0.0.4 • Published 6 years ago

track-i18n v0.0.4

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

TrackI18n

Internationalization support for track.

Build Status

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.'