@digitaldefiance/i18n-lib 1.0.29 → 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 +10 -7
- package/package.json +1 -1
package/dist/i18n-engine.js
CHANGED
|
@@ -107,23 +107,25 @@ 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
|
-
return key;
|
|
125
|
+
return String(key);
|
|
124
126
|
}
|
|
125
127
|
}
|
|
126
|
-
return key;
|
|
128
|
+
return String(key);
|
|
127
129
|
}
|
|
128
130
|
}
|
|
129
131
|
/**
|
|
@@ -157,14 +159,15 @@ class I18nEngine {
|
|
|
157
159
|
const lang = language ?? this.config.defaultLanguage;
|
|
158
160
|
const strings = this.config.strings[lang];
|
|
159
161
|
if (!strings?.[key])
|
|
160
|
-
return key;
|
|
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
|
-
return key;
|
|
170
|
+
return String(key);
|
|
168
171
|
}
|
|
169
172
|
}
|
|
170
173
|
/**
|