2 Copyright (C) 2017 Kai Uwe Broulik <kde@privat.broulik.de>
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as
6 published by the Free Software Foundation; either version 3 of
7 the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 document.addEventListener("DOMContentLoaded", function() {
20 document.querySelectorAll("[data-i18n]").forEach(function (item) {
21 var data = item.dataset.i18n.split(",").map(function (value) {
24 if (value.startsWith("__MSG_")) {
25 return value.replace(/__MSG_(\w+)__/g, function (match, key) {
26 return key ? chrome.i18n.getMessage(key) : "";
33 var text = chrome.i18n.getMessage(data.shift(), data) || ("I18N_UNKNOWN " + item.dataset.i18n);
35 if (!!item.dataset.i18nHtml) {
36 item.innerHTML = text;
38 item.innerText = text;