@blueeast/bluerain-plugin-intl
v2.1.1
Published
A BlueRain Plugin to add Internationalization through react-intl.
Downloads
41
Keywords
Readme
bluerain Internationalisation plugin
Adds internationalization through react-intl-redux . https://blueeast.gitbook.io/bluerain-plugin-intl
| 🌏 Web | 🖥 Electron | 📱 React Native | | :----------------: | :----------------: | :----------------: | | ✔️ | ✔️ | TBD |
Screenshots
NA
Components
This plugin registers following components in the Component registry, so they can be reused later by other apps and plugins:
FormattedMessageWeb
FormattedNumber Web
FormattedPlural Web
FormattedDate Web
FormattedTimeWeb
FormattedRelativeWeb
IntlConsumer
This Component is used to provide Intl functionality as a prop
<BR.Components.IntlConsumer>
{({ children, intl }) => {
return props.intl
}}
</BR.Components.IntlConsumer>
Hooks
bluerain.intl.messages
This hook gives the ability to add custom intl messages.
Parameters:
| Name | Type | Description | | -------- | ------ | --------------- | | messages | Object | The messages db |
Returns:
| Name | Type | Description | | -------- | ------ | --------------- | | messages | Object | The messages db |
Example:
This example registers custom english and urdu messages to the system:
BR.Filters.add('bluerain.intl.messages', function eng(messages) {
const en = require('./lang/en.ts');
const ur = require('./lang/ur.ts');
messages.en = Object.assign(messages.en ? messages.en : {}, en);
messages.ur = Object.assign(messages.ur ? messages.ur : {}, ur);
return messages;
});
API
IntlPluginConfigs
This is the default configuration set that is used at boot time.
Properties
locale
Array [default: "en"] Tries to detect automatically, falls back to 'en'.localeData
Array An array of localData files.
InternationalizationPlugin
Extends Plugin
react-intl plugin to add internationalization to BlueRain Apps
Plugin Properties
setLocale
Change app's locale
setLocale Parameters
withIntl
Higher Order component in inject intl
prop in Component
Parameters
Component
Component
Returns Component
injectIntl
react-intl
's higher order component
injectIntl Parameters
Component
Component
Returns Component