import { Story, Meta, html } from '@open-wc/demoing-storybook';
import { render } from '@lion/core';
import { localize, formatNumber, formatDate } from '../index.js';
## Translate Text
### As a function
```js
localize.msg('lit-html-example:body'); // for en-GB: I am from England
localize.msg('lit-html-example:body'); // for nl-NL: Ik kom uit Nederland
// ...
```
### Web Component
For use in a web component we have `LocalizeMixin` that lets you define namespaces and awaits loading of those translations.
```js
class MessageExample extends LocalizeMixin(LitElement) {
render() {
return html`
${localize.msg('lit-html-example:body')}
`;
}
}
```
## Numbers
To format numbers you can use `formatNumber`. For more details see [Numbers](?path=/docs/localize-system-numbers--formatting).
{() => {
const wrapper = document.createElement('div');
let value = 1234.56;
function update() {
render(
html`
${formatNumber(value)}
`,
wrapper,
);
}
localize.addEventListener('localeChanged', () => {
update();
});
update();
const input = wrapper.querySelector('input');
input.addEventListener('input', ev => {
value = ev.target.value;
update();
});
return wrapper;
}}
## Dates
To format dates you can use `formatDate`. For more details see [Dates](?path=/docs/localize-system-dates--formatting).
{() => {
const wrapper = document.createElement('div');
let value = '1987/05/12';
function update() {
render(
html`