ez-localize

Super-simple localization of strings in a Node/Browserify application

ez-localize

Localizing an application should be easy, not hard. ez-localize makes it ridiculously simple.

Just replace:

console.log("Hello world!");

With:

console.log(T("Hello world!"));
var extractor = require('ez-localize/extractor');
 
extractor.updateLocalizationFile("index.js", "localizations.json", {}, function() { console.log("done!")})
var ezlocalize = require('ez-localize');
var localizations = require('localizations.json');
 
var localizer = new ezlocalize.Localizer(localizations, "en")
localizer.makeGlobal();
 

You're done!

String substitution:

console.log(T("This works {0}%!", 100);

It handles Coffeescript and Handlebars too:

var options = { extensions: ['.js', '.coffee'], transform: [coffeeify, hbsfy] };
extractor.updateLocalizationsupdateLocalizationFile("index.js", "localizations.json", options, function() { console.log("done!")})

To register a T helper:

var ezlocalize = require('ez-localize');
var handlebars = require("hbsfy/runtime");
var localizations = require('localizations.json');
 
var localizer = new ezlocalize.Localizer(localizations, "en")
localizer.makeGlobal(handlebars);

Only relative requires are included by default. To include another module, pass externalModules to options, an optional list of external modules to include