remove outdated translation checks

This commit is contained in:
ansuz 2021-02-23 13:56:06 +05:30
parent 1785f79f7f
commit d4291fb3ed
3 changed files with 0 additions and 137 deletions

View file

@ -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 '?'; }

View file

@ -1,10 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<script data-bootload="main.js" data-main="/common/boot.js" src="/bower_components/requirejs/require.js"></script>
</head>
<body>

View file

@ -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 $('<pre>', 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);
});