
Research
/Security News
Popular Go Decimal Library Targeted by Long-Running Typosquat with DNS Backdoor
A long-running Go typosquat impersonated the popular shopspring/decimal library and used DNS TXT records to execute commands.
Translation module with dynamic json storage in Redis and suport npm: express, z-form...
Download and install test project at (New version 1.0.2): https://github.com/kimthangatm/test-node-js-z-i18n/
New tutorial Node Js Mutiple language & more .. at : https://kimtatthang.wordpress.com/2015/03/11/multiple-languages-i18n-l10n-in-your-node-js-express-and-redis/
Translation module with dynamic json storage in Redis and suport npm: express, z-form...
When APP Node JS firt run, translation loaded loaded from file or Redis and never reload => Fast
My computer is MacOS 10.10.2 and currently Redis version is 2.8.19, you can use guide bellow or visit: http://redis.io/download to download and install redis server
//Mac OS install
$ wget http://download.redis.io/releases/redis-2.8.19.tar.gz
$ tar xzf redis-2.8.19.tar.gz
$ cd redis-2.8.19
$ make
$ sudo make install
// Restart redis in background Mac OS
$ redis-server > /dev/null &
Note: When Node Js application running, translation save on Redis, if you want reload cache please follow:
Typing into terminal
$ redis-cli
//Result: 127.0.0.1:6379>
$ FLUSHALL
Open terminal and typing
// # If you don't have express generator:
// # sudo npm install express-generator -g
cd ~
express test-i18n && cd test-i18n
sudo npm install
sudo npm install redis z-i18n
sudo npm update
test-i18n/
└── languages
├── en_GB
│ └── moduleA.en_GB.json
└── nl_NL
└── moduleA.nl_NL.json
//Code moduleA.en_GB.json
{
"m_user_name_label" : "User name",
"m_user_name" : "Enter your user name!",
"hello_user_name" : "Hello, %s %s year old"
}
//Code moduleA.nl_NL.json
{
"m_user_name_label" : "Gebruikersnaam",
"m_user_name" : "Voer uw gebruikersnaam!",
"hello_user_name" : "Hallo, %s %s jaar oud"
}
Open test-i18n/app.js and copy/pate bellow code after: var app = express();
var app = express();
// Require redis
var redis = require('redis').createClient();
// Require z-i18n
var i18n = require('z-i18n');
var languages = [
'en_GB',
'nl_NL',
'vi_VN'
];
// Set current
i18n.init({current_lang: 'en_GB', default_lang : 'en_GB'});
// Or set current_lang/default_lang
// i18n.init({current_lang : 'en_GB', default_lang : 'en_GB'});
// Translations into the dutch language.
// i18n.init({current_lang : 'nl_NL', default_lang : 'en_GB'});
var languageRedisCache = 'LANGUAGE_CACHE_REDIS';
redis.get(languageRedisCache, function (error, result) {
if (result == null) {
i18n.add('languages/nl_NL/moduleA.nl_NL.json', 'nl_NL');
i18n.add('languages/en_GB/moduleA.en_GB.json', 'en_GB');
global.i18n = i18n;
global._t = i18n.__;
//global._ = i18n.__;
redis.set(languageRedisCache, JSON.stringify(i18n.getTranslation()), redis.print);
} else {
i18n.setTranslation(result);
global.i18n = i18n;
global._t = i18n.__;
//global._ = i18n.__;
}
});
//Use middleware to set current language
app.use(function (req, res, next) {
if (req.query.lang != undefined && languages.indexOf(req.query.lang) >= 0) {
i18n.setCurrentLang(req.query.lang);
}else{
i18n.setCurrentLang(i18n.getDefaultLang());
}
next();
});
var express = require('express');
var router = express.Router();
/* GET home page. */
router.get('/', function (req, res, next) {
var hello = _t('hello_user_name', 'ZaiChi', 25);
res.render('index', {title: 'Express', hello : hello});
});
module.exports = router;
extends layout
block content
h1= title
p Welcome to #{title}
p "var hello = _t('hello_user_name', 'ZaiChi', 25);"
p "============================"
p Result: #{hello}
Open terminal and typing
//cd "path_project"
cd ~/test-i18n/
node bin/www
// If you have grunt
grunt
// If you have nodemon
nodemon
Address: 127.0.0.1:3000 . App use default “en_GB”
Address: 127.0.0.1:3000?lang=nl_NL . App switch language “nl_NL”
Address: 127.0.0.1:3000?lang=vi_VN . Because “vi_VN” lang don’t have tranlation key “hello_user_name”, system get default “hello_user_name” in default_language = “en_GB”
FAQs
Translation module with dynamic json storage in Redis and suport npm: express, z-form...
The npm package z-i18n receives a total of 15 weekly downloads. As such, z-i18n popularity was classified as not popular.
We found that z-i18n demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Research
/Security News
A long-running Go typosquat impersonated the popular shopspring/decimal library and used DNS TXT records to execute commands.

Research
Active npm supply chain attack compromises @antv packages in a fast-moving malicious publish wave tied to Mini Shai-Hulud.

Security News
/Research
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.