i18n/I18nDecorator

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
latinLanguageOverrides
ArrayString

Array of locales that should be treated as latin regardless of their script.

Default: null
nonLatinLanguageOverrides
ArrayString

Array of locales that should be treated as non-latin regardless of their script.

Default: null
resources
Array of

Array 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 is true or a Promise for the resource when options.sync is false.

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: null
sync
Boolean

Retrieve i18n resource files synchronously

Default: false
Properties added to wrapped component
className
String

Classname for a root app element.

locale
String

A string with a BCP 47 language tag.

The system locale will be used by default.

ArrayBooleanFunctionModuleNumberObjectString