Fix race condition setting current language (#996)

This commit is contained in:
Paulus Schoutsen 2018-03-15 12:33:32 -07:00 committed by GitHub
parent e0ca88b3ad
commit b80c52dab2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -173,8 +173,8 @@ class HomeAssistant extends Polymer.Element {
themes: null,
panelUrl: this.panelUrl,
// If language and resources are already loaded, don't discard them
language: (this.hass && this.hass.language) || null,
language: window.getActiveTranslation(),
// If resources are already loaded, don't discard them
resources: (this.hass && this.hass.resources) || null,
translationMetadata: window.translationMetadata,

View File

@ -1,7 +1,7 @@
<link rel='import' href='../../build-translations/translationMetadata.html' />
<script>
function getActiveTranslation() {
window.getActiveTranslation = function () {
// Perform case-insenstive comparison since browser isn't required to
// report languages with specific cases.
const lookup = {};
@ -59,7 +59,7 @@ function getActiveTranslation() {
// Final fallback
return 'en';
}
};
// Store loaded translations in memory so translations are available immediately
// when DOM is created in Polymer. Even a cache lookup creates noticeable latency.