Description
I'm using the starter kit app where I pass the current language to all views within the shell. All views extend a mixin which loads the langauge resources for the current view in an observer of the language property:
_languageChanged(currentLang, oldLang) {
if (currentLang) {
const viewName = this.getAttribute('name');
this.loadResources(this.resolveUrl(`locales/${currentLang}/${viewName}.json`), currentLang);
}
}
Now I find myself in situation where a call to this.localize returns undefined because the network request loading the language resources is still pending, while the view is being visible. The only solution I found so far is to wrap the whole view inside a
<template is="dom-if" if="{{resources}}">
...
</template>
And add an additional check to observers:
_currentChanged(visible, resources) {
if (visible && resources) {
this.localize(...)
}
}
Isn't there a better solution then differing rendering until the locale resources are loaded?
Description
I'm using the starter kit app where I pass the current language to all views within the shell. All views extend a mixin which loads the langauge resources for the current view in an observer of the language property:
Now I find myself in situation where a call to
this.localizereturns undefined because the network request loading the language resources is still pending, while the view is being visible. The only solution I found so far is to wrap the whole view inside aAnd add an additional check to observers:
Isn't there a better solution then differing rendering until the locale resources are loaded?