@digitaldefiance/i18n-lib 1.0.18 → 1.0.20

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/utils.d.ts CHANGED
@@ -24,3 +24,11 @@ export declare function isValidTimezone(timezone: string): boolean;
24
24
  * @returns The joined string key
25
25
  */
26
26
  export declare function toStringKey<TStringKey extends string>(...parts: (string)[]): TStringKey;
27
+ /**
28
+ * Converts an enum value to a string key by joining parts with underscores and appending the enum value.
29
+ * @param enumObj - The enum object
30
+ * @param value - The enum value
31
+ * @param parts - Additional parts to join
32
+ * @returns The constructed string key
33
+ */
34
+ export declare function toStringKeyFromEnum<TStringKey extends string, TEnum extends string>(value: TEnum[keyof TEnum], ...parts: (string)[]): TStringKey;
package/dist/utils.js CHANGED
@@ -7,6 +7,7 @@ exports.replaceVariables = replaceVariables;
7
7
  exports.isTemplate = isTemplate;
8
8
  exports.isValidTimezone = isValidTimezone;
9
9
  exports.toStringKey = toStringKey;
10
+ exports.toStringKeyFromEnum = toStringKeyFromEnum;
10
11
  const moment_timezone_1 = __importDefault(require("moment-timezone"));
11
12
  /**
12
13
  * Replaces variables in a string with their corresponding values from vars or constants.
@@ -59,3 +60,13 @@ function isValidTimezone(timezone) {
59
60
  function toStringKey(...parts) {
60
61
  return parts.join('_');
61
62
  }
63
+ /**
64
+ * Converts an enum value to a string key by joining parts with underscores and appending the enum value.
65
+ * @param enumObj - The enum object
66
+ * @param value - The enum value
67
+ * @param parts - Additional parts to join
68
+ * @returns The constructed string key
69
+ */
70
+ function toStringKeyFromEnum(value, ...parts) {
71
+ return parts.join('_') + '_' + String(value);
72
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitaldefiance/i18n-lib",
3
- "version": "1.0.18",
3
+ "version": "1.0.20",
4
4
  "description": "Generic i18n library with enum translation support",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",