Merge pull request #1223 from joker-x/languages4translatewiki

Added support for *all* translatewiki languages
This commit is contained in:
Marcel Klehr 2012-12-04 04:09:17 -08:00
commit ce71002644
2 changed files with 33 additions and 32 deletions

View File

@ -1,4 +1,4 @@
var languages = require('languages') var languages = require('languages4translatewiki')
, fs = require('fs') , fs = require('fs')
, path = require('path') , path = require('path')
, express = require('express') , express = require('express')
@ -8,22 +8,23 @@ var localesPath = __dirname+"/../../locales";
// Serve English strings directly with /locales.ini // Serve English strings directly with /locales.ini
var localeIndex = fs.readFileSync(localesPath+'/en.ini')+'\r\n'; var localeIndex = fs.readFileSync(localesPath+'/en.ini')+'\r\n';
// add language base 'en' to availableLangs exports.availableLangs = {'en': {'nativeName': 'English', 'direction': 'ltr'}};
exports.availableLangs = {en: languages.getLanguageInfo('en')}
fs.readdir(localesPath, function(er, files) { fs.readdir(localesPath, function(er, files) {
files.forEach(function(locale) { files.forEach(function(locale) {
locale = locale.split('.')[0] var ext = path.extname(locale);
if(locale.toLowerCase() == 'en') return; locale = path.basename(locale, ext).toLowerCase();
if(locale == 'en' || ext != '.ini') return;
// build locale index // build locale index
localeIndex += '['+locale+']\r\n@import url(locales/'+locale+'.ini)\r\n' localeIndex += '['+locale+']\r\n@import url(locales/'+locale+'.ini)\r\n'
// add info language {name, nativeName, direction} to availableLangs // add info language {nativeName, direction} to availableLangs
exports.availableLangs[locale]=languages.getLanguageInfo(locale); exports.availableLangs[locale]=languages.getLanguageInfo(locale);
}) })
}) })
exports.expressCreateServer = function(n, args) { exports.expressCreateServer = function(n, args) {
args.app.use('/locales', express.static(localesPath)); args.app.use('/locales', express.static(localesPath));

View File

@ -36,7 +36,7 @@
"tinycon" : "0.0.1", "tinycon" : "0.0.1",
"underscore" : "1.3.1", "underscore" : "1.3.1",
"unorm" : "1.0.0", "unorm" : "1.0.0",
"languages" : "0.1.1" "languages4translatewiki" : "0.1.3"
}, },
"bin": { "etherpad-lite": "./node/server.js" }, "bin": { "etherpad-lite": "./node/server.js" },
"devDependencies": { "devDependencies": {