feat(scripts): apply translations
This commit is contained in:
parent
2e589f2adc
commit
5bb09feebd
@ -94,8 +94,10 @@ const handleRate = (event) => {
|
||||
*/
|
||||
|
||||
const handleContentLoaded = () => {
|
||||
dispatch({ type: "GET_TAB" }, null, ({ hostname, id }) => {
|
||||
dispatch({ type: "GET_TAB" }, null, ({ hostname }) => {
|
||||
dispatch({ hostname, type: "GET_CACHE" }, null, ({ enabled }) => {
|
||||
translate();
|
||||
|
||||
const host = document.getElementById("host");
|
||||
const like = document.getElementById("like");
|
||||
const power = document.getElementById("power");
|
||||
@ -114,6 +116,21 @@ const handleContentLoaded = () => {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @description Applies translations to tags with i18n data attribute
|
||||
*/
|
||||
|
||||
const translate = () => {
|
||||
const nodes = document.querySelectorAll("[data-i18n]");
|
||||
|
||||
for (let i = nodes.length; i--; ) {
|
||||
const node = nodes[i];
|
||||
const { i18n } = node.dataset;
|
||||
|
||||
node.innerHTML = chrome.i18n.getMessage(i18n);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @description Listen to document ready
|
||||
* @listens document#ready
|
||||
|
Loading…
Reference in New Issue
Block a user