0.0.3 • Published 10 years ago
i18n-that-works v0.0.3
i18n that works!
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
directory: path to your locales directory.defaultLocale: the locale to use by default. ("en"if not specified)objectNotation: the separator to use for object notation. ("."if not specified)
Features
String replacement:
Locale JSON:
{ "greeting": "Hello %s" }Code:
i18n.t('greeting', 'Gerhard'); //=> "Hello Gerhard"Object Notation:
Locale JSON:
{ "greetings": { "morning": "Good Morning" } }Code:
i18n.t('greetings.morning'); //=> "Good Morning"And BOTH!!!
Locale JSON:
{ "greetings":{ "morning": "Good Morning %s" } }Code:
i18n.t('greetings.morning', 'Gerhard'); //=> "Good Morning Gerhard"