Skip to content

Swatinem/localization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple localization middleware

Setting it up:

var l = require('localization')(__dirname.'/lang');

Use it directly:

var t = l.init('de');
assert.equal(t._('Cauliflower'), 'Blumenkohl');
assert.equal(t.language, 'Deutsch');

Use it as a connect middleware:

var app = connect();
app.use(l.middleware())
app.use(function (req, res, next) {
	res.writeHead(200, { 'Content-Type': 'text/plain' });
	var _ = req.localization._;
	var language = req.localization.language;
	res.write(_('Cauliflower') + "\n");
	res.end(language);
});

Language files use a simple json structure:

{"language": "Österreichisch", "inherit": "de", "strings": {
	"Cauliflower": "Karfiol"
}}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors