Add i18n component

This commit is contained in:
Marcel Klehr 2012-11-10 14:12:17 +01:00
parent dc3db7a4a8
commit a3504f70c4
4 changed files with 1051 additions and 1 deletions

View File

@ -5,6 +5,7 @@
"restartServer": "ep_etherpad-lite/node/hooks/express:restartServer"
} },
{ "name": "static", "hooks": { "expressCreateServer": "ep_etherpad-lite/node/hooks/express/static:expressCreateServer" } },
{ "name": "i18n", "hooks": { "expressCreateServer": "ep_etherpad-lite/node/hooks/i18n:expressCreateServer" } },
{ "name": "specialpages", "hooks": { "expressCreateServer": "ep_etherpad-lite/node/hooks/express/specialpages:expressCreateServer" } },
{ "name": "padurlsanitize", "hooks": { "expressCreateServer": "ep_etherpad-lite/node/hooks/express/padurlsanitize:expressCreateServer" } },
{ "name": "padreadonly", "hooks": { "expressCreateServer": "ep_etherpad-lite/node/hooks/express/padreadonly:expressCreateServer" } },

24
src/node/hooks/i18n.js Normal file
View File

@ -0,0 +1,24 @@
var Globalize = require('globalize')
, fs = require('fs')
, path = require('path')
fs.readdir(__dirname+"/../../locales", function(er, files) {
files.forEach(function(locale) {
locale = locale.split('.')[0]
if(locale.toLowerCase() == 'en') return;
require('globalize/lib/cultures/globalize.culture.'+locale+'.js')
})
})
exports.expressCreateServer = function(n, args) {
args.app.get('/locale.ini', function(req, res) {
Globalize.culture( req.header('Accept-Language') || 'en' );
var localePath = path.normalize(__dirname +"/../../locales/"+Globalize.culture().name+".ini");
res.sendfile(localePath, function(er) {
if(er) console.error(er)
});
})
}

View File

@ -35,7 +35,8 @@
"security" : "1.0.0",
"tinycon" : "0.0.1",
"underscore" : "1.3.1",
"unorm" : "1.0.0"
"unorm" : "1.0.0",
"globalize" : "0.1.1"
},
"bin": { "etherpad-lite": "./node/server.js" },
"devDependencies": {

1024
src/static/js/l10n.js Normal file

File diff suppressed because it is too large Load Diff