https://github.com/stewartpark/node-i18n
Simple i18n module
https://github.com/stewartpark/node-i18n
Last synced: 3 months ago
JSON representation
Simple i18n module
- Host: GitHub
- URL: https://github.com/stewartpark/node-i18n
- Owner: stewartpark
- Created: 2012-01-29T17:29:47.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2012-04-10T18:38:56.000Z (about 13 years ago)
- Last Synced: 2025-02-02T23:05:31.812Z (5 months ago)
- Language: JavaScript
- Homepage:
- Size: 97.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
i18n module for node.JS
=======================i18n is a simple international support library written in Node.js.
Let me give you an example for fast deployment.
Assume that the hierarchy of directories is following below.node_modules/
node-i18n/
locales/
en/
index.js
ko/
index.js
ja/
index.js
app.jsand the source code of each file is as follows:
locales/ko/index.js:
```javascript
module.exports = {
'Hello, $name.': '$name님, 안녕하세요!'
}
```locales/ja/index.js:
```javascript
module.exports = {
'Hello, $name.': 'こんにちは!$nameさん!'
}
```app.js:
```javascript
var i = require('node-i18n');
var obj = {
name: 'Smith'
};i.setLocale('en');
console.log( i.string('Hello, $name.', obj) );i.setLocale('ko');
console.log( i.string('Hello, $name.', obj) );i.setLocale('ja');
console.log( i.string('Hello, $name.', obj) );
```And go to your terminal.
$ node app.js
Hello, Smith.
Smith님, 안녕하세요!
こんにちは!Smithさん!