strolch-wc-localize-behavior/strolch-wc-localize-behavio...

35 lines
1.3 KiB
HTML
Raw Normal View History

<link rel="import" href="../app-localize-behavior/app-localize-behavior.html">
<script>
// custom behaviour accessing the configuration above
StrolchLocalizeBehaviorImpl = {
2021-09-10 08:03:01 +02:00
properties: {
fallbackLanguage: {
type: String,
value: "en"
}
},
created: function () {
this.__computeLocalizeOld = this.__computeLocalize;
this.__computeLocalize = function (language, resources, formats) {
if (!resources[language])
return this.__computeLocalizeOld(this.fallbackLanguage, resources, formats).bind(this);
return this.__computeLocalizeOld(language, resources, formats).bind(this);
}.bind(this);
},
attached: function () {
// load the language resource of the configured language
2021-09-10 08:03:01 +02:00
this.language = Strolch.getUserLocale();
2017-03-08 16:34:42 +01:00
this.useKeyIfMissing = true;
if (Strolch.isNotEmptyString(this.localesPath)) {
this.loadResources(this.resolveUrl(this.localesPath));
}
2021-09-10 08:03:01 +02:00
},
};
// inherit the behavior of the standard polymer localization
StrolchLocalizeBehavior = [Polymer.AppLocalizeBehavior, StrolchLocalizeBehaviorImpl];
</script>