0.0.3 • Published 8 years ago

i18n-that-works v0.0.3

Weekly downloads
2
License
MIT
Repository
-
Last release
8 years ago

i18n that works!

Circle CI

How to?

Create a locales file ...

{
  "greeting": "Hello"
}

... and use it!

var i18n = require('i18n-that-works');

i18n.configure({
  directory: './myLocales'
});

i18n.t('greeting'); //=> "Hello"

It's that easy, folks!

Options

  1. directory: path to your locales directory.

  2. defaultLocale: the locale to use by default. ("en" if not specified)

  3. objectNotation: the separator to use for object notation. ("." if not specified)

Features

  1. String replacement:

    Locale JSON:

    {
      "greeting": "Hello %s"
    }

    Code:

    i18n.t('greeting', 'Gerhard'); //=> "Hello Gerhard"
  2. Object Notation:

    Locale JSON:

    {
      "greetings": {
        "morning": "Good Morning"
      }
    }

    Code:

    i18n.t('greetings.morning'); //=> "Good Morning"
  3. And BOTH!!!

    Locale JSON:

    {
     "greetings":{
       "morning": "Good Morning %s"
     }
    }

    Code:

    i18n.t('greetings.morning', 'Gerhard'); //=> "Good Morning Gerhard"