@digitaldefiance/i18n-lib 1.0.30 → 1.0.31
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/dist/i18n-engine.js +6 -3
- package/package.json +1 -1
package/dist/i18n-engine.js
CHANGED
|
@@ -107,17 +107,19 @@ class I18nEngine {
|
|
|
107
107
|
const fallback = fallbackLanguage ?? this.config.defaultLanguage;
|
|
108
108
|
try {
|
|
109
109
|
const stringValue = this.getString(lang, key);
|
|
110
|
-
|
|
110
|
+
const result = (0, utils_1.isTemplate)(key)
|
|
111
111
|
? (0, utils_1.replaceVariables)(stringValue, vars, this.config.constants)
|
|
112
112
|
: stringValue;
|
|
113
|
+
return typeof result === 'string' ? result : String(result);
|
|
113
114
|
}
|
|
114
115
|
catch {
|
|
115
116
|
if (lang !== fallback) {
|
|
116
117
|
try {
|
|
117
118
|
const stringValue = this.getString(fallback, key);
|
|
118
|
-
|
|
119
|
+
const result = (0, utils_1.isTemplate)(key)
|
|
119
120
|
? (0, utils_1.replaceVariables)(stringValue, vars, this.config.constants)
|
|
120
121
|
: stringValue;
|
|
122
|
+
return typeof result === 'string' ? result : String(result);
|
|
121
123
|
}
|
|
122
124
|
catch {
|
|
123
125
|
return String(key);
|
|
@@ -159,9 +161,10 @@ class I18nEngine {
|
|
|
159
161
|
if (!strings?.[key])
|
|
160
162
|
return String(key);
|
|
161
163
|
const stringValue = strings[key];
|
|
162
|
-
|
|
164
|
+
const result = (0, utils_1.isTemplate)(key)
|
|
163
165
|
? (0, utils_1.replaceVariables)(stringValue, vars, this.config.constants)
|
|
164
166
|
: stringValue;
|
|
167
|
+
return typeof result === 'string' ? result : String(result);
|
|
165
168
|
}
|
|
166
169
|
catch {
|
|
167
170
|
return String(key);
|