i18n/ I18n Decorator
Adds Internationalization (I18N) support to an application using ilib.
import I18nDecorator from '@enact/i18n/I18nDecorator';
Members
I18nDecoratorHigher-Order Component
A higher-order component that is used to wrap the root element in an app. It provides an rtl
member on the context of the wrapped component, allowing the children to check the current text
directionality as well as an updateLocale
method that can be used to update the current locale.
There are no configurable options on this HOC.
Note: This HoC passes className
to the wrapped component. It must be passed to the main DOM
node.
import I18nDecorator from '@enact/i18n/I18nDecorator';
Configuration
Array of locales that should be treated as latin regardless of their script.
Default: nullArray of locales that should be treated as non-latin regardless of their script.
Default: nullArray of resource loaders to be invoked after a locale change.
Each loader must be a function which accepts an object and returns either the resource when
options.sync
istrue
or aPromise
for the resource whenoptions.sync
isfalse
.resources: [ (options) => new Promise((resolve, reject) => { fetchResource({onLoad: resolve, onError: reject}); }) ]
If you need to handle the resource in some way on load, you can pass an object with an
onLoad
member that will be called once all resources have been loaded. This should be used if loading a resource has side effects that should only be applied once all loading has completed.resources: [ {resource: (options) => { ... fetch ... }, onLoad: (res) => { ... apply side effect ... }} ]
Default: nullRetrieve i18n resource files synchronously
Default: false
Properties added to wrapped component
Classes to apply to the wrapped component.
The locale to use.
A string with a BCP 47 language tag. The system locale will be used by default.