@xxanderwp/translate-module 1.0.4 → 1.0.5
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/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -114,12 +114,12 @@ export declare class LanguageCore<T extends Record<string, Record<string, string
|
|
|
114
114
|
* @param args - Zero or more values to interpolate into the translated string.
|
|
115
115
|
* Each value is coerced to a string and replaces the matching `{n}` token.
|
|
116
116
|
*
|
|
117
|
-
* @returns The translated (and interpolated) string, or
|
|
117
|
+
* @returns The translated (and interpolated) string, or the key itself if the translation is missing.
|
|
118
118
|
*
|
|
119
119
|
* @example
|
|
120
120
|
* lc.translate("greeting", "Alice"); // "Hello, Alice!"
|
|
121
121
|
* lc.translate("score", "Alice", 42); // "Alice scored 42 points."
|
|
122
122
|
*/
|
|
123
|
-
translate<K extends keyof T[LangKey]>(key: K, ...args: (string | number)[]): string
|
|
123
|
+
translate<K extends keyof T[LangKey]>(key: K, ...args: (string | number)[]): string;
|
|
124
124
|
}
|
|
125
125
|
export default LanguageCore;
|
package/dist/index.js
CHANGED
|
@@ -149,7 +149,7 @@ class LanguageCore {
|
|
|
149
149
|
* @param args - Zero or more values to interpolate into the translated string.
|
|
150
150
|
* Each value is coerced to a string and replaces the matching `{n}` token.
|
|
151
151
|
*
|
|
152
|
-
* @returns The translated (and interpolated) string, or
|
|
152
|
+
* @returns The translated (and interpolated) string, or the key itself if the translation is missing.
|
|
153
153
|
*
|
|
154
154
|
* @example
|
|
155
155
|
* lc.translate("greeting", "Alice"); // "Hello, Alice!"
|
|
@@ -161,7 +161,7 @@ class LanguageCore {
|
|
|
161
161
|
args.forEach((arg, index) => {
|
|
162
162
|
res = res.replace(new RegExp(`\\{${index}\\}`, "g"), String(arg));
|
|
163
163
|
});
|
|
164
|
-
return res ||
|
|
164
|
+
return res || String(key);
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
exports.LanguageCore = LanguageCore;
|