Skip to content

golgotha/i18n-tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

i18n-tools

CircleCI

A simple internationalization library.

Installation

Install with npm

# via npm
npm install @numizmatclub/i18n-tool

# or Yarn
yarn add @numizmatclub/i18n-tool

Usage

import I18n from '@numizmatclub/i18n-tool';
import de_DE from './de_DE.json';

const i18n = new I18n('en_US')
    .addLocale("en_US", {
        title: "Title",
        totalItemsX: "Total items: {0}",
        deep: {
            dive: "Dive"
        }
    })
    .addLocale("uk_UA", {
        title: "Заголовок",
        totalItemsX: "Всього елементів: {0}"
    })
    .addLocale("de_DE", de_DE)
    .assignTranslation('en_US');

    const title = i18n.t('title');
    const totalItems = i18n.t('totalItemsX', 10);
    const deepDive = i18n.t('deep.dive');

Change translation:

    i18n.assignTranslation("uk_UA");

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published