diff options
author | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2016-09-07 16:05:17 +0200 |
---|---|---|
committer | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2016-09-07 16:05:17 +0200 |
commit | 792f685359449c84510e04a9f89070f5234a2307 (patch) | |
tree | a98077d28a5fdf4bc0802839b0ee71cf459b654f | |
parent | 764a076ee3cf99d27607f19fed54ccf771705fab (diff) |
Simplify translateDocument function
-rw-r--r-- | js/codeq/translation.js | 21 |
1 files changed, 7 insertions, 14 deletions
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 <http://www.gnu.org/licenses/>. */ 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); + }); }); }; |