1.0.2 • Published 5 years ago
langylanglang v1.0.2
Localize your interface
Table of Contents
Usage
import { set, onMissingKey, t, locale, fallback } from './langylanglang'
set('en', {
greeting: 'Hi {bar}! how are you?',
info: 'Bye buddy!'
})
set('za', {
greeting: 'Hi {bar}! Hoe gaan dit my bra?',
info: 'Cheers tjom!'
})
// Can also set multiple
// set({
// 'en': {
// greeting: 'Hi {bar}! how are you?',
// info: 'Bye buddy!'
// },
// {
// greeting: 'Hi {bar}! Hoe gaan dit my bra?',
// info: 'Cheers tjom!'
// }
// })
onMissingKey((...args) => {
console.log('Got missing key', args)
return ''
})
console.log(
t('greeting', {
bar: 'Tiaan',
bing: 'mcface'
})
)
console.log(t('info'))
locale('za')
console.log(
t('greeting', {
bar: 'Tiaan',
bing: 'mcface'
})
)
console.log(t('info'))
Install
This project uses node and npm.
$ npm install langylanglang
$ # OR
$ yarn add langylanglang
Contribute
- Fork it and create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am "Add some feature"
- Push to the branch:
git push origin my-new-feature
- Submit a pull request
License
MIT