Localize your interface
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'))
This project uses node and npm.
$ npm install langylanglang
$ # OR
$ yarn add langylanglang
- 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
MIT