0.1.1 • Published 9 years ago

tiny-lang v0.1.1

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

tiny-lang

A tiny language library. Put this on your page:

<script type="text/x-i18n-json">
	{
        "numbers" {
            "one": "Un",
            "two": "Deux",
            "three": "Trois",
            "four": "Quatre"
        },
        "sentence": "Ce est une phrase"
    }
</script>

Then, you can use the lang function as follows:

var lang = require('tiny-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 tiny-lang

License

Released under the MIT license.