1.0.2 • Published 5 years ago

langylanglang v1.0.2

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

package version package downloads standard-readme compliant package license make a pull request

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

  1. Fork it and create your feature branch: git checkout -b my-new-feature
  2. Commit your changes: git commit -am "Add some feature"
  3. Push to the branch: git push origin my-new-feature
  4. Submit a pull request

License

MIT

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

6 years ago