reset L10N cache if our page is loaded before bg
This commit is contained in:
		
							parent
							
								
									d2dd4ae178
								
							
						
					
					
						commit
						b31dec86ba
					
				|  | @ -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
 | ||||
|  |  | |||
|  | @ -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('*')); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user