Skip to content

A lightweight (not asynchronous) i18n module for creating cli tools

License

Notifications You must be signed in to change notification settings

azukiapp/i18n-cli

Repository files navigation

i18n-cli

Usage

Create a folder shared/locales, and a file:

// shared/locales/en-US.js
module.exports = {
    key: { found: "foobar" },
    formated: "formated %s",
    array_value: ["item1", "item2"],
    wildkey: {
        '*': { 'subkey': 'value default' },
        'linux': { 'subkey': 'value linux' },
    },
    colors: {
        'red': '${red}red text${red.close}',
    }
};

Now you can use:

// index.js
import { I18n } from 'i18n';     // es6
var I18n = require('i18n');      // es5

var i18n = new I18n({
    path  : ('locales'),
    locale: 'en-US'
});

i18n.t('key.found');              // "foobar"
i18n.t('formated', "with value"); // "formated with value"
i18n.t('array_value');            // ["item1", "item2"]
i18n.t('wildkey.linux.subkey');   // value linux
i18n.t('wildkey.macosx.subkey');  // value default

Check the sprintf-js to know what to use in "formated strings".

Check the ansi-styles to know what colors to use.

License

"Azuki", "Azk" and the Azuki logo are copyright (c) 2013-2017 Azuki Serviços de Internet LTDA.

i18n-cli is released under Apache 2 License.

Check LEGAL and LICENSE files for more information.

About

A lightweight (not asynchronous) i18n module for creating cli tools

Resources

License

Stars

Watchers

Forks

Packages

No packages published