react-intl

  • Version 5.20.13
  • Published
  • 247 kB
  • 10 dependencies
  • BSD-3-Clause license

Install

npm i react-intl
yarn add react-intl
pnpm add react-intl

Overview

Internationalize React apps. This library provides React components and an API to format dates, numbers, and strings, including pluralization and handling translations.

Index

Variables

variable createIntl

const createIntl: any;
  • Create intl object

    Parameter config

    intl config

    Parameter cache

    cache for formatter instances to prevent memory leak

variable FormattedDate

const FormattedDate: any;

    variable FormattedDateParts

    const FormattedDateParts: any;

      variable FormattedDateTimeRange

      const FormattedDateTimeRange: any;

        variable FormattedDisplayName

        const FormattedDisplayName: any;

          variable FormattedList

          const FormattedList: any;

            variable FormattedListParts

            const FormattedListParts: any;

              variable FormattedMessage

              const FormattedMessage: any;

                variable FormattedNumber

                const FormattedNumber: any;

                  variable FormattedNumberParts

                  const FormattedNumberParts: any;

                    variable FormattedPlural

                    const FormattedPlural: any;

                      variable FormattedRelativeTime

                      const FormattedRelativeTime: any;

                        variable FormattedTime

                        const FormattedTime: any;

                          variable FormattedTimeParts

                          const FormattedTimeParts: any;

                            variable IntlContext

                            const IntlContext: any;

                              variable RawIntlProvider

                              const RawIntlProvider: any;

                                Functions

                                function defineMessage

                                defineMessage: <T extends any>(msg: T) => T;

                                  function defineMessages

                                  defineMessages: <
                                  K extends string | number | symbol,
                                  T = any,
                                  U extends Record<K, T> = Record<K, T>
                                  >(
                                  msgs: U
                                  ) => U;

                                    function injectIntl

                                    injectIntl: {
                                    <
                                    IntlPropName extends string = 'intl',
                                    P extends WrappedComponentProps<IntlPropName> = WrappedComponentProps<any>
                                    >(
                                    WrappedComponent: any,
                                    options?: Opts<IntlPropName, false>
                                    ): React.FC<WithIntlProps<P>> & { WrappedComponent: React.ComponentType<P> };
                                    <
                                    IntlPropName extends string = 'intl',
                                    P extends WrappedComponentProps<IntlPropName> = WrappedComponentProps<any>,
                                    T extends any = any
                                    >(
                                    WrappedComponent: any,
                                    options?: Opts<IntlPropName, true>
                                    ): any;
                                    };

                                      function useIntl

                                      useIntl: () => IntlShape;

                                        Classes

                                        class IntlProvider

                                        class IntlProvider extends React.PureComponent<
                                        React.PropsWithChildren<IntlConfig>,
                                        State
                                        > {}

                                          property defaultProps

                                          static defaultProps: Pick<
                                          ResolvedIntlConfig,
                                          | 'timeZone'
                                          | 'formats'
                                          | 'messages'
                                          | 'defaultLocale'
                                          | 'defaultFormats'
                                          | 'onError'
                                          | 'textComponent'
                                          >;

                                            property displayName

                                            static displayName: string;

                                              property state

                                              state: State;

                                                method getDerivedStateFromProps

                                                static getDerivedStateFromProps: (
                                                props: Readonly<IntlConfig>,
                                                { prevConfig, cache }: State
                                                ) => Partial<State> | null;

                                                  method render

                                                  render: () => any;

                                                    Interfaces

                                                    interface IntlShape

                                                    interface IntlShape extends ResolvedIntlConfig, IntlFormatters<React.ReactNode> {}

                                                      property formatters

                                                      formatters: Formatters;

                                                        interface ResolvedIntlConfig

                                                        interface ResolvedIntlConfig extends CoreResolvedIntlConfig<React.ReactNode> {}

                                                          property textComponent

                                                          textComponent?: React.ComponentType | keyof React.ReactHTML;

                                                            property wrapRichTextChunksInFragment

                                                            wrapRichTextChunksInFragment?: boolean;

                                                              Type Aliases

                                                              type IntlConfig

                                                              type IntlConfig = Omit<ResolvedIntlConfig, keyof typeof DEFAULT_INTL_CONFIG> &
                                                              Partial<typeof DEFAULT_INTL_CONFIG>;

                                                                type WithIntlProps

                                                                type WithIntlProps<P> = Omit<P, keyof WrappedComponentProps> & {
                                                                forwardedRef?: React.Ref<any>;
                                                                };

                                                                  type WrappedComponentProps

                                                                  type WrappedComponentProps<IntlPropName extends string = 'intl'> = {
                                                                  [k in IntlPropName]: IntlShape;
                                                                  };

                                                                    Package Files (10)

                                                                    Dependencies (10)

                                                                    Dev Dependencies (0)

                                                                    No dev dependencies.

                                                                    Peer Dependencies (2)

                                                                    Badge

                                                                    To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                    You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/react-intl.

                                                                    • Markdown
                                                                      [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/react-intl)
                                                                    • HTML
                                                                      <a href="https://www.jsdocs.io/package/react-intl"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>