mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-20 06:29:53 +01:00
Add pad setting for UI lang
This commit is contained in:
parent
fb340793da
commit
7021a8b885
5 changed files with 24 additions and 3 deletions
|
@ -34,6 +34,7 @@ pad.settings.linenocheck = Zeilennummern
|
||||||
pad.settings.fontType = Schriftart:
|
pad.settings.fontType = Schriftart:
|
||||||
pad.settings.fontType.normal = Normal
|
pad.settings.fontType.normal = Normal
|
||||||
pad.settings.fontType.monospaced = Monospace
|
pad.settings.fontType.monospaced = Monospace
|
||||||
|
pad.settings.language = Sprache
|
||||||
pad.settings.globalView = Eigene Ansicht
|
pad.settings.globalView = Eigene Ansicht
|
||||||
|
|
||||||
pad.importExport.import_export = Import/Export
|
pad.importExport.import_export = Import/Export
|
||||||
|
|
|
@ -2,19 +2,23 @@ var Globalize = require('globalize')
|
||||||
, fs = require('fs')
|
, fs = require('fs')
|
||||||
, path = require('path')
|
, path = require('path')
|
||||||
|
|
||||||
|
exports.availableLangs = {}
|
||||||
fs.readdir(__dirname+"/../../locales", function(er, files) {
|
fs.readdir(__dirname+"/../../locales", function(er, files) {
|
||||||
files.forEach(function(locale) {
|
files.forEach(function(locale) {
|
||||||
locale = locale.split('.')[0]
|
locale = locale.split('.')[0]
|
||||||
if(locale.toLowerCase() == 'en') return;
|
if(locale.toLowerCase() == 'en') return;
|
||||||
|
|
||||||
require('globalize/lib/cultures/globalize.culture.'+locale+'.js')
|
require('globalize/lib/cultures/globalize.culture.'+locale+'.js')
|
||||||
|
var culture = Globalize.cultures[locale];
|
||||||
|
exports.availableLangs[culture.name] = culture.nativeName;
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
exports.expressCreateServer = function(n, args) {
|
exports.expressCreateServer = function(n, args) {
|
||||||
|
|
||||||
args.app.get('/locale.ini', function(req, res) {
|
args.app.get('/locale.ini', function(req, res) {
|
||||||
|
// let gloablize find out the preferred locale and default to 'en'
|
||||||
Globalize.culture( req.header('Accept-Language') || 'en' );
|
Globalize.culture(req.cookies['language'] || req.header('Accept-Language') || 'en');
|
||||||
var localePath = path.normalize(__dirname +"/../../locales/"+Globalize.culture().name+".ini");
|
var localePath = path.normalize(__dirname +"/../../locales/"+Globalize.culture().name+".ini");
|
||||||
res.sendfile(localePath, function(er) {
|
res.sendfile(localePath, function(er) {
|
||||||
if(er) console.error(er)
|
if(er) console.error(er)
|
||||||
|
|
|
@ -447,6 +447,7 @@ var pad = {
|
||||||
{
|
{
|
||||||
pad.collabClient.sendClientMessage(msg);
|
pad.collabClient.sendClientMessage(msg);
|
||||||
},
|
},
|
||||||
|
createCookie: createCookie,
|
||||||
|
|
||||||
init: function()
|
init: function()
|
||||||
{
|
{
|
||||||
|
|
|
@ -75,6 +75,11 @@ var padeditor = (function()
|
||||||
{
|
{
|
||||||
pad.changeViewOption('useMonospaceFont', $("#viewfontmenu").val() == 'monospace');
|
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)
|
setViewOptions: function(newOptions)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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>
|
<!doctype html>
|
||||||
<html>
|
<html>
|
||||||
|
@ -207,6 +208,15 @@
|
||||||
<option value="monospace" data-l10n-id="pad.settings.fontType.monospaced">Monospaced</option>
|
<option value="monospace" data-l10n-id="pad.settings.fontType.monospaced">Monospaced</option>
|
||||||
</select>
|
</select>
|
||||||
</p>
|
</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(); %>
|
<% e.end_block(); %>
|
||||||
</div>
|
</div>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
|
|
Loading…
Reference in a new issue