Socket
Book a DemoInstallSign in
Socket

i81n

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

i81n

An ultra lightweight translation library using tagged template literals.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

i81n

An ultra lightweight translation library using tagged template literals.

Usage

The translate function is stored in global['t'] by default. The default language is en_EN.

const i81n = require('i81n')()

i81n.addTranslations('en_EN', {
   hello: 'Hello',
   bye: 'Goodbye'
})

i81n.addTranslations('de_DE', {
   hello: 'Hallo',
   bye: 'Auf Wiedersehen'
})

i81n.addTranslations('fr_FR', {
   hello: 'Bonjour',
   bye: 'Au Revoir'
})


console.log(t`hello`)
// => 'Hello'


i81n.setLanguage('de_DE')

console.log(t`bye`)
// => 'Auf Wiedersehen'


i81n.setLanguage('fr_FR')

console.log(t`hello`)
// => 'Bonjour'

console.log(t`unknown translation`)
// => 'unknown translation'

FAQs

Package last updated on 06 Nov 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts