chore(localize): improve localize storybook demo
This commit is contained in:
parent
3a0c71e6aa
commit
e9611c6a3e
1 changed files with 27 additions and 27 deletions
|
|
@ -41,48 +41,48 @@ Localization data modules for `my-hello-component` might look like these:
|
||||||
|
|
||||||
- `/path/to/my-hello-component/translations/en-GB.js`
|
- `/path/to/my-hello-component/translations/en-GB.js`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
export default {
|
export default {
|
||||||
greeting: 'Hello {name}!',
|
greeting: 'Hello {name}!',
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
- `/path/to/my-hello-component/translations/nl-NL.js`
|
- `/path/to/my-hello-component/translations/nl-NL.js`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
export default {
|
export default {
|
||||||
greeting: 'Hallo {name}!',
|
greeting: 'Hallo {name}!',
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
The approach with ES modules is great because it allows to simply reuse basic locale data and override only the needed parts for more specific locales.
|
The approach with ES modules is great because it allows to simply reuse basic locale data and override only the needed parts for more specific locales.
|
||||||
|
|
||||||
- `/path/to/my-family-component/translations/en.js`
|
- `/path/to/my-family-component/translations/en.js`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
export default {
|
export default {
|
||||||
havePartnerQuestion: 'Do you have a partner?',
|
havePartnerQuestion: 'Do you have a partner?',
|
||||||
haveChildrenQuestion: 'Do you have children?',
|
haveChildrenQuestion: 'Do you have children?',
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
- `/path/to/my-family-component/translations/en-GB.js`
|
- `/path/to/my-family-component/translations/en-GB.js`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
import en from './en.js';
|
import en from './en.js';
|
||||||
export default en;
|
export default en;
|
||||||
```
|
```
|
||||||
|
|
||||||
- `/path/to/my-family-component/translations/en-US.js`
|
- `/path/to/my-family-component/translations/en-US.js`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
import en from './en.js';
|
import en from './en.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
...en,
|
...en,
|
||||||
haveChildrenQuestion: 'Do you have kids?',
|
haveChildrenQuestion: 'Do you have kids?',
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
### Loading data
|
### Loading data
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue