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, 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,

View File

@ -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.