1.0.0 • Published 8 years ago

js-translate v1.0.0

Weekly downloads
12
License
MIT
Repository
github
Last release
8 years ago

JS-TRANSLATE

Build Status

Very easy i18n library. Just load your data, and then start to translate.

  • supports wildcards
  • supports regional dialects with residing to global
  • several levels of warning

Usage

import { i18n } from 'js-translate';

// init current language and default language
const translator = i18n({ language: 'en', defaultLanguage: 'en' });
// fill dictionary
translator.add([{
    language: 'en',
    data: {
        'my string': 'Some translated stuff!',
        'string with {params}': '{params} is here!'
    }
}]);

// use
translator.translate('string with {params}', 'Date');
-> Date is here!

// change language
translator.useLanguage('ta');

You could specify several translators, with different parameters. If default wildcards isn't appropriate to you, then you could change it:

const translator = i18n({ language: 'en', startSeparator: '{{', endSeparator: '}}' });

And again, all instansiated translators don't share these settings.


© 2015 MIT