lion/packages/localize/README.md
Thomas Allmer 89b835a799 feat: improved storybook demos
Co-authored-by: Joren Broekema <Joren.Broekema@ing.com>
Co-authored-by: Alex Ghiu <Alex.Ghiu@ing.com>
Co-authored-by: Thijs Louisse <Thijs.Louisse@ing.com>
2020-01-13 13:58:03 +01:00

48 lines
859 B
Markdown

# Localize
[//]: # 'AUTO INSERT HEADER PREPUBLISH'
The localization system helps to manage localization data split into locales and automate its loading.
## Live Demo/Documentation
> See our [storybook](http://lion-web-components.netlify.com/?path=/docs/localize--page) for a live demo and documentation
## How to use
### Installation
```sh
npm i --save @lion/localize
```
```js
import { localize } from '@lion/localize';
```
### Example
Translation data:
```js
// path/to/hello-world/translations/en-GB.js
export default { greeting: 'Hello {name}!', };`
```
Loading translations:
```js
// path/to/hello-world/HelloWorld.js
localize.loadNamespace({
'hello-world': locale => {
return import(`./translations/${locale}.js`);
},
});
```
Translating messages:
```js
localize.msg('hello-world:greeting', { name: 'John' });
// Hello John!
```