From a84f8e280841057e8bbfa8c3bed92c8ab39cb29f Mon Sep 17 00:00:00 2001 From: Pierre Bondoerffer Date: Tue, 21 Feb 2017 14:23:58 +0100 Subject: [PATCH] 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);