Merge pull request #87 from pbondoer/staging

Assert translation now outputs an easy to edit diff
This commit is contained in:
ansuz 2017-02-21 15:01:03 +01:00 committed by GitHub
commit 22f926d3a5

View File

@ -1,7 +1,8 @@
define([ define([
'/bower_components/jquery/dist/jquery.min.js', '/bower_components/jquery/dist/jquery.min.js',
'/common/cryptpad-common.js', '/common/cryptpad-common.js',
], function (jQuery, Cryptpad) { '/customize/translations/messages.js',
], function (jQuery, Cryptpad, English) {
var $ = window.jQuery; var $ = window.jQuery;
var $body = $('body'); var $body = $('body');
@ -11,12 +12,41 @@ define([
}; };
var todo = function (missing) { var todo = function (missing) {
var str = "";
var need = 1;
if (missing.length) { if (missing.length) {
$body.append(pre(missing.map(function (msg) { $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 += ' // ' + JSON.stringify(English[key]);
}
return res;
}).join('\n'))); }).join('\n')));
} else { } else {
$body.text('All keys are present in all translations'); $body.text('// All keys are present in all translations');
} }
}; };
Cryptpad.Messages._checkTranslationState(todo); Cryptpad.Messages._checkTranslationState(todo);