From d4291fb3ed7bed0f6650f43066d9babf6f880800 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 23 Feb 2021 13:56:06 +0530 Subject: [PATCH] remove outdated translation checks --- customize.dist/messages.js | 70 ------------------------------ www/assert/translations/index.html | 10 ----- www/assert/translations/main.js | 57 ------------------------ 3 files changed, 137 deletions(-) delete mode 100644 www/assert/translations/index.html delete mode 100644 www/assert/translations/main.js diff --git a/customize.dist/messages.js b/customize.dist/messages.js index 303375e4e..b2a264b70 100755 --- a/customize.dist/messages.js +++ b/customize.dist/messages.js @@ -103,76 +103,6 @@ define(req, function(AppConfig, Default, Language) { messages._languages = map; messages._languageUsed = language; - messages._checkTranslationState = function (cb) { - if (typeof(cb) !== "function") { return; } - var allMissing = []; - var reqs = []; - Object.keys(map).forEach(function (code) { - if (code === defaultLanguage) { return; } - reqs.push('/customize/translations/messages.' + code + '.js'); - }); - require(reqs, function () { - var langs = arguments; - Object.keys(map).forEach(function (code, i) { - if (code === defaultLanguage) { return; } - var translation = langs[i]; - var missing = []; - var checkInObject = function (ref, translated, path) { - var updated = {}; - Object.keys(ref).forEach(function (k) { - if (/^updated_[0-9]+_/.test(k) && !translated[k]) { - var key = k.split('_').slice(2).join('_'); - // Make sure we don't already have an update for that key. It should not happen - // but if it does, keep the latest version - if (updated[key]) { - var ek = updated[key]; - if (parseInt(ek.split('_')[1]) > parseInt(k.split('_')[1])) { return; } - } - updated[key] = k; - } - }); - Object.keys(ref).forEach(function (k) { - if (/^_/.test(k) || k === 'driveReadme') { return; } - var nPath = path.slice(); - nPath.push(k); - if (!translated[k] || updated[k]) { - if (updated[k]) { - var uPath = path.slice(); - uPath.unshift('out'); - missing.push([code, nPath, 2, uPath.join('.') + '.' + updated[k]]); - return; - } - return void missing.push([code, nPath, 1]); - } - if (typeof ref[k] !== typeof translated[k]) { - return void missing.push([code, nPath, 3]); - } - if (typeof ref[k] === "object" && !Array.isArray(ref[k])) { - checkInObject(ref[k], translated[k], nPath); - } - }); - Object.keys(translated).forEach(function (k) { - if (/^_/.test(k) || k === 'driveReadme') { return; } - var nPath = path.slice(); - nPath.push(k); - if (typeof ref[k] === "undefined") { - missing.push([code, nPath, 0]); - } - }); - }; - checkInObject(Default, translation, []); - // Push the removals at the end - missing.sort(function (a, b) { - if (a[2] === 0 && b[2] !== 0) { return 1; } - if (a[2] !== 0 && b[2] === 0) { return -1; } - return 0; - }); - Array.prototype.push.apply(allMissing, missing); // Destructive concat - }); - cb(allMissing); - }); - }; - // Get keys with parameters messages._getKey = function (key, argArray) { if (!messages[key]) { return '?'; } diff --git a/www/assert/translations/index.html b/www/assert/translations/index.html deleted file mode 100644 index cd8c31e3a..000000000 --- a/www/assert/translations/index.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/www/assert/translations/main.js b/www/assert/translations/main.js deleted file mode 100644 index b1033f700..000000000 --- a/www/assert/translations/main.js +++ /dev/null @@ -1,57 +0,0 @@ -define([ - 'jquery', - '/common/common-util.js', - '/customize/messages.js', - 'json!/common/translations/messages.json', -], function ($, Util, Messages, English) { - - var $body = $('body'); - - var pre = function (text, opt) { - return $('
', opt).text(text);
-    };
-
-    var todo = function (missing) {
-        var currentLang = "";
-        var currentState = 1;
-
-        if (missing.length) {
-            $body.append(pre(missing.map(function (msg) {
-                var res = "";
-                var lang = msg[0];
-                var key = msg[1]; // Array
-                var state = msg[2]; // 0 === toDelete, 1 === missing, 2 === updated, 3 === invalid (wrong type)
-                var value = msg[3] || '""';
-
-                if (currentLang !== lang) {
-                    if (currentLang !== "")
-                    {
-                        res += '\n';
-                    }
-                    currentLang = lang;
-                    res += '/*\n *\n * ' + lang + '\n *\n */\n\n';
-                }
-                if (currentState !== state) {
-                    currentState = state;
-                    if (currentState === 0)
-                    {
-                        res += '\n// TODO: These keys are not needed anymore and should be removed ('+ lang + ')\n\n';
-                    }
-                }
-
-                res += (currentState ? '' : '// ') + 'out.' + key.join('.') + ' = ' + value + ';';
-                if (currentState === 1) {
-                    res += ' // ' + JSON.stringify(Util.find(English, key));
-                } else if (currentState === 2) {
-                    res += ' // TODO: Key updated --> make sure the updated key "'+ value +'" exists and is translated before this one.';
-                } else if (currentState === 3) {
-                    res += ' // NOTE: this key has an invalid type! Original value: ' + JSON.stringify(Util.find(English, key));
-                }
-                return res;
-            }).join('\n')));
-        } else {
-            $body.text('// All keys are present in all translations');
-        }
-    };
-    Messages._checkTranslationState(todo);
-});