You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cryptpad/scripts/find-html-translations.js

100 lines
1.9 KiB
JavaScript

var EN = require("../www/common/translations/messages.json");
var simpleTags = [
'<br>',
'<a href="/login/">',
'<a href="/register/">',
4 years ago
// FIXME
"<a href='#'>",
'<a href="#docs">',
'<h3>',
'</h3>',
4 years ago
// FIXME register_notes
'<ul class="cp-notes-list">',
'</ul>',
'<li>',
'</li>',
'<span class="red">',
'</span>',
];
['a', 'b', 'em', 'p', 'i'].forEach(function (tag) {
simpleTags.push('<' + tag + '>');
simpleTags.push('</' + tag + '>');
});
4 years ago
// these keys are known to be problematic
var KNOWN_ISSUES = [ // FIXME
//'newVersion',
4 years ago
//'fm_info_anonymous',
//'register_notes',
];
var processLang = function (map, lang, primary) {
var announced = false;
var announce = function () {
if (announced) { return; }
announced = true;
console.log("NEXT LANGUAGE: ", lang);
};
Object.keys(map).forEach(function (k) {
if (!EN[k]) { return; }
4 years ago
if (KNOWN_ISSUES.indexOf(k) !== -1) { return; }
var s = map[k];
if (typeof(s) !== 'string') { return; }
var usesHTML;
s.replace(/<.*?>/g, function (html) {
if (simpleTags.indexOf(html) !== -1) { return; }
announce();
usesHTML = true;
if (!primary) {
console.log("{%s}", html);
}
});
if (usesHTML) {
4 years ago
announce();
console.log("%s", s);
console.log("[%s]\n", k);
}
});
};
processLang(EN, 'en', true);
[
'ar',
//'bn_BD',
'ca',
'de',
'es',
'fi',
'fr',
'hi',
'it',
'ja',
'nb',
'nl',
'pl',
'pt-br',
'ro',
'ru',
'sv',
//'te',
'tr',
'zh',
].forEach(function (lang) {
try {
var map = require("../www/common/translations/messages." + lang + ".json");
if (!Object.keys(map).length) { return; }
processLang(map, lang);
} catch (err) {
console.error(err);
}
});