Add pad setting for UI lang

pull/1153/head
Marcel Klehr 2012-11-12 16:49:15 +01:00
parent fb340793da
commit 7021a8b885
5 changed files with 24 additions and 3 deletions

View File

@ -34,6 +34,7 @@ pad.settings.linenocheck = Zeilennummern
pad.settings.fontType = Schriftart:
pad.settings.fontType.normal = Normal
pad.settings.fontType.monospaced = Monospace
pad.settings.language = Sprache
pad.settings.globalView = Eigene Ansicht
pad.importExport.import_export = Import/Export

View File

@ -2,19 +2,23 @@ var Globalize = require('globalize')
, fs = require('fs')
, path = require('path')
exports.availableLangs = {}
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')
var culture = Globalize.cultures[locale];
exports.availableLangs[culture.name] = culture.nativeName;
})
})
exports.expressCreateServer = function(n, args) {
args.app.get('/locale.ini', function(req, res) {
Globalize.culture( req.header('Accept-Language') || 'en' );
// let gloablize find out the preferred locale and default to 'en'
Globalize.culture(req.cookies['language'] || 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

@ -447,6 +447,7 @@ var pad = {
{
pad.collabClient.sendClientMessage(msg);
},
createCookie: createCookie,
init: function()
{

View File

@ -75,6 +75,11 @@ var padeditor = (function()
{
pad.changeViewOption('useMonospaceFont', $("#viewfontmenu").val() == 'monospace');
});
$("#languagemenu").val(document.webL10n.getLanguage());
$("#languagemenu").change(function() {
pad.createCookie("language",$("#languagemenu").val(),null,'/');
document.webL10n.setLanguage($("#languagemenu").val());
});
},
setViewOptions: function(newOptions)
{

View File

@ -1,5 +1,6 @@
<%
var settings = require("ep_etherpad-lite/node/utils/Settings");
var settings = require("ep_etherpad-lite/node/utils/Settings")
, langs = require("ep_etherpad-lite/node/hooks/i18n").availableLangs
%>
<!doctype html>
<html>
@ -207,6 +208,15 @@
<option value="monospace" data-l10n-id="pad.settings.fontType.monospaced">Monospaced</option>
</select>
</p>
<p data-l10n-id="pad.settings.language">
Language:
<select id="languagemenu">
<option value="en">English</option>
<% for (lang in langs) { %>
<option value="<%=lang%>"><%=langs[lang]%></option>
<% } %>
</select>
</p>
<% e.end_block(); %>
</div>
<div class="column">