track-i18n
v0.0.4
Published
Internationalization support for track.
Downloads
2
Readme
TrackI18n
Internationalization support for track.
Installation
npm
npm install track-i18n
Usage
Define locale.
models.ja.js
module.exports = {
models: {
anime: {
title: 'Title',
creator: 'Creator',
},
},
};
YAML is useful, when define locale.
(Webpack
and yaml-loader
is very very very good)
models.ja.yml
views:
index:
hello: 'Welcome to yokoso japaripark!',
serval: 'I am %{name} of serval cat.',
show:
title: 'The friends of %{type}.'
Translate
const I18n = require('track-i18n');
I18n.load(require('./models.ja'));
I18n.load(require('./views.ja'));
I18n.t('views.index.hello'); // => 'Welcome to yokoso japaripark!'
I18n.t('views.index.serval', {name: 'serval'}); // => 'I am servel of serval cat.'