[New] Using Strolch to detect language

This commit is contained in:
Robert von Burg 2017-09-12 15:11:05 +02:00
parent 7949b7571c
commit 11e31089a3
2 changed files with 7 additions and 11 deletions

View File

@ -1,7 +1,7 @@
{
"name": "strolch-wc-localize-behavior",
"description": "Strolch Polymer Localization Behavior extension",
"version": "1.0.3",
"version": "1.1.0",
"authors": [
"Franz Nieschalk",
"Robert von Burg"
@ -20,6 +20,7 @@
"homepage": "https://github.com/4treesCH/strolch-wc-localize-behavior",
"ignore": [],
"dependencies": {
"app-localize-behavior": "PolymerElements/app-localize-behavior#^0.10.0"
"strolchjs": "4treesCH/strolchjs#^0.2.0",
"app-localize-behavior": "PolymerElements/app-localize-behavior#^1.0.2"
}
}

View File

@ -1,22 +1,17 @@
<link rel="import" href="../app-localize-behavior/app-localize-behavior.html">
<script>
// global variables holding the language tag and the URL to the locales.json
var strolchLocalLanguage = undefined;
var strolchLocalResourceUrl = undefined;
// custom behaviour accessing the configuration above
StrolchLocalizeBehaviorImpl = {
attached: function() {
if(!strolchLocalLanguage || !strolchLocalResourceUrl) {
console.log("warning: localization not configured");
return;
}
var locale = Strolch.getUserLocale();
// load the language resource of the configured language
this.language = strolchLocalLanguage;
this.language = locale;
this.useKeyIfMissing = true;
this.loadResources(strolchLocalResourceUrl);
console.log('Loading locales ' + this.localesPath);
this.loadResources(this.resolveUrl(this.localesPath));
}
};