Add i18n component
This commit is contained in:
parent
dc3db7a4a8
commit
a3504f70c4
|
@ -5,6 +5,7 @@
|
||||||
"restartServer": "ep_etherpad-lite/node/hooks/express:restartServer"
|
"restartServer": "ep_etherpad-lite/node/hooks/express:restartServer"
|
||||||
} },
|
} },
|
||||||
{ "name": "static", "hooks": { "expressCreateServer": "ep_etherpad-lite/node/hooks/express/static:expressCreateServer" } },
|
{ "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": "specialpages", "hooks": { "expressCreateServer": "ep_etherpad-lite/node/hooks/express/specialpages:expressCreateServer" } },
|
||||||
{ "name": "padurlsanitize", "hooks": { "expressCreateServer": "ep_etherpad-lite/node/hooks/express/padurlsanitize: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" } },
|
{ "name": "padreadonly", "hooks": { "expressCreateServer": "ep_etherpad-lite/node/hooks/express/padreadonly:expressCreateServer" } },
|
||||||
|
|
|
@ -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)
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
|
@ -35,7 +35,8 @@
|
||||||
"security" : "1.0.0",
|
"security" : "1.0.0",
|
||||||
"tinycon" : "0.0.1",
|
"tinycon" : "0.0.1",
|
||||||
"underscore" : "1.3.1",
|
"underscore" : "1.3.1",
|
||||||
"unorm" : "1.0.0"
|
"unorm" : "1.0.0",
|
||||||
|
"globalize" : "0.1.1"
|
||||||
},
|
},
|
||||||
"bin": { "etherpad-lite": "./node/server.js" },
|
"bin": { "etherpad-lite": "./node/server.js" },
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue