Skip to content
/ x18n-ts Public

Typescript wrapper for X18n - A sane JavaScript internationalisation library

License

Notifications You must be signed in to change notification settings

anwfr/x18n-ts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

X18n-ts

  • Typescript wrapper for X18n - A sane JavaScript internationalisation library
  • Tested with webpack

## Installation

npm install x18n

Usage

import {X18nLoader} from '../lib/x18n-ts'

let lang = 'fr'
let langDefault = 'en'
let bundle = new X18nLoader(lang, langDefault) // optional parameters - can be set later

// set i18n messages
bundle.set('fr', {
    'hello': 'Bonjour',
    'bye': 'Au revoir'
})
bundle.set('en', {
    'hello': 'Hello',
    'bye': 'Bye'
})

// override i18n messages
bundle.override('fr', {
    'hello': 'Bonjour override'
})

// get i18n message in current lang
bundle.t('hello') // 'Bonjour override'

// switch lang
bundle.setLang('en')

// switch default lang
bundle.setLangDefault('fr')

// get i18n message in current lang
bundle.t('hello') // 'Hello'

## Credits

About

Typescript wrapper for X18n - A sane JavaScript internationalisation library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published