Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

lang

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lang

A tiny internationalization library

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

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('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.

Keywords

language

FAQs

Package last updated on 22 Apr 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts