sahara-localization

0.1.2 • Public • Published

Installation

npm install --save sahara-localization

Usage

import _, {setLocalizations} from 'sahara-localization';

setLocalizations({
    en: {
        'hello': 'hello',
        'hello %s': 'hello %s',
        '%s has %s post': '%s has %s post',
        '%s has %s posts': '%s has %s posts'
    },
    es: {
        'hello': 'hola',
        'hello %s': 'hola %s',
        '%s has %s post': '%s tiene %s posta',
        '%s has %s posts': '%s tiene %s puestos'
    }
});

console.log(_('test', 'test')); // test
console.log(_('en', 'hello')); // hello
console.log(_('es', 'hello')); // hola
console.log(_('en', 'hello %s', 'John')); // hello John
console.log(_('es', 'hello %s', 'John')); // hola John

var postCount = 1;
console.log(_('en', ['%s has %s post', '%s has %s posts', () => postCount > 1 ? 1 : 0], 'John', postCount)); // John has 1 post

var postCount = 2;
console.log(_('es', ['%s has %s post', '%s has %s posts', () => postCount > 1 ? 1 : 0], 'John', postCount)); // John tiene 2 puestos

Readme

Keywords

none

Package Sidebar

Install

npm i sahara-localization

Weekly Downloads

0

Version

0.1.2

License

ISC

Unpacked Size

4.47 kB

Total Files

4

Last publish

Collaborators

  • anvilapp