lion/packages/localize
2020-04-29 10:05:06 +02:00
..
docs feat: refrain from using dynamic vars inside dynamic import 2020-03-25 17:02:10 +01:00
src fix(localization): force TR currency code at the end (#641) 2020-04-29 10:05:06 +02:00
stories feat: refrain from using dynamic vars inside dynamic import 2020-03-25 17:02:10 +01:00
test fix(localization): force TR currency code at the end (#641) 2020-04-29 10:05:06 +02:00
test-helpers fix: public test-helpers 2019-07-30 15:50:53 +02:00
CHANGELOG.md chore: release new versions 2020-04-02 14:28:44 +00:00
index.js fix(input-amount): normalize added for currency label (#618) 2020-03-04 17:33:09 +01:00
package.json chore: release new versions 2020-04-02 14:28:44 +00:00
README.md feat: refrain from using dynamic vars inside dynamic import 2020-03-25 17:02:10 +01:00
test-helpers.js fix: public test-helpers 2019-07-30 15:50:53 +02:00

Localize

The localization system helps to manage localization data split into locales and automate its loading.

Live Demo/Documentation

See our storybook for a live demo and documentation

How to use

Installation

npm i --save @lion/localize
import { localize } from '@lion/localize';

Example

Translation data:

// path/to/hello-world/translations/en-GB.js
export default { greeting: 'Hello {name}!', };`

Loading translations:

// path/to/hello-world/HelloWorld.js
localize.loadNamespace({
  'hello-world': locale => {
    return import(`./translations/${locale}.js`);
  },
});

Note: dynamic variables inside dynamic imports may cause problems with tools that do static analysis, and may not work out of the box

Translating messages:

localize.msg('hello-world:greeting', { name: 'John' });
// Hello John!