open-i18n

0.5.0 • Public • Published

open-i18n

=================

Build status codecov

Quick start

npm install open-i18n --save

Usage

var i18n = require('i18n');
 
// languages System allow language
// locale Current request use lanuage
// language packages,
/*
  {
    "zh": {
      "hello world": "你好世界。"
    },
    "en": {
      "hello world": "Hello world."
    }
  }
 */
var t = i18n(languages, locale, LANGS).t;
 
t('hello world'); // return "你好世界"
 
// middle-ware auto handle res.body when request error
server.use(i18n.middleWare(languages, defaultLanguage, LANGS))

Collect language items

  find ./src/app -type f | node_modules/.bin/open-i18n read > bin/locale/application.pot
  msgmerge -UN --no-wrap ./bin/locale/en.po ./bin/locale/application.pot
  msgmerge -UN --no-wrap ./bin/locale/zh.po ./bin/locale/application.pot

Translate language items

Edit en.po, zh.po to translate.

Make language package

  node_modules/.bin/open-i18n write ./bin/locale/zh.po zh > locale/zh.json

Readme

Keywords

Package Sidebar

Install

npm i open-i18n

Weekly Downloads

0

Version

0.5.0

License

MIT

Last publish

Collaborators

  • stonephp