@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 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 `null` if the resolved translation is an empty string.
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 | null;
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 `null` if the resolved translation is an empty string.
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 || null;
164
+ return res || String(key);
165
165
  }
166
166
  }
167
167
  exports.LanguageCore = LanguageCore;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xxanderwp/translate-module",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "directories": {