From cc141ebee86e96be756ab1f6fceddcd855d040ad Mon Sep 17 00:00:00 2001 From: ansuz Date: Fri, 13 May 2022 19:18:26 +0530 Subject: [PATCH] improve translation linting --- scripts/translations/lint-translations.js | 14 ++++++++++++-- www/admin/inner.js | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/scripts/translations/lint-translations.js b/scripts/translations/lint-translations.js index 5234d1b68..b34a715cd 100644 --- a/scripts/translations/lint-translations.js +++ b/scripts/translations/lint-translations.js @@ -18,11 +18,13 @@ var simpleTags = [ '', ]; -['a', 'b', 'em', 'p', 'i', 'code', 'li',].forEach(function (tag) { +['a', 'b', 'em',/* 'p',*/ 'i', 'code', 'li',].forEach(function (tag) { simpleTags.push('<' + tag + '>'); simpleTags.push(''); }); +var found_tags = {}; + // these keys are known to be problematic var KNOWN_ISSUES = [ // FIXME //'newVersion', @@ -67,7 +69,10 @@ var processLang = function (map, lang, primary) { var usesHTML; s.replace(/<[\s\S]*?>/g, function (html) { - if (simpleTags.indexOf(html) !== -1) { return; } + if (simpleTags.includes(html)) { + found_tags[html] = 1; + return; + } announce(); usesHTML = true; if (!primary) { @@ -126,3 +131,8 @@ processLang(EN, 'en', true); console.error(err); } }); + +simpleTags.forEach(html => { + if (found_tags[html]) { return; } + console.log(`html exemption '${html}' is unnecessary.`); +}); diff --git a/www/admin/inner.js b/www/admin/inner.js index c81fa55f8..18d0ed314 100644 --- a/www/admin/inner.js +++ b/www/admin/inner.js @@ -481,7 +481,7 @@ define([ create['notice'] = function () { // TODO make translateable var key = 'notice'; - var $div = makeBlock(key, true); + var $div = makeBlock(key, true); // Messages.admin_noticeHint var $button = $div.find('button').addClass('cp-listing-action').text(Messages.settings_save);