[New] Using Strolch to detect language
This commit is contained in:
parent
7949b7571c
commit
11e31089a3
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "strolch-wc-localize-behavior",
|
"name": "strolch-wc-localize-behavior",
|
||||||
"description": "Strolch Polymer Localization Behavior extension",
|
"description": "Strolch Polymer Localization Behavior extension",
|
||||||
"version": "1.0.3",
|
"version": "1.1.0",
|
||||||
"authors": [
|
"authors": [
|
||||||
"Franz Nieschalk",
|
"Franz Nieschalk",
|
||||||
"Robert von Burg"
|
"Robert von Burg"
|
||||||
|
@ -20,6 +20,7 @@
|
||||||
"homepage": "https://github.com/4treesCH/strolch-wc-localize-behavior",
|
"homepage": "https://github.com/4treesCH/strolch-wc-localize-behavior",
|
||||||
"ignore": [],
|
"ignore": [],
|
||||||
"dependencies": {
|
"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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,17 @@
|
||||||
<link rel="import" href="../app-localize-behavior/app-localize-behavior.html">
|
<link rel="import" href="../app-localize-behavior/app-localize-behavior.html">
|
||||||
|
|
||||||
<script>
|
<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
|
// custom behaviour accessing the configuration above
|
||||||
StrolchLocalizeBehaviorImpl = {
|
StrolchLocalizeBehaviorImpl = {
|
||||||
attached: function() {
|
attached: function() {
|
||||||
if(!strolchLocalLanguage || !strolchLocalResourceUrl) {
|
var locale = Strolch.getUserLocale();
|
||||||
console.log("warning: localization not configured");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// load the language resource of the configured language
|
// load the language resource of the configured language
|
||||||
this.language = strolchLocalLanguage;
|
this.language = locale;
|
||||||
this.useKeyIfMissing = true;
|
this.useKeyIfMissing = true;
|
||||||
this.loadResources(strolchLocalResourceUrl);
|
console.log('Loading locales ' + this.localesPath);
|
||||||
|
this.loadResources(this.resolveUrl(this.localesPath));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue