Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/callumacrae/lang
:earth_americas: An tiny language library
https://github.com/callumacrae/lang
Last synced: 10 days ago
JSON representation
:earth_americas: An tiny language library
- Host: GitHub
- URL: https://github.com/callumacrae/lang
- Owner: callumacrae
- Created: 2015-03-05T17:45:24.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-04-22T09:14:35.000Z (over 9 years ago)
- Last Synced: 2024-10-11T00:10:39.765Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 133 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# lang
A tiny language library. Put this on your page:
```html
{
"numbers" {
"one": "Un",
"two": "Deux",
"three": "Trois",
"four": "Quatre"
},
"sentence": "Ce est une phrase"
}```
Then, you can use the lang function as follows:
```js
var lang = require('lang');lang('numbers.two'); //=> Deux
lang('sentence'); //=> Ce est une phrase
```You can have multiple script tags and it'll merge the objects. The idea is that
you output the JSON from the server using the already localised text, instead
of putting localised text straight into your JavaScript.If this library is too simple for you, check out something like [i18next].
## Todo
Add tests.
## Install
```
$ npm install --save lang
```(note: used to be tiny-lang, and is still available as tiny-lang on npm, but
that won't be updated)## License
Released under the MIT license.
[i18next]: http://i18next.com/