https://github.com/felangel/locale-manager
Locale-Manager is designed to be the simplest way possible to localize content while keeping an organized, scalable project structure.
https://github.com/felangel/locale-manager
Last synced: 6 months ago
JSON representation
Locale-Manager is designed to be the simplest way possible to localize content while keeping an organized, scalable project structure.
- Host: GitHub
- URL: https://github.com/felangel/locale-manager
- Owner: felangel
- Created: 2016-09-10T19:31:16.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-09-11T19:56:28.000Z (about 9 years ago)
- Last Synced: 2024-10-30T04:19:19.084Z (11 months ago)
- Language: JavaScript
- Size: 82 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Locale-Manager - Simplified Localization
[](https://www.npmjs.com/package/locale-manager)
## Super simple to use
Locale-Manager is designed to be the simplest way possible to localize content while keeping an organized, scalable project structure.
```js
var localeManager = require("locale-manager");var locale = "en-US";
console.log(localeManager[locale].hello); // Hellolocale = "es-MX";
console.log(localeManager[locale].hello); // Hola
```## Table of contents
- [Setup](#setup)
- [Examples](#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:
```js
var localeManager = require("locale-manager");var locale = "en-US";
console.log(localeManager[locale].hello); // Hello
console.log(localeManager[locale].greet("Bob"); // Hello Boblocale = "es-MX";
console.log(localeManager[locale].hello); // Hola
console.log(localeManager[locale].greet("Bob"); // Hola Bob
```##### Locales:
###### myNodeProject/locales/english.js
```js
var english = {
// locale
locale: "en-US",
// Hello
hello: "Hello",
greet: function(name) { return "Hello " + name; }
};
module.exports = english;
```###### myNodeProject/locales/spanish.js
```js
var spanish = {
// locale
locale: "es-MX",
// Hello
hello: "Hola",
greet: function(name) { return "Hola " + name; }
};
module.exports = spanish;
```[back to top](#table-of-contents)