Skip to content

Commit

Permalink
Minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
erosman authored Sep 16, 2023
1 parent 1cf8db5 commit 536a788
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/content/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
class I18n {

static {
document.querySelectorAll('template').forEach(item => this.set(item.content));
document.querySelectorAll('template').forEach(i => this.set(i.content));
this.set();
document.body.style.opacity = 1; // show after i18n
}

static set(target = document) {
target.querySelectorAll('[data-i18n]').forEach(node => {
let [text, attr] = node.dataset.i18n.split('|');
target.querySelectorAll('[data-i18n]').forEach(elem => {
let [text, attr] = elem.dataset.i18n.split('|');
text = browser.i18n.getMessage(text);
attr ? node.setAttribute(attr, text) : node.append(text);
attr ? elem.setAttribute(attr, text) : elem.append(text);
});
}
}

0 comments on commit 536a788

Please sign in to comment.