0.1.19 • Published 9 years ago

mrpi18n v0.1.19

Weekly downloads
1
License
MIT
Repository
-
Last release
9 years ago

i18n Circle CI

Simple translation module for node.js

Install

npm install i18n-mrp

test

npm test

usage

Minimal example, just setup two locales and a project specific directory

  1. create the locales directory with two JSON files (bundle.en.json, bundle.fr.json).

  2. load and configure the module within your project

    var i18n = require('i18n-mrp').configure({
        locales:['en', 'fr'],
        directory: __dirname + '/locales' // path to  your locales directory
    });

language-country usage

when calling for a merged result of two locales (one being the language and the other being country) as demonstrated below:

i18n.getCatalog('en-fr')
// {'currency': '€', 'Hello': 'Hello World'}

'en-fr' is a combination of en being the language and fr being the country.

API

The module exposes a single method getCatalog.

getCatalog

When a params of a valid local is given, the module will return the JSON object.

  i18n.getCatalog('en')

// {'Hello': 'Hello World'}

You can get also a merged result of two locales

  i18n.getCatalog('en-fr')

// {'currency': '€', 'Hello': 'Hello World'}

When no params is given, the module will return the full catalog

  i18n.getCatalog()

// { en: { 'Hello World': 'Hello World' },fr: { currency: '€', 'Hello World': 'Bonjour' } }

credit

Inspiration came from the i18n-node module: https://github.com/mashpie/i18n-node

0.1.19

9 years ago

0.1.18

9 years ago

0.1.17

9 years ago

0.1.16

9 years ago

0.1.15

9 years ago

0.1.14

9 years ago

0.1.13

9 years ago

0.1.12

9 years ago

0.1.11

9 years ago