pome-ui 2.0.0-preview11 → 2.0.0-preview13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/pome-localization.js +5 -3
- package/pome-localization.min.js +1 -1
package/package.json
CHANGED
package/pome-localization.js
CHANGED
|
@@ -71,11 +71,13 @@ function create() {
|
|
|
71
71
|
|
|
72
72
|
var key = arguments[0];
|
|
73
73
|
var val = key;
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
var foundInOverrides = false;
|
|
75
|
+
if (this.overrides[this.getCurrentLocale()] && this.overrides[this.getCurrentLocale()][key]) {
|
|
76
|
+
val = this.overrides[this.getCurrentLocale()][key];
|
|
77
|
+
foundInOverrides = true;
|
|
76
78
|
}
|
|
77
79
|
|
|
78
|
-
if (!
|
|
80
|
+
if (!foundInOverrides && this.texts[key]) {
|
|
79
81
|
val = this.texts[key];
|
|
80
82
|
}
|
|
81
83
|
|
package/pome-localization.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function create(){var
|
|
1
|
+
function create(){var a=null;return{locales:{},texts:{},overrides:{},getCurrentLocale(){return a},addLocale(e,t,r){if(!t){var l=e.lastIndexOf("/");if(l<0){t=e}else{t=e.substr(e,l+1)}t=t.split(".")[0]}if(typeof t=="string"){this.locales[t]=e}else if(t instanceof Array){for(var a=0;a<t.length;++a){this.locales[t[a]]=e}}if(r){this.locales["fallback"]=e}},setLocale(e){if(!e){e=!window.localStorage.locale?window.navigator.language:window.localStorage.locale}if(!this.locales[e]){e="fallback"}if(!this.locales[e]){throw"No available translations for the locale"}a=e;this.texts=require(this.locales[e]).texts;if(this.locales["fallback"]){if(this.locales[e]!=this.locales["fallback"]){var t=require(this.locales["fallback"]).texts;var r=Object.getOwnPropertyNames(t);var l=this;r.forEach(function(e){if(!l.texts[e]){l.texts[e]=t[e]}})}}},sr(){if(arguments.length==0){return null}var e=arguments[0];var t=e;var r=false;if(this.overrides[this.getCurrentLocale()]&&this.overrides[this.getCurrentLocale()][e]){t=this.overrides[this.getCurrentLocale()][e];r=true}if(!r&&this.texts[e]){t=this.texts[e]}for(var l=1;l<arguments.length;++l){t=t.replaceAll(`{${l-1}}`,arguments[l])}return t},setLocalizedString(e,t,r){var l=this;e.forEach(function(e){if(!l.overrides[e]){l.overrides[e]={}}l.overrides[e][t]=r})}}}exports.create=create;
|