0.5.3 • Published 6 years ago

react-intl-locale v0.5.3

Weekly downloads
13
License
MIT
Repository
-
Last release
6 years ago

react-intl-locale

Dynamically load locale as needed for react-intl.

Install

$ npm install react-intl-locale

Use

import initLocale, { defaultLocale, getLocale, setLocale, getLocaleMessages } from 'react-intl-locale';
...
initLocale('en-CA', ['fr-CA']);
...
const locale = getLocale();
const messages = getLocaleMessages(['./{locale}.header.json','./{locale}.footer.json']);
...
<IntlProvider
    locale={locale}
    defaultLocale={defaultLocale}
    messages={messages}
>
...

Docs

initLocale

  • defaultLocale (String): Set the default locale to use in the app. default: en.
  • allowedLocales (String[]): List of locales supported inteh app, excluding the defaultLocale, defaultLocale will be added to it.

Using the browsers locale and the locales initialized the best match will be returned for use.

getLocale

Returns the currently selected locale

setLocale

Overrides the the current locale, if allowed based in the init.

getLocaleMessages

  • locale (String): Current locale
  • paths (String[]): Array to paths to load for locale. Has locale replacement built in {locale}. Path names are relative the root of the build folder.
0.5.3

6 years ago

0.5.2

6 years ago

0.5.1

6 years ago

0.5.0

6 years ago

0.4.1

7 years ago

0.4.0

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago