1.2.6 • Published 8 years ago

locale-manager v1.2.6

Weekly downloads
2
License
ISC
Repository
github
Last release
8 years ago

Locale-Manager - Simplified Localization

npm package

Super simple to use

Locale-Manager is designed to be the simplest way possible to localize content while keeping an organized, scalable project structure.

var localeManager = require("locale-manager");

var locale = "en-US";
console.log(localeManager[locale].hello); // Hello

locale = "es-MX";
console.log(localeManager[locale].hello); // Hola

Table of contents


Setup:

  • Create a locales directory in the root of your Node.js project.
    • mkdir locales
  • Create all supported locale files within the locales directory
  • Enjoy!

Examples:

Usage:

  var localeManager = require("locale-manager");

  var locale = "en-US";
  console.log(localeManager[locale].hello); // Hello
  console.log(localeManager[locale].greet("Bob"); // Hello Bob

  locale = "es-MX";
  console.log(localeManager[locale].hello); // Hola
  console.log(localeManager[locale].greet("Bob"); // Hola Bob
Locales:
myNodeProject/locales/english.js
  var english = {
    // locale
    locale: "en-US",
    // Hello
    hello: "Hello",
    greet: function(name) { return "Hello " + name; }
  };
  module.exports = english;
myNodeProject/locales/spanish.js
  var spanish = {
    // locale
    locale: "es-MX",
    // Hello
    hello: "Hola",
    greet: function(name) { return "Hola " + name; }
  };
  module.exports = spanish;

back to top

1.2.6

8 years ago

1.2.5

8 years ago

1.2.4

8 years ago

1.2.3

8 years ago

1.2.2

8 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.9

8 years ago

1.1.8

8 years ago

1.1.7

8 years ago

1.1.6

8 years ago

1.1.5

8 years ago

1.1.4

8 years ago

1.1.3

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago