reset L10N cache if our page is loaded before bg

This commit is contained in:
tophf 2017-07-11 18:03:35 +03:00
parent d2dd4ae178
commit b31dec86ba
2 changed files with 12 additions and 5 deletions

View File

@ -64,12 +64,10 @@ updateIcon({id: undefined}, {});
url: 'http://add0n.com/stylus.html'
});
}
// reset L10N cache on UI language change or update
const {browserUIlanguage} = tryJSONparse(localStorage.L10N) || {};
const UIlang = chrome.i18n.getUILanguage();
if (reason == 'update' || browserUIlanguage != UIlang) {
// reset L10N cache on update
if (reason == 'update') {
localStorage.L10N = JSON.stringify({
browserUIlanguage: UIlang,
browserUIlanguage: chrome.i18n.getUILanguage(),
});
}
// TODO: remove in the future

View File

@ -91,7 +91,16 @@ function tNodeList(nodes) {
function tDocLoader() {
t.cache = tryJSONparse(localStorage.L10N) || {};
// reset L10N cache on UI language change
const UIlang = chrome.i18n.getUILanguage();
if (t.cache.browserUIlanguage != UIlang) {
t.cache = {browserUIlanguage: UIlang};
localStorage.L10N = JSON.stringify(t.cache);
}
const cacheLength = Object.keys(t.cache).length;
// localize HEAD
tNodeList(document.getElementsByTagName('*'));