Micro i18n library for node and browser. Ugly name comes from interpret. Use it to translate your app with strings already there.
$ npm install ipret -S
Below example can be used in node / browserify transform. For standalone usage include dist/ipret.js
.
const ipret = require('ipret')
// add some translations
ipret.setStrings('tr', {
'Current password': 'Şimdiki şifre',
'New password': 'Yeni şifre',
'Change Password': 'Şifreyi Değiştir',
'Updated {0}': '{0} güncellendi',
'password': 'şifre'
})
// set active lang
ipret.setLanguage('tr')
_ = ipret.translate
// translate
_('Current password') // Şimdiki şifre
_('New password') // Yeni şifre
_('Updated {0}', 'password') // şifre güncellendi
_('New email address') // [Not translated string] New email address
Adds new language with translations. lang
is language identifier (e.g. language code). strings
is key-value translations.
Activates a language to use in translations. lang
is language identifier used before in setStrings
.
Translates given string if a translation for it is defined.
Returns active language identifier.
Returns all languages that are being used.
MIT
İsmail Demirbilek - @dbtek