From a84f8e280841057e8bbfa8c3bed92c8ab39cb29f Mon Sep 17 00:00:00 2001 From: Pierre Bondoerffer Date: Tue, 21 Feb 2017 14:23:58 +0100 Subject: [PATCH 1/4] Assert translation now outputs JavaScript which is easier to edit for translators --- www/assert/translations/main.js | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/www/assert/translations/main.js b/www/assert/translations/main.js index 0324e55f2..e711cbf8a 100644 --- a/www/assert/translations/main.js +++ b/www/assert/translations/main.js @@ -10,13 +10,40 @@ define([ return $('
', opt).text(text);
     };
 
+    var addSlashes = function (text) {
+        return (text + '').replace(/[\\']/g, '\\\'');
+    }
+
     var todo = function (missing) {
+        var str = "";;
+        var need = 1;
+
         if (missing.length) {
             $body.append(pre(missing.map(function (msg) {
-                return '* ' + msg;
+                var res = "";
+                var code = msg[0];
+                var key = msg[1];
+                var needed = msg[2];
+
+                if (str !== code) {
+                    if (str !== "")
+                        res += '\n';
+                    str = code;
+                    res += '/*\n *\n * ' + code + '\n *\n */\n\n';
+                }
+                if (need !== needed) {
+                    need = needed;
+                    if (need === 0)
+                        res += '\n// TODO: These keys are not needed anymore and should be removed ('+ code + ')\n\n';
+                }
+
+                res += (need ? '' : '// ') + 'out.' + key + ' = \'\';';
+                if (need)
+                    res += ' // \'' + addSlashes(Cryptpad.Messages._getKey(key, [])) + '\'';
+                return res;
             }).join('\n')));
         } else {
-            $body.text('All keys are present in all translations');
+            $body.text('// All keys are present in all translations');
         }
     };
     Cryptpad.Messages._checkTranslationState(todo);

From ffe17a6bc90e4e37c9c692ac83681375071d366d Mon Sep 17 00:00:00 2001
From: Pierre Bondoerffer 
Date: Tue, 21 Feb 2017 14:37:08 +0100
Subject: [PATCH 2/4] Use JSON.stringify instead and fix linter

---
 www/assert/translations/main.js | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/www/assert/translations/main.js b/www/assert/translations/main.js
index e711cbf8a..9e81a87bf 100644
--- a/www/assert/translations/main.js
+++ b/www/assert/translations/main.js
@@ -10,12 +10,8 @@ define([
         return $('
', opt).text(text);
     };
 
-    var addSlashes = function (text) {
-        return (text + '').replace(/[\\']/g, '\\\'');
-    }
-
     var todo = function (missing) {
-        var str = "";;
+        var str = "";
         var need = 1;
 
         if (missing.length) {
@@ -27,19 +23,25 @@ define([
 
                 if (str !== code) {
                     if (str !== "")
+                    {
                         res += '\n';
+                    }
                     str = code;
                     res += '/*\n *\n * ' + code + '\n *\n */\n\n';
                 }
                 if (need !== needed) {
                     need = needed;
                     if (need === 0)
+                    {
                         res += '\n// TODO: These keys are not needed anymore and should be removed ('+ code + ')\n\n';
+                    }
                 }
 
-                res += (need ? '' : '// ') + 'out.' + key + ' = \'\';';
+                res += (need ? '' : '// ') + 'out.' + key + ' = "";';
                 if (need)
-                    res += ' // \'' + addSlashes(Cryptpad.Messages._getKey(key, [])) + '\'';
+                {
+                    res += ' // ' + JSON.stringify(Cryptpad.Messages._getKey(key, []));
+                }
                 return res;
             }).join('\n')));
         } else {

From 4cbb3b2ed25e1e3e816894f7963e193f6c818eec Mon Sep 17 00:00:00 2001
From: Pierre Bondoerffer 
Date: Tue, 21 Feb 2017 14:53:18 +0100
Subject: [PATCH 3/4] Ensure we use English for reference

---
 www/assert/translations/main.js | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/www/assert/translations/main.js b/www/assert/translations/main.js
index 9e81a87bf..1b1683afe 100644
--- a/www/assert/translations/main.js
+++ b/www/assert/translations/main.js
@@ -1,7 +1,8 @@
 define([
     '/bower_components/jquery/dist/jquery.min.js',
     '/common/cryptpad-common.js',
-], function (jQuery, Cryptpad) {
+    '/customize/translations/messages.js',
+], function (jQuery, Cryptpad, English) {
     var $ = window.jQuery;
 
     var $body = $('body');
@@ -40,7 +41,7 @@ define([
                 res += (need ? '' : '// ') + 'out.' + key + ' = "";';
                 if (need)
                 {
-                    res += ' // ' + JSON.stringify(Cryptpad.Messages._getKey(key, []));
+                    res += ' // ' + JSON.stringify(English[key]);
                 }
                 return res;
             }).join('\n')));

From ed19c6885d354300f4e3e7be552253bfaa4b0c43 Mon Sep 17 00:00:00 2001
From: ansuz 
Date: Tue, 21 Feb 2017 17:16:56 +0100
Subject: [PATCH 4/4] join array in messages.js

---
 customize.dist/translations/messages.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js
index 9ba0402ac..6a339a033 100644
--- a/customize.dist/translations/messages.js
+++ b/customize.dist/translations/messages.js
@@ -234,7 +234,7 @@ define(function () {
             "
  • You can import pads which were recently viewed in your browser so you have them in your account.
  • ", "
  • If you are using a shared computer, you need to log out when you are done, closing the tab is not enough.
  • ", "" - ]; + ].join(''); // Settings out.settings_title = "Settings";