summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2016-09-07 16:05:17 +0200
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2016-09-07 16:05:17 +0200
commit792f685359449c84510e04a9f89070f5234a2307 (patch)
treea98077d28a5fdf4bc0802839b0ee71cf459b654f /js
parent764a076ee3cf99d27607f19fed54ccf771705fab (diff)
Simplify translateDocument function
Diffstat (limited to 'js')
-rw-r--r--js/codeq/translation.js21
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);
+ });
});
};