diff --git a/node/utils/Minify.js b/node/utils/Minify.js index dbb409666..c09a63495 100644 --- a/node/utils/Minify.js +++ b/node/utils/Minify.js @@ -31,7 +31,7 @@ var gzip = require('gzip'); var server = require('../server'); var os = require('os'); -var padJS = ["jquery.min.js", "pad_utils.js", "plugins.js", "undo-xpopup.js", "json2.js", "pad_cookie.js", "pad_editor.js", "pad_editbar.js", "pad_docbar.js", "pad_modals.js", "ace.js", "collab_client.js", "pad_userlist.js", "pad_impexp.js", "pad_savedrevs.js", "pad_connectionstatus.js", "pad2.js", "jquery-ui.js", "chat.js", "excanvas.js", "farbtastic.js"]; +var padJS = ["jquery.min.js", "translate.js", "LANGUAGE", "pad_utils.js", "plugins.js", "undo-xpopup.js", "json2.js", "pad_cookie.js", "pad_editor.js", "pad_editbar.js", "pad_docbar.js", "pad_modals.js", "ace.js", "collab_client.js", "pad_userlist.js", "pad_impexp.js", "pad_savedrevs.js", "pad_connectionstatus.js", "pad2.js", "jquery-ui.js", "chat.js", "excanvas.js", "farbtastic.js"]; var timesliderJS = ["jquery.min.js", "plugins.js", "undo-xpopup.js", "json2.js", "colorutils.js", "draggable.js", "pad_utils.js", "pad_cookie.js", "pad_editor.js", "pad_editbar.js", "pad_docbar.js", "pad_modals.js", "easysync2_client.js", "domline_client.js", "linestylefilter_client.js", "cssmanager_client.js", "broadcast.js", "broadcast_slider.js", "broadcast_revisions.js"]; @@ -129,8 +129,31 @@ exports.minifyJS = function(req, res, jsFilename) { async.forEach(jsFiles, function (item, callback) { - fs.readFile("../static/js/" + item, "utf-8", function(err, data) - { + var fileName = "../static/js/" + item; + + //if this is the language file, take the correct one + if(item == "LANGUAGE") + { + //skip if this is english, we don't need a language file for that + if(settings.language == "en") + { + fileValues[item] = ""; + callback(); + return; + } + + //replace it with the translation file + fileName = "../translation/" + settings.language + "/pad.json"; + } + + fs.readFile(fileName, "utf-8", function(err, data) + { + //add this prefix for language files + if(item == "LANGUAGE") + { + data = "var language = '" + settings.language + "'; var translation = {};\ntranslation['" + settings.language + "'] = " + data; + } + fileValues[item] = data; callback(err); }); @@ -269,8 +292,31 @@ exports.minifyJS = function(req, res, jsFilename) //read all js files async.forEach(jsFiles, function (item, callback) { - fs.readFile("../static/js/" + item, "utf-8", function(err, data) + var fileName = "../static/js/" + item; + + //if this is the language file, take the correct one + if(item == "LANGUAGE") + { + //skip if this is english, we don't need a language file for that + if(settings.language == "en") + { + fileValues[item] = ""; + callback(); + return; + } + + //replace it with the translation file + fileName = "../translation/" + settings.language + "/pad.json"; + } + + fs.readFile(fileName, "utf-8", function(err, data) { + //add this prefix for language files + if(item == "LANGUAGE") + { + data = "var language = '" + settings.language + "'; var translation = {};\ntranslation['" + settings.language + "'] = " + data; + } + fileValues[item] = data; callback(err); }); diff --git a/node/utils/Settings.js b/node/utils/Settings.js index 1d855a53d..4c069531c 100644 --- a/node/utils/Settings.js +++ b/node/utils/Settings.js @@ -57,6 +57,11 @@ exports.abiword = null; */ exports.loglevel = "INFO"; +/** + * The language of the user interface + */ +exports.language = "en"; + //read the settings sync var settingsStr = fs.readFileSync("../settings.json").toString(); diff --git a/settings.json.template b/settings.json.template index a7afaecc9..0e4ae6309 100644 --- a/settings.json.template +++ b/settings.json.template @@ -37,5 +37,8 @@ "abiword" : null, /* The log level we are using, can be: DEBUG, INFO, WARN, ERROR */ - "loglevel": "INFO" + "loglevel": "INFO", + + /* The language of the user interface */ + "language": "en" } diff --git a/settings.json.template_windows b/settings.json.template_windows index 235ec71a3..53d016ea7 100644 --- a/settings.json.template_windows +++ b/settings.json.template_windows @@ -34,5 +34,11 @@ /* This is the path to the Abiword executable. Setting it to null, disables abiword. Abiword is needed to enable the import/export of pads*/ - "abiword" : null + "abiword" : null, + + /* The log level we are using, can be: DEBUG, INFO, WARN, ERROR */ + "loglevel": "INFO", + + /* The language of the user interface */ + "language": "en" } diff --git a/static/js/pad_userlist.js b/static/js/pad_userlist.js index 68f33419f..d27e9fbc2 100644 --- a/static/js/pad_userlist.js +++ b/static/js/pad_userlist.js @@ -699,7 +699,7 @@ var paduserlist = (function() } else { - $("#myusernameedit").addClass("editempty").val("Enter your name"); + $("#myusernameedit").addClass("editempty").val(translate("Enter your name")); } if (colorPickerOpen) { diff --git a/static/js/translate.js b/static/js/translate.js new file mode 100644 index 000000000..c4f0ea29c --- /dev/null +++ b/static/js/translate.js @@ -0,0 +1,47 @@ +//trys to find a translation for the string and returns the translation or the original string +function translate(str) +{ + var translated = str; + + //return translation if avaiable + if(language != null && translation != null && translation[language][str] != null) + { + translated = translation[language][str]; + } + else if(window.console) + { + window.console.log("No " + language + " translation for '" + str + "'"); + } + + return translated; +} + +function DOMTranslate(selector, attribute) +{ + //skip translation if its english + if(language === "en") + return; + + //loop trough all elements + $(selector).each(function(index, element) + { + //make a jquery object + element = $(element); + + //thats a attribute translation + if(attribute != null) + { + element.attr(attribute, translate(element.attr(attribute))); + } + //thats a text translation + else + { + element.text(translate(element.text())); + } + }); +} + +$(document).ready(function() +{ + DOMTranslate(".translate"); +}); diff --git a/static/pad.html b/static/pad.html index 980905e99..156a993c9 100644 --- a/static/pad.html +++ b/static/pad.html @@ -109,6 +109,8 @@ + +
@@ -120,15 +122,11 @@
- - Save + Save - Cancel + Cancel
@@ -181,13 +179,13 @@
- Import from text file, HTML, PDF, Word, ODT or RTF:

+ Import from text file, HTML, PDF, Word, ODT or RTF:

-
Successful!
+
Successful!
@@ -202,13 +200,13 @@
- Export current pad as: -
HTML
-
Plain text
-
Microsoft Word
-
PDF
-
OpenDocument
-
Wordle
+ Export current pad as: +
HTML
+
Plain text
+
Microsoft Word
+
PDF
+
OpenDocument
+
Wordle
@@ -218,14 +216,14 @@
-Embed code: +Embed code:
-Use this link to share a read-only version of your pad: +Use this link to share a read-only version of your pad:
@@ -237,14 +235,14 @@ Use this link to share a read-only version of your pad: - Chat + Chat
0
-
Chat
+
Chat
@@ -266,10 +264,10 @@ Use this link to share a read-only version of your pad:
- Connecting... + Connecting...
- Reestablishing connection... + Reestablishing connection...

Disconnected.

@@ -277,49 +275,49 @@ Use this link to share a read-only version of your pad:No Authorization.

- We're having trouble talking to the EtherPad lite synchronization server. - You may be connecting through an incompatible firewall or proxy server. + We're having trouble talking to the EtherPad lite synchronization server. + You may be connecting through an incompatible firewall or proxy server.

- We were unable to connect to the EtherPad lite synchronization server. - This may be due to an incompatibility with your web browser or internet connection. + We were unable to connect to the EtherPad lite synchronization server. + This may be due to an incompatibility with your web browser or internet connection.

- You seem to have opened this pad in another browser window. - If you'd like to use this window instead, you can reconnect. + You seem to have opened this pad in another browser window. + If you'd like to use this window instead, you can reconnect.

- Lost connection with the EtherPad lite synchronization server. This may be due to a loss of network connectivity. + Lost connection with the EtherPad lite synchronization server. This may be due to a loss of network connectivity.

- Server not responding. This may be due to network connectivity issues or high load on the server. + Server not responding. This may be due to network connectivity issues or high load on the server.

- Your browser's credentials or permissions have changed while viewing this pad. Try reconnecting. + Your browser's credentials or permissions have changed while viewing this pad. Try reconnecting.

- This pad was deleted. + This pad was deleted.

- If this continues to happen, please let us know + If this continues to happen, please let us know

- +
diff --git a/translation/de/pad.json b/translation/de/pad.json new file mode 100644 index 000000000..be0940648 --- /dev/null +++ b/translation/de/pad.json @@ -0,0 +1,47 @@ +{ +"Bold (ctrl-B)":"Fett (Strg+B)", +"Italics (ctrl-I)":"Kursiv (Strg+I)", +"Underline (ctrl-U)":"Unterstrichen (Strg+U)", +"Strikethrough":"Durchgestrichen", +"Toggle Bullet List":"Liste", +"Indent List":"Liste einrücken", +"Unindent List":"Liste ausrücken", +"Undo (ctrl-Z)":"Rückgängig", +"Redo (ctrl-Y)":"Widerholen", +"Clear Authorship Colors":"Autorenfarben entfernen", +"Create a readonly link for this pad":"Erzeuge einen Nur-Lese Link", +"Import/Export from/to different document formats":"Importiere/Exportiere von und zu verschiedenen Dokumentformaten", +"Embed this pad":"Binde dieses Pad in deine Webseite ein", +"Show the history of this pad":"Zeige den Verlauf des Pads", +"Show connected users":"Zeige verbundene Benutzer", +"Cancel":"Abrechen", +"Save":"Speichern", +"Import from text file, HTML, PDF, Word, ODT or RTF:":"Importiere von Text, HTML, PDF, Word, ODT oder RTF:", +"Successful!":"Erfolgreich!", +"Export current pad as:":"Exportiere dieses Pad als", +"HTML":"HTML", +"Plain text":"Reiner Text", +"Microsoft Word":"Microsoft Word", +"PDF":"PDF", +"OpenDocument":"OpenDocument", +"Wordle":"Wordle", +"Embed code:":"Einbett code", +"Use this link to share a read-only version of your pad:":"Nutze diesen Link um mit deinen Freunden eine Nur-Lese zu teilen", +"Chat":"Chat", +"Connecting...":"Verbinde...", +"Reestablishing connection...":"Baue verbindung neu auf...", +"We're having trouble talking to the EtherPad lite synchronization server.":"Wir haben Probleme uns zu verbinden", +"You may be connecting through an incompatible firewall or proxy server.":"", +"We were unable to connect to the EtherPad lite synchronization server.":"", +"This may be due to an incompatibility with your web browser or internet connection.":"", +"You seem to have opened this pad in another browser window.":"", +"If you'd like to use this window instead, you can reconnect.":"", +"Lost connection with the EtherPad lite synchronization server.":"", +"Server not responding.":"", +"This may be due to network connectivity issues or high load on the server.":"", +"Your browser's credentials or permissions have changed while viewing this pad. Try reconnecting.":"", +"This pad was deleted.":"Dieses Pad wurde gelöscht", +"If this continues to happen, please let us know":"Sollte dies wiederholt passieren, informieren sie uns bitte darüber", +"Reconnect Now":"Jetzt neu verbinden", +"Enter your name":"Namen eingeben" +}