-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- #20 - inspired by https://gist.github.com/eligrey/738199 and https://git.io/viasH
- Loading branch information
Showing
2 changed files
with
28 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters