@urso/core 0.7.24 → 0.7.25
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
CHANGED
package/src/js/lib/helper.js
CHANGED
|
@@ -582,6 +582,23 @@ class LibHelper {
|
|
|
582
582
|
|
|
583
583
|
return results;
|
|
584
584
|
}
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* apply params to string
|
|
588
|
+
* @param {String} string
|
|
589
|
+
* @param {Object} params
|
|
590
|
+
* @returns {String}
|
|
591
|
+
*
|
|
592
|
+
* @example interpolate('Bet ${bet} with Multi ${multi}', {bet:12,multi:13})
|
|
593
|
+
* returns 'Bet 12 with Multi 13'
|
|
594
|
+
*/
|
|
595
|
+
interpolate(string, params) {
|
|
596
|
+
for (const [key, value] of Object.entries(params)) {
|
|
597
|
+
string = Urso.helper.stringReplace('${' + key + '}', value, string);
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
return string
|
|
601
|
+
}
|
|
585
602
|
}
|
|
586
603
|
|
|
587
604
|
module.exports = LibHelper;
|
|
@@ -11,7 +11,7 @@ class ModulesI18nController {
|
|
|
11
11
|
*/
|
|
12
12
|
get(localeId, localeVariables = {}) {
|
|
13
13
|
if (this.#vocabulary && this.#vocabulary[localeId]) {
|
|
14
|
-
return
|
|
14
|
+
return Urso.helper.interpolate(this.#vocabulary[localeId], localeVariables);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
return localeId;
|
|
@@ -66,14 +66,6 @@ class ModulesI18nController {
|
|
|
66
66
|
const localeAsset = { type: Urso.types.assets.JSON, key: localeKey, path: pathToLocaleJson };
|
|
67
67
|
Urso.assets.preload(localeAsset, () => this.setLocale(localeKey));
|
|
68
68
|
}
|
|
69
|
-
|
|
70
|
-
_interpolate(string, params) {
|
|
71
|
-
for (const [key, value] of Object.entries(params)) {
|
|
72
|
-
string = Urso.helper.stringReplace('${' + key + '}', value, string);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return string
|
|
76
|
-
}
|
|
77
69
|
}
|
|
78
70
|
|
|
79
71
|
module.exports = ModulesI18nController;
|