mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 16:06:16 -04:00

* l10n.js is doing locale detection already, so we shouldn't interfere but help it do its job * this should also fix the ?lang embed parameter * Set language from cookie on page init for l10n to load the right translation
33 lines
No EOL
927 B
JavaScript
33 lines
No EOL
927 B
JavaScript
var Globalize = require('globalize')
|
|
, fs = require('fs')
|
|
, path = require('path')
|
|
, express = require('express')
|
|
|
|
var localesPath = __dirname+"/../../locales";
|
|
|
|
var localeIndex = '[*]\r\n@import url(locales/en.ini)\r\n';
|
|
exports.availableLangs = {en: 'English'};
|
|
|
|
fs.readdir(localesPath, function(er, files) {
|
|
files.forEach(function(locale) {
|
|
locale = locale.split('.')[0]
|
|
if(locale.toLowerCase() == 'en') return;
|
|
|
|
// build locale index
|
|
localeIndex += '['+locale+']\r\n@import url(locales/'+locale+'.ini)\r\n'
|
|
|
|
require('globalize/lib/cultures/globalize.culture.'+locale+'.js')
|
|
var culture = Globalize.cultures[locale];
|
|
exports.availableLangs[culture.name] = culture.nativeName;
|
|
})
|
|
})
|
|
|
|
exports.expressCreateServer = function(n, args) {
|
|
|
|
args.app.use('/locales', express.static(localesPath));
|
|
|
|
args.app.get('/locales.ini', function(req, res) {
|
|
res.send(localeIndex);
|
|
})
|
|
|
|
} |