diff options
author | Marcel Klehr <mklehr@gmx.net> | 2012-11-10 14:12:17 +0100 |
---|---|---|
committer | Marcel Klehr <mklehr@gmx.net> | 2012-11-10 14:12:17 +0100 |
commit | a3504f70c4e78677644785706270d070a475350e (patch) | |
tree | 209c53b799f283167861748b1557dd1697d85cf3 /src/node/hooks | |
parent | dc3db7a4a8953167561f5aa39a23830a620da5c9 (diff) | |
download | etherpad-lite-a3504f70c4e78677644785706270d070a475350e.zip |
Add i18n component
Diffstat (limited to 'src/node/hooks')
-rw-r--r-- | src/node/hooks/i18n.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/node/hooks/i18n.js b/src/node/hooks/i18n.js new file mode 100644 index 00000000..ab0a887b --- /dev/null +++ b/src/node/hooks/i18n.js @@ -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) + }); + }) + +}
\ No newline at end of file |