summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcel Klehr <mklehr@gmx.net>2012-11-12 16:49:15 +0100
committerMarcel Klehr <mklehr@gmx.net>2012-11-12 16:49:15 +0100
commit7021a8b8859958a12c6f7d1747d59816b29af169 (patch)
tree55fd1226d4b83f9ff62ce609dbfdcff145f2dcb5 /src
parentfb340793da2a9f5d58ef868b7750ca1841a29bf3 (diff)
downloadetherpad-lite-7021a8b8859958a12c6f7d1747d59816b29af169.zip
Add pad setting for UI lang
Diffstat (limited to 'src')
-rw-r--r--src/locales/de.ini1
-rw-r--r--src/node/hooks/i18n.js8
-rw-r--r--src/static/js/pad.js1
-rw-r--r--src/static/js/pad_editor.js5
-rw-r--r--src/templates/pad.html12
5 files changed, 24 insertions, 3 deletions
diff --git a/src/locales/de.ini b/src/locales/de.ini
index d73c926d..ae79323a 100644
--- a/src/locales/de.ini
+++ b/src/locales/de.ini
@@ -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
diff --git a/src/node/hooks/i18n.js b/src/node/hooks/i18n.js
index ab0a887b..a2faa458 100644
--- a/src/node/hooks/i18n.js
+++ b/src/node/hooks/i18n.js
@@ -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)
diff --git a/src/static/js/pad.js b/src/static/js/pad.js
index c55f8dfe..a07b29b5 100644
--- a/src/static/js/pad.js
+++ b/src/static/js/pad.js
@@ -447,6 +447,7 @@ var pad = {
{
pad.collabClient.sendClientMessage(msg);
},
+ createCookie: createCookie,
init: function()
{
diff --git a/src/static/js/pad_editor.js b/src/static/js/pad_editor.js
index 5a9e7b9b..690dde37 100644
--- a/src/static/js/pad_editor.js
+++ b/src/static/js/pad_editor.js
@@ -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)
{
diff --git a/src/templates/pad.html b/src/templates/pad.html
index a57d5d32..0cd27835 100644
--- a/src/templates/pad.html
+++ b/src/templates/pad.html
@@ -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">