1.0.2 • Published 5 years ago

minimalistic-i18n v1.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

:airplane: Minimalistic i18n

Minimalistic internationalization JavaScript library

Build Status

Installation

npm install minimalistic-i18n

Usage

import i18n from 'minimalistic-i18n';

i18n.addLocale('en', {
    foo: 'the bar',
    msg: ['message', 'messages'],
    email: {
        hey: 'Hey!',
        info: 'Hi {name}. {@email.hey} You have {number} {@msg(number)}.'
    }
});
i18n.setLocale('en');

i18n('foo'); // "the bar"
i18n('email.baz'); // "email.baz"
i18n('msg', 3); // "messages"
i18n('email.info', { name: 'James', number: 0 }); // "Hi James. Hey! You have 0 messages."
i18n('email.info', { name: 'James', number: 1 }); // "Hi James. Hey! You have 1 message."

i18n.addLocale('fr', {
    foo: 'le bar'
});
i18n.setLocale('fr');
i18n('foo'); // "le bar"

i18n.setLocale('en');
i18n('foo'); // "the bar"

License

MIT