Skip to content
/ ipret Public

Micro i18n library for node and browser. Translate your app with strings already there.

License

Notifications You must be signed in to change notification settings

dbtek/ipret

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ipret 🌍

Build Status Test Coverage Standard

Micro i18n library for node and browser. Ugly name comes from interpret. Use it to translate your app with strings already there.

Install

$ npm install ipret -S

Usage

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

API

setStrings(lang, strings)

Adds new language with translations. lang is language identifier (e.g. language code). strings is key-value translations.

setLanguage(lang)

Activates a language to use in translations. lang is language identifier used before in setStrings.

translate(str)

Translates given string if a translation for it is defined.

getLanguage()

Returns active language identifier.

getLanguages()

Returns all languages that are being used.

License

MIT

Author

İsmail Demirbilek - @dbtek

About

Micro i18n library for node and browser. Translate your app with strings already there.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published