i18nt-gen
TypeScript icon, indicating that this package has built-in type declarations

1.3.1 • Public • Published

i18nt-gen

NPM Version NPM Downloads NPM License

生成翻译函数

Install

npm install i18nt-gen --save

Usage

const { i18nt } = require('i18nt-gen');
const i18n = i18nt(translateData);

i18n('中文');   // chinese
i18n('中文', 'short');   // zh

i18n('我是%s', ['Bacra']);    // I‘m Bacra
i18n('我是%s', ['Bacra'], { language: 'hk' });    // 我是Bacra
i18n('我是%{1} %{0}', ['woo', 'Bacra']);          // 我是Bacra woo
i18n('我是%{username} %{firstname}', { tpldata: { username: 'Bacra' firstname: 'woo' } });  // 我是Bacra woo

const username = 'Bacra';
i18n.t`我是${username}`  // I‘m Bacra
i18n.t({ language: 'hk' })`我是${username}`  // 我是Bacra
i18n.t({ encode: 'urlEncode' })`我是${{ text: username, encode: false }}`  // %E6%88%91%E6%98%AFBacra

/i18nt-gen/

    Package Sidebar

    Install

    npm i i18nt-gen

    Weekly Downloads

    11

    Version

    1.3.1

    License

    MIT

    Unpacked Size

    26.9 kB

    Total Files

    24

    Last publish

    Collaborators

    • bacra