Skip to content

Latest commit

 

History

History
 
 

localize

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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`);
  },
});

Translating messages:

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