🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

locale-manager

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

locale-manager

Tool used to dynamically load localized content.

latest
Source
npmnpm
Version
1.2.6
Version published
Weekly downloads
32
-21.95%
Maintainers
1
Weekly downloads
 
Created
Source

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
  • Examples

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

Keywords

locale

FAQs

Package last updated on 11 Sep 2016

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