From 792f685359449c84510e04a9f89070f5234a2307 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Wed, 7 Sep 2016 16:05:17 +0200 Subject: Simplify translateDocument function --- js/codeq/translation.js | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'js') diff --git a/js/codeq/translation.js b/js/codeq/translation.js index e648ae3..320cbc1 100644 --- a/js/codeq/translation.js +++ b/js/codeq/translation.js @@ -61,20 +61,13 @@ along with this program. If not, see . */ else jqElt.html(html); }, translateDocument = function (lang) { - $('[data-tkey]').each(function () { - translateElement($(this), 'tkey', lang); - }); - $('[data-tkey-placeholder]').each(function () { - translateElement($(this), 'tkey-placeholder', lang); - }); - $('[data-tkey-title]').each(function () { - translateElement($(this), 'tkey-title', lang); - }); - $('[data-tkey-value]').each(function () { - translateElement($(this), 'tkey-value', lang); - }); - $('[data-tkey-data-content]').each(function () { - translateElement($(this), 'tkey-data-content', lang); + var keys = ['', 'placeholder', 'title', 'value', 'data-content']; + keys.forEach(function (key) { + var tkey = (key == '' ? 'tkey' : 'tkey-' + key), + selector = '[data-' + tkey + ']'; + $(selector).each(function () { + translateElement($(this), tkey, lang); + }); }); }; -- cgit v1.2.1