diff --git a/lib/data-i18n.js b/lib/data-i18n.js new file mode 100644 index 000000000..d65768f80 --- /dev/null +++ b/lib/data-i18n.js @@ -0,0 +1,11 @@ +// Search for items with data-i18n attribute and replace them with values from current locale +let items = document.querySelectorAll("[data-i18n]"); +for (let item of items) { + let translation = chrome.i18n.getMessage(item.getAttribute("data-i18n")); + if (typeof item.value !== "undefined" && item.value === "i18n") { + // things like inputs can trigger translation with value equal "i18n" + item.value = translation; + } else { + item.innerText = translation; + } +} diff --git a/popup/button-menu.html b/popup/button-menu.html index c7013c1b3..fa2512719 100644 --- a/popup/button-menu.html +++ b/popup/button-menu.html @@ -8,35 +8,36 @@ - + +