mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-09 10:26:35 +00:00
Fix race condition setting current language (#996)
This commit is contained in:
parent
e0ca88b3ad
commit
b80c52dab2
@ -173,8 +173,8 @@ class HomeAssistant extends Polymer.Element {
|
|||||||
themes: null,
|
themes: null,
|
||||||
panelUrl: this.panelUrl,
|
panelUrl: this.panelUrl,
|
||||||
|
|
||||||
// If language and resources are already loaded, don't discard them
|
language: window.getActiveTranslation(),
|
||||||
language: (this.hass && this.hass.language) || null,
|
// If resources are already loaded, don't discard them
|
||||||
resources: (this.hass && this.hass.resources) || null,
|
resources: (this.hass && this.hass.resources) || null,
|
||||||
|
|
||||||
translationMetadata: window.translationMetadata,
|
translationMetadata: window.translationMetadata,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<link rel='import' href='../../build-translations/translationMetadata.html' />
|
<link rel='import' href='../../build-translations/translationMetadata.html' />
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function getActiveTranslation() {
|
window.getActiveTranslation = function () {
|
||||||
// Perform case-insenstive comparison since browser isn't required to
|
// Perform case-insenstive comparison since browser isn't required to
|
||||||
// report languages with specific cases.
|
// report languages with specific cases.
|
||||||
const lookup = {};
|
const lookup = {};
|
||||||
@ -59,7 +59,7 @@ function getActiveTranslation() {
|
|||||||
|
|
||||||
// Final fallback
|
// Final fallback
|
||||||
return 'en';
|
return 'en';
|
||||||
}
|
};
|
||||||
|
|
||||||
// Store loaded translations in memory so translations are available immediately
|
// Store loaded translations in memory so translations are available immediately
|
||||||
// when DOM is created in Polymer. Even a cache lookup creates noticeable latency.
|
// when DOM is created in Polymer. Even a cache lookup creates noticeable latency.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user