@digitaldefiance/i18n-lib 3.6.3 → 3.7.0

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.
Files changed (52) hide show
  1. package/README.md +124 -3
  2. package/package.json +1 -1
  3. package/src/errors/context-error.d.ts +33 -1
  4. package/src/errors/context-error.d.ts.map +1 -1
  5. package/src/errors/context-error.js +46 -3
  6. package/src/errors/context-error.js.map +1 -1
  7. package/src/errors/enhanced-error-base.d.ts +120 -0
  8. package/src/errors/enhanced-error-base.d.ts.map +1 -0
  9. package/src/errors/enhanced-error-base.js +165 -0
  10. package/src/errors/enhanced-error-base.js.map +1 -0
  11. package/src/errors/handleable.d.ts +38 -2
  12. package/src/errors/handleable.d.ts.map +1 -1
  13. package/src/errors/handleable.js +38 -2
  14. package/src/errors/handleable.js.map +1 -1
  15. package/src/errors/i18n-error.d.ts +91 -27
  16. package/src/errors/i18n-error.d.ts.map +1 -1
  17. package/src/errors/i18n-error.js +150 -40
  18. package/src/errors/i18n-error.js.map +1 -1
  19. package/src/errors/index.d.ts +1 -0
  20. package/src/errors/index.d.ts.map +1 -1
  21. package/src/errors/index.js +1 -0
  22. package/src/errors/index.js.map +1 -1
  23. package/src/errors/translatable-generic.d.ts +55 -1
  24. package/src/errors/translatable-generic.d.ts.map +1 -1
  25. package/src/errors/translatable-generic.js +64 -1
  26. package/src/errors/translatable-generic.js.map +1 -1
  27. package/src/errors/translatable-handleable-generic.d.ts +88 -1
  28. package/src/errors/translatable-handleable-generic.d.ts.map +1 -1
  29. package/src/errors/translatable-handleable-generic.js +77 -1
  30. package/src/errors/translatable-handleable-generic.js.map +1 -1
  31. package/src/errors/translatable.d.ts +55 -0
  32. package/src/errors/translatable.d.ts.map +1 -1
  33. package/src/errors/translatable.js +66 -0
  34. package/src/errors/translatable.js.map +1 -1
  35. package/src/errors/typed-handleable.d.ts +48 -0
  36. package/src/errors/typed-handleable.d.ts.map +1 -1
  37. package/src/errors/typed-handleable.js +48 -0
  38. package/src/errors/typed-handleable.js.map +1 -1
  39. package/src/errors/typed.d.ts +120 -4
  40. package/src/errors/typed.d.ts.map +1 -1
  41. package/src/errors/typed.js +120 -4
  42. package/src/errors/typed.js.map +1 -1
  43. package/src/icu/compiler.d.ts.map +1 -1
  44. package/src/icu/compiler.js +8 -2
  45. package/src/icu/compiler.js.map +1 -1
  46. package/src/icu/formatters/number-formatter.d.ts.map +1 -1
  47. package/src/icu/formatters/number-formatter.js +3 -0
  48. package/src/icu/formatters/number-formatter.js.map +1 -1
  49. package/src/types.d.ts +4 -0
  50. package/src/types.d.ts.map +1 -1
  51. package/src/types.js +5 -1
  52. package/src/types.js.map +1 -1
package/README.md CHANGED
@@ -17,8 +17,9 @@ Part of [Express Suite](https://github.com/Digital-Defiance/express-suite)
17
17
  - **37 Supported Languages**: CLDR-compliant plural rules for world's most complex languages
18
18
  - **Pluralization Support**: Automatic plural form selection based on count (one/few/many/other)
19
19
  - **Gender Support**: Gender-aware translations (male/female/neutral/other)
20
+ - **Advanced Number Formatting**: Thousand separators, currency, percent with decimal precision
20
21
  - **8 Built-in Languages**: English (US/UK), French, Spanish, German, Chinese, Japanese, Ukrainian
21
- - **Advanced Template Processing**:
22
+ - **Advanced Template Processing**:
22
23
  - Component references: `{{Component.key}}`
23
24
  - Alias resolution: `{{Alias.key}}`
24
25
  - Enum name resolution: `{{EnumName.value}}`
@@ -30,8 +31,8 @@ Part of [Express Suite](https://github.com/Digital-Defiance/express-suite)
30
31
  - **Fluent Builder**: I18nBuilder for clean, chainable engine configuration
31
32
  - **Core System Strings**: Pre-built translations for common UI elements and errors
32
33
  - **Type Safety**: Full TypeScript support with generic types
33
- - **Error Handling**: Comprehensive error classes with translation support
34
- - **91.81% Test Coverage**: 714 tests covering all features
34
+ - **Error Handling**: Comprehensive error classes with translation support and ICU formatting
35
+ - **93.22% Test Coverage**: 1,738 tests covering all features
35
36
  - **Security Hardened**: See [SECURITY.md](SECURITY.md) for details
36
37
 
37
38
  ## Installation
@@ -223,6 +224,7 @@ engine.translate('shop', 'items', { count: 21 }, 'ru'); // "21 товар"
223
224
  ```
224
225
 
225
226
  **Supported Languages** (37 total):
227
+
226
228
  - **Simple** (other only): Japanese, Chinese, Korean, Turkish, Vietnamese, Thai, Indonesian, Malay
227
229
  - **Two forms** (one/other): English, German, Spanish, Italian, Portuguese, Dutch, Swedish, Norwegian, Danish, Finnish, Greek, Hebrew, Hindi
228
230
  - **Three forms** (one/few/many): Russian, Ukrainian, Romanian, Latvian
@@ -765,6 +767,125 @@ Contributions welcome! Please:
765
767
 
766
768
  ## ChangeLog
767
769
 
770
+ ### Version 3.7.0 (January 2026)
771
+
772
+ **Comprehensive ICU Integration & Number Formatting Enhancements**
773
+
774
+ Enhanced **all** I18nError methods and core ICU infrastructure to fully leverage 3.5.0 advanced ICU MessageFormat features:
775
+
776
+ **Core Infrastructure Improvements:**
777
+
778
+ - **ICU Compiler Enhancements**:
779
+ - Fixed `#` placeholder in plural/selectordinal to use `Intl.NumberFormat` with thousand separators
780
+ - Numbers in plural messages now properly formatted (1,500 instead of 1500)
781
+ - Locale-aware formatting respects regional preferences
782
+
783
+ - **Number Formatter Upgrades**:
784
+ - **Percent formatting** now shows decimal precision (0-2 places): 5.67% instead of 5%
785
+ - **Integer formatting** maintains thousand separators automatically
786
+ - **Currency formatting** preserves decimal places with locale-specific symbols
787
+
788
+ **Enhanced Error Methods** (13 existing + 4 new):
789
+
790
+ *Enhanced Existing Methods:*
791
+ - `componentNotFound()` - ICU select for namespaced components
792
+ - `stringKeyNotFound()` - SelectOrdinal for nested depth levels
793
+ - `duplicateComponent()` - Nested select for namespace context
794
+ - `instanceNotFound()` - Select for default vs named instances
795
+ - `instanceExists()` - Nested select with detailed messages
796
+ - `translationMissing()` - Nested select detecting key paths
797
+ - `duplicateLanguage()` - Template literal with proper quoting
798
+ - `pluralFormNotFound()` - Nested select + plural + number formatting (form count)
799
+ - `invalidPluralCategory()` - Nested plural + number formatting (category count)
800
+ - And 4 more existing methods with ICU enhancements...
801
+
802
+ *New Advanced Methods:*
803
+ - `validationThresholdExceeded()` - **Number formatting**: Currency ($1,500.50), Percent (5.67%), Integer (1,500)
804
+ - `operationStepFailed()` - **SelectOrdinal**: 1st, 2nd, 3rd, 4th, 21st, 22nd, 23rd...
805
+ - `rateLimitExceeded()` - **4-level nested messages**: Plural + number + select with thousand separators
806
+ - `nestedValidationError()` - **Complex nesting**: Multiple select + plural for validation context
807
+
808
+ **ICU Features Fully Integrated:**
809
+
810
+ - ✅ **Number Formatters**: Currency ($1,500.50), percent (5.67%), integer (1,500) with thousand separators
811
+ - ✅ **SelectOrdinal**: Ordinal formatting (1st, 2nd, 3rd, 21st, 22nd, 23rd)
812
+ - ✅ **Nested Messages**: Up to 4 levels deep with combined plural, select, and number formatting
813
+ - ✅ **ICU Plural**: `#` placeholder now formats with thousand separators
814
+ - ✅ **ICU Select**: Nested within plural messages for complex conditional logic
815
+ - ✅ **Decimal Precision**: Percent values show up to 2 decimal places
816
+ - ✅ **Locale-Aware**: All formatting respects target language/locale
817
+
818
+ - **Real-World Use Cases**:
819
+ - Validation threshold errors with formatted currency/percentages
820
+ - Multi-step operation failures with ordinal step numbers
821
+ - Rate limiting with nested request counts and retry timing
822
+ - Complex nested field validation with severity levels
823
+
824
+ **Testing & Quality:**
825
+
826
+ - **1,738 total tests passing** (93.22% coverage)
827
+ - **250+ new tests** for advanced ICU features:
828
+ - Currency formatting: $1,500.50, €1.500,50, ¥1,500
829
+ - Percent precision: 5.67%, 0.5%, 100%
830
+ - SelectOrdinal: 1st-100th with edge cases (11th, 21st, 22nd, 23rd)
831
+ - Nested messages: 4 levels deep validation
832
+ - Thousand separators: 1,000, 10,000, 1,000,000
833
+ - Multilingual: 8+ languages tested
834
+ - Real-world scenarios: API rate limits, validation thresholds, multi-step operations
835
+
836
+ **Documentation:**
837
+
838
+ - All error methods include comprehensive JSDoc with ICU pattern examples
839
+ - EnhancedErrorHelper base class with static utility methods
840
+ - Integration patterns for all error class types
841
+ - Migration guide showing before/after message formats
842
+
843
+ **New Error Codes:**
844
+ - `VALIDATION_THRESHOLD_EXCEEDED` - Numeric threshold violations with formatted values
845
+ - `OPERATION_STEP_FAILED` - Step-based operation failures with ordinal formatting
846
+ - `RATE_LIMIT_EXCEEDED` - Rate limiting with nested plural/number formatting
847
+ - `NESTED_VALIDATION_ERROR` - Complex nested validation with 4-level messages
848
+
849
+ **Files Modified:**
850
+ - `src/icu/compiler.ts` - Enhanced `#` placeholder with `Intl.NumberFormat`
851
+ - `src/icu/formatters/number-formatter.ts` - Added percent decimal precision (0-2 places)
852
+ - `src/errors/i18n-error.ts` - Enhanced all 17 error methods with ICU patterns
853
+ - `src/errors/enhanced-error-base.ts` - New base class with static helper methods
854
+ - `src/errors/*.ts` - Enhanced 8 error classes with comprehensive JSDoc
855
+ - `tests/errors/*.spec.ts` - 250+ new tests, updated expectations
856
+
857
+ **Breaking Changes:**
858
+
859
+ None - Fully backward compatible! All changes are enhancements:
860
+ - Enhanced error message formats (more detailed, better formatted)
861
+ - Metadata structure extended (formCount, count added where useful)
862
+ - New optional parameters for advanced error methods
863
+ - All existing code continues to work unchanged
864
+
865
+ **Migration:**
866
+
867
+ No migration required! Your existing code works as-is. To use new features:
868
+
869
+ ```typescript
870
+ // Use new number formatting in errors
871
+ const error = I18nError.validationThresholdExceeded(
872
+ 'price', 99.99, 50.00, 'currency', 'en-US'
873
+ );
874
+ // Message: "Validation failed for price: value $99.99 exceeds maximum threshold of $50.00"
875
+
876
+ // Use selectordinal for steps
877
+ const error = I18nError.operationStepFailed(3, 'deployment', 'Connection timeout');
878
+ // Message: "Operation 'deployment' failed at 3rd step: Connection timeout"
879
+
880
+ // Numbers in plural messages now have thousand separators automatically
881
+ const error = I18nError.rateLimitExceeded(1500, 1000, 3600, 300);
882
+ // Message: "Rate limit exceeded: 1,500 requests made, exceeding limit of 1,000..."
883
+ ```
884
+
885
+ ### Version 3.6.4
886
+
887
+ - Add DefaultLanguageCode
888
+
768
889
  ### Version 3.6.3
769
890
 
770
891
  - make getCodeLabelMap() not readonly
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitaldefiance/i18n-lib",
3
- "version": "3.6.3",
3
+ "version": "3.7.0",
4
4
  "description": "i18n library with enum translation support",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -2,17 +2,49 @@ import { ContextErrorType } from '../context-error-type';
2
2
  /**
3
3
  * Error class for context-related failures in the i18n system.
4
4
  * Thrown when attempting to access or manipulate an invalid or non-existent context.
5
+ *
6
+ * **i18n Feature Support:**
7
+ * - ICU MessageFormat variable substitution
8
+ * - Nested message paths detection
9
+ * - Number formatting for context depths/positions
10
+ * - SelectOrdinal for context priority levels
11
+ *
12
+ * **Translation String Examples:**
13
+ * ```typescript
14
+ * // ICU plural
15
+ * "Context has {count, plural, one {# issue} other {# issues}}"
16
+ *
17
+ * // ICU select + nested
18
+ * "{severity, select, low {Minor context issue} high {Critical context error}}"
19
+ *
20
+ * // Number formatting
21
+ * "Context exceeded {limit, number, integer} maximum depth"
22
+ * ```
5
23
  */
6
24
  export declare class ContextError extends Error {
7
25
  /** The type of context error */
8
26
  readonly type: ContextErrorType;
9
27
  /** The context key that caused the error, if applicable */
10
28
  readonly contextKey?: string;
29
+ /** Additional context metadata */
30
+ readonly metadata?: Record<string, any>;
11
31
  /**
12
32
  * Creates a new ContextError instance.
13
33
  * @param type - The type of context error
14
34
  * @param contextKey - Optional context key that caused the error
35
+ * @param variables - Additional variables for ICU message formatting
36
+ * @param language - Optional language code
15
37
  */
16
- constructor(type: ContextErrorType, contextKey?: string);
38
+ constructor(type: ContextErrorType, contextKey?: string, variables?: Record<string, string | number>, language?: string);
39
+ /**
40
+ * Create context error with nested path information
41
+ * Demonstrates selectordinal for depth level
42
+ */
43
+ static withNestedPath(type: ContextErrorType, contextPath: string, language?: string): ContextError;
44
+ /**
45
+ * Create context error with count information
46
+ * Demonstrates plural formatting
47
+ */
48
+ static withCount(type: ContextErrorType, contextKey: string, count: number, language?: string): ContextError;
17
49
  }
18
50
  //# sourceMappingURL=context-error.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context-error.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/errors/context-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAIzD;;;GAGG;AACH,qBAAa,YAAa,SAAQ,KAAK;IACrC,gCAAgC;IAChC,SAAgB,IAAI,EAAE,gBAAgB,CAAC;IACvC,2DAA2D;IAC3D,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpC;;;;OAIG;gBACS,IAAI,EAAE,gBAAgB,EAAE,UAAU,CAAC,EAAE,MAAM;CAUxD"}
1
+ {"version":3,"file":"context-error.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/errors/context-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAKzD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,YAAa,SAAQ,KAAK;IACrC,gCAAgC;IAChC,SAAgB,IAAI,EAAE,gBAAgB,CAAC;IACvC,2DAA2D;IAC3D,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpC,kCAAkC;IAClC,SAAgB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAE/C;;;;;;OAMG;gBAED,IAAI,EAAE,gBAAgB,EACtB,UAAU,CAAC,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EAC3C,QAAQ,CAAC,EAAE,MAAM;IAcnB;;;OAGG;IACH,MAAM,CAAC,cAAc,CACnB,IAAI,EAAE,gBAAgB,EACtB,WAAW,EAAE,MAAM,EACnB,QAAQ,SAAU,GACjB,YAAY;IAaf;;;OAGG;IACH,MAAM,CAAC,SAAS,CACd,IAAI,EAAE,gBAAgB,EACtB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,QAAQ,SAAU,GACjB,YAAY;CAQhB"}
@@ -3,29 +3,72 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ContextError = void 0;
4
4
  const core_i18n_1 = require("../core-i18n");
5
5
  const core_string_key_1 = require("../core-string-key");
6
+ const enhanced_error_base_1 = require("./enhanced-error-base");
6
7
  /**
7
8
  * Error class for context-related failures in the i18n system.
8
9
  * Thrown when attempting to access or manipulate an invalid or non-existent context.
10
+ *
11
+ * **i18n Feature Support:**
12
+ * - ICU MessageFormat variable substitution
13
+ * - Nested message paths detection
14
+ * - Number formatting for context depths/positions
15
+ * - SelectOrdinal for context priority levels
16
+ *
17
+ * **Translation String Examples:**
18
+ * ```typescript
19
+ * // ICU plural
20
+ * "Context has {count, plural, one {# issue} other {# issues}}"
21
+ *
22
+ * // ICU select + nested
23
+ * "{severity, select, low {Minor context issue} high {Critical context error}}"
24
+ *
25
+ * // Number formatting
26
+ * "Context exceeded {limit, number, integer} maximum depth"
27
+ * ```
9
28
  */
10
29
  class ContextError extends Error {
11
30
  /** The type of context error */
12
31
  type;
13
32
  /** The context key that caused the error, if applicable */
14
33
  contextKey;
34
+ /** Additional context metadata */
35
+ metadata;
15
36
  /**
16
37
  * Creates a new ContextError instance.
17
38
  * @param type - The type of context error
18
39
  * @param contextKey - Optional context key that caused the error
40
+ * @param variables - Additional variables for ICU message formatting
41
+ * @param language - Optional language code
19
42
  */
20
- constructor(type, contextKey) {
43
+ constructor(type, contextKey, variables, language) {
21
44
  const engine = (0, core_i18n_1.getCoreI18nEngine)();
45
+ const allVars = { ...variables, contextKey: contextKey || '' };
22
46
  const message = contextKey
23
- ? engine.safeTranslate(core_i18n_1.CoreI18nComponentId, core_string_key_1.CoreStringKey.Error_InvalidContextTemplate, { contextKey })
24
- : engine.safeTranslate(core_i18n_1.CoreI18nComponentId, core_string_key_1.CoreStringKey.Error_InvalidContext);
47
+ ? engine.safeTranslate(core_i18n_1.CoreI18nComponentId, core_string_key_1.CoreStringKey.Error_InvalidContextTemplate, allVars, language)
48
+ : engine.safeTranslate(core_i18n_1.CoreI18nComponentId, core_string_key_1.CoreStringKey.Error_InvalidContext, allVars, language);
25
49
  super(message);
26
50
  this.name = 'ContextError';
27
51
  this.type = type;
28
52
  this.contextKey = contextKey;
53
+ this.metadata = variables;
54
+ }
55
+ /**
56
+ * Create context error with nested path information
57
+ * Demonstrates selectordinal for depth level
58
+ */
59
+ static withNestedPath(type, contextPath, language = 'en-US') {
60
+ const analysis = enhanced_error_base_1.EnhancedErrorHelper.analyzeKeyPath(contextPath);
61
+ return new ContextError(type, contextPath, {
62
+ depth: analysis.depth,
63
+ isNested: analysis.isNested ? 'true' : 'false',
64
+ }, language);
65
+ }
66
+ /**
67
+ * Create context error with count information
68
+ * Demonstrates plural formatting
69
+ */
70
+ static withCount(type, contextKey, count, language = 'en-US') {
71
+ return new ContextError(type, contextKey, { count }, language);
29
72
  }
30
73
  }
31
74
  exports.ContextError = ContextError;
@@ -1 +1 @@
1
- {"version":3,"file":"context-error.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/errors/context-error.ts"],"names":[],"mappings":";;;AACA,4CAAsE;AACtE,wDAAmD;AAEnD;;;GAGG;AACH,MAAa,YAAa,SAAQ,KAAK;IACrC,gCAAgC;IAChB,IAAI,CAAmB;IACvC,2DAA2D;IAC3C,UAAU,CAAU;IAEpC;;;;OAIG;IACH,YAAY,IAAsB,EAAE,UAAmB;QACrD,MAAM,MAAM,GAAG,IAAA,6BAAiB,GAAE,CAAC;QACnC,MAAM,OAAO,GAAG,UAAU;YACxB,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,+BAAmB,EAAE,+BAAa,CAAC,4BAA4B,EAAE,EAAC,UAAU,EAAC,CAAC;YACrG,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,+BAAmB,EAAE,+BAAa,CAAC,oBAAoB,CAAC,CAAC;QAClF,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF;AArBD,oCAqBC"}
1
+ {"version":3,"file":"context-error.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/errors/context-error.ts"],"names":[],"mappings":";;;AACA,4CAAsE;AACtE,wDAAmD;AACnD,+DAA4D;AAE5D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAa,YAAa,SAAQ,KAAK;IACrC,gCAAgC;IAChB,IAAI,CAAmB;IACvC,2DAA2D;IAC3C,UAAU,CAAU;IACpC,kCAAkC;IAClB,QAAQ,CAAuB;IAE/C;;;;;;OAMG;IACH,YACE,IAAsB,EACtB,UAAmB,EACnB,SAA2C,EAC3C,QAAiB;QAEjB,MAAM,MAAM,GAAG,IAAA,6BAAiB,GAAE,CAAC;QACnC,MAAM,OAAO,GAAG,EAAE,GAAG,SAAS,EAAE,UAAU,EAAE,UAAU,IAAI,EAAE,EAAE,CAAC;QAC/D,MAAM,OAAO,GAAG,UAAU;YACxB,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,+BAAmB,EAAE,+BAAa,CAAC,4BAA4B,EAAE,OAAO,EAAE,QAAQ,CAAC;YAC1G,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,+BAAmB,EAAE,+BAAa,CAAC,oBAAoB,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QACrG,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,cAAc,CACnB,IAAsB,EACtB,WAAmB,EACnB,QAAQ,GAAG,OAAO;QAElB,MAAM,QAAQ,GAAG,yCAAmB,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QACjE,OAAO,IAAI,YAAY,CACrB,IAAI,EACJ,WAAW,EACX;YACE,KAAK,EAAE,QAAQ,CAAC,KAAK;YACrB,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;SAC/C,EACD,QAAQ,CACT,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,SAAS,CACd,IAAsB,EACtB,UAAkB,EAClB,KAAa,EACb,QAAQ,GAAG,OAAO;QAElB,OAAO,IAAI,YAAY,CACrB,IAAI,EACJ,UAAU,EACV,EAAE,KAAK,EAAE,EACT,QAAQ,CACT,CAAC;IACJ,CAAC;CACF;AAvED,oCAuEC"}
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Enhanced error base with i18n 3.0/3.5 feature support
3
+ * Provides helper methods for ICU MessageFormat, pluralization, gender, and advanced features
4
+ */
5
+ import { GenderCategory } from '../gender/gender-categories';
6
+ /**
7
+ * Options for enhanced error message formatting
8
+ */
9
+ export interface EnhancedErrorOptions {
10
+ /** Variables for ICU substitution */
11
+ variables?: Record<string, string | number | boolean>;
12
+ /** Language code for message formatting */
13
+ language?: string;
14
+ /** Count for plural formatting */
15
+ count?: number;
16
+ /** Gender for gender-aware formatting */
17
+ gender?: GenderCategory;
18
+ /** Additional metadata */
19
+ metadata?: Record<string, any>;
20
+ }
21
+ /**
22
+ * Helper class providing advanced i18n features for error messages
23
+ * This can be used as a mixin or utility class for error classes
24
+ */
25
+ export declare class EnhancedErrorHelper {
26
+ /**
27
+ * Format error message with ICU MessageFormat
28
+ * @param pattern - ICU message pattern
29
+ * @param options - Formatting options
30
+ * @returns Formatted message string
31
+ */
32
+ static formatMessage(pattern: string, options?: EnhancedErrorOptions): string;
33
+ /**
34
+ * Create a plural-aware error message
35
+ * @param singularPattern - Pattern for singular form
36
+ * @param pluralPattern - Pattern for plural form
37
+ * @param count - Count value
38
+ * @param options - Additional formatting options
39
+ * @returns Formatted message
40
+ */
41
+ static formatPlural(singularPattern: string, pluralPattern: string, count: number, options?: Omit<EnhancedErrorOptions, 'count'>): string;
42
+ /**
43
+ * Create a gender-aware error message
44
+ * @param patterns - Patterns for different genders
45
+ * @param gender - Gender value
46
+ * @param options - Additional formatting options
47
+ * @returns Formatted message
48
+ */
49
+ static formatGender(patterns: Partial<Record<GenderCategory, string>>, gender: GenderCategory, options?: Omit<EnhancedErrorOptions, 'gender'>): string;
50
+ /**
51
+ * Format ordinal numbers (1st, 2nd, 3rd, etc.)
52
+ * @param number - The number to format
53
+ * @param pattern - Pattern with {number} placeholder
54
+ * @param options - Additional formatting options
55
+ * @returns Formatted message with ordinal
56
+ */
57
+ static formatOrdinal(number: number, pattern: string, options?: EnhancedErrorOptions): string;
58
+ /**
59
+ * Format numbers with specific formatting (integer, currency, percent)
60
+ * @param value - Number value
61
+ * @param format - Format type
62
+ * @param pattern - Pattern with {value} placeholder
63
+ * @param options - Additional formatting options
64
+ * @returns Formatted message
65
+ */
66
+ static formatNumber(value: number, format: 'integer' | 'currency' | 'percent', pattern: string, options?: EnhancedErrorOptions): string;
67
+ /**
68
+ * Create nested messages with multiple levels of ICU formatting
69
+ * @param pattern - Complex nested ICU pattern
70
+ * @param options - Formatting options
71
+ * @returns Formatted message
72
+ */
73
+ static formatNested(pattern: string, options?: EnhancedErrorOptions): string;
74
+ /**
75
+ * Detect if a string key represents a nested path
76
+ * @param key - String key to check
77
+ * @returns Object with nesting information
78
+ */
79
+ static analyzeKeyPath(key: string): {
80
+ isNested: boolean;
81
+ depth: number;
82
+ parts: string[];
83
+ };
84
+ /**
85
+ * Create metadata object with count information for debugging
86
+ * @param count - Count value
87
+ * @param additionalMetadata - Additional metadata to include
88
+ * @returns Metadata object
89
+ */
90
+ static createCountMetadata(count: number, additionalMetadata?: Record<string, any>): Record<string, any>;
91
+ /**
92
+ * Validate that all required ICU variables are provided
93
+ * @param pattern - ICU pattern
94
+ * @param variables - Provided variables
95
+ * @returns Object with validation result
96
+ */
97
+ static validateVariables(pattern: string, variables: Record<string, any>): {
98
+ valid: boolean;
99
+ missing: string[];
100
+ };
101
+ }
102
+ /**
103
+ * Mixin function to add enhanced i18n features to error classes
104
+ * @param Base - Base error class
105
+ * @returns Enhanced error class
106
+ */
107
+ export declare function withEnhancedI18n<T extends new (...args: any[]) => Error>(Base: T): {
108
+ new (...args: any[]): {
109
+ formatMessage(pattern: string, options?: EnhancedErrorOptions): string;
110
+ formatPlural(singularPattern: string, pluralPattern: string, count: number, options?: Omit<EnhancedErrorOptions, "count">): string;
111
+ formatGender(patterns: Partial<Record<GenderCategory, string>>, gender: GenderCategory, options?: Omit<EnhancedErrorOptions, "gender">): string;
112
+ formatOrdinal(number: number, pattern: string, options?: EnhancedErrorOptions): string;
113
+ formatNumber(value: number, format: "integer" | "currency" | "percent", pattern: string, options?: EnhancedErrorOptions): string;
114
+ name: string;
115
+ message: string;
116
+ stack?: string;
117
+ cause?: unknown;
118
+ };
119
+ } & T;
120
+ //# sourceMappingURL=enhanced-error-base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enhanced-error-base.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/errors/enhanced-error-base.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,qCAAqC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;IACtD,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kCAAkC;IAClC,KAAK,C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AE,MAAM,EAAE,CAAC;KACjB;IASD;;;;;OAKG;IACH,MAAM,CAAC,mBAAmB,CACxB,KAAK,EAAE,MAAM,EACb,kBAAkB,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GAC3C,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAOtB;;;;;OAKG;IACH,MAAM,CAAC,iBAAiB,CACtB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC7B;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE;CAkBzC;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,KAAK,EACtE,IAAI,EAAE,CAAC;kBADgD,GAAG,EAAE;+BAK/C,MAAM,YACN,oBAAoB,GAC5B,MAAM;sCAKU,MAAM,iBACR,MAAM,SACd,MAAM,YACJ,IAAI,CAAC,oBAAoB,EAAE,OAAO,CAAC,GAC3C,MAAM;+BAKG,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,UACzC,cAAc,YACb,IAAI,CAAC,oBAAoB,EAAE,QAAQ,CAAC,GAC5C,MAAM;8BAKC,MAAM,WACL,MAAM,YACN,oBAAoB,GAC5B,MAAM;4BAKA,MAAM,UACL,SAAS,GAAG,UAAU,GAAG,SAAS,WACjC,MAAM,YACN,oBAAoB,GAC5B,MAAM;;;;;;MAIZ"}
@@ -0,0 +1,165 @@
1
+ "use strict";
2
+ /**
3
+ * Enhanced error base with i18n 3.0/3.5 feature support
4
+ * Provides helper methods for ICU MessageFormat, pluralization, gender, and advanced features
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.EnhancedErrorHelper = void 0;
8
+ exports.withEnhancedI18n = withEnhancedI18n;
9
+ const helpers_1 = require("../icu/helpers");
10
+ /**
11
+ * Helper class providing advanced i18n features for error messages
12
+ * This can be used as a mixin or utility class for error classes
13
+ */
14
+ class EnhancedErrorHelper {
15
+ /**
16
+ * Format error message with ICU MessageFormat
17
+ * @param pattern - ICU message pattern
18
+ * @param options - Formatting options
19
+ * @returns Formatted message string
20
+ */
21
+ static formatMessage(pattern, options = {}) {
22
+ const { variables = {}, language = 'en-US', count, gender } = options;
23
+ // Add count and gender to variables if provided
24
+ const allVars = {
25
+ ...variables,
26
+ ...(count !== undefined ? { count } : {}),
27
+ ...(gender ? { gender } : {}),
28
+ };
29
+ return (0, helpers_1.formatICUMessage)(pattern, allVars, language);
30
+ }
31
+ /**
32
+ * Create a plural-aware error message
33
+ * @param singularPattern - Pattern for singular form
34
+ * @param pluralPattern - Pattern for plural form
35
+ * @param count - Count value
36
+ * @param options - Additional formatting options
37
+ * @returns Formatted message
38
+ */
39
+ static formatPlural(singularPattern, pluralPattern, count, options = {}) {
40
+ const pattern = `{count, plural, one {${singularPattern}} other {${pluralPattern}}}`;
41
+ return this.formatMessage(pattern, { ...options, count });
42
+ }
43
+ /**
44
+ * Create a gender-aware error message
45
+ * @param patterns - Patterns for different genders
46
+ * @param gender - Gender value
47
+ * @param options - Additional formatting options
48
+ * @returns Formatted message
49
+ */
50
+ static formatGender(patterns, gender, options = {}) {
51
+ const { male, female, neutral, other } = patterns;
52
+ const selectPattern = `{gender, select, ${male ? `male {${male}}` : ''} ${female ? `female {${female}}` : ''} ${neutral ? `neutral {${neutral}}` : ''} other {${other || patterns.male || patterns.female || patterns.neutral || 'Error'}}}`;
53
+ return this.formatMessage(selectPattern, { ...options, gender });
54
+ }
55
+ /**
56
+ * Format ordinal numbers (1st, 2nd, 3rd, etc.)
57
+ * @param number - The number to format
58
+ * @param pattern - Pattern with {number} placeholder
59
+ * @param options - Additional formatting options
60
+ * @returns Formatted message with ordinal
61
+ */
62
+ static formatOrdinal(number, pattern, options = {}) {
63
+ const ordinalPattern = pattern.replace('{number}', `{number, selectordinal, one {#st} two {#nd} few {#rd} other {#th}}`);
64
+ return this.formatMessage(ordinalPattern, {
65
+ ...options,
66
+ variables: { ...options.variables, number },
67
+ });
68
+ }
69
+ /**
70
+ * Format numbers with specific formatting (integer, currency, percent)
71
+ * @param value - Number value
72
+ * @param format - Format type
73
+ * @param pattern - Pattern with {value} placeholder
74
+ * @param options - Additional formatting options
75
+ * @returns Formatted message
76
+ */
77
+ static formatNumber(value, format, pattern, options = {}) {
78
+ const numberPattern = pattern.replace('{value}', `{value, number, ${format}}`);
79
+ return this.formatMessage(numberPattern, {
80
+ ...options,
81
+ variables: { ...options.variables, value },
82
+ });
83
+ }
84
+ /**
85
+ * Create nested messages with multiple levels of ICU formatting
86
+ * @param pattern - Complex nested ICU pattern
87
+ * @param options - Formatting options
88
+ * @returns Formatted message
89
+ */
90
+ static formatNested(pattern, options = {}) {
91
+ return this.formatMessage(pattern, options);
92
+ }
93
+ /**
94
+ * Detect if a string key represents a nested path
95
+ * @param key - String key to check
96
+ * @returns Object with nesting information
97
+ */
98
+ static analyzeKeyPath(key) {
99
+ const parts = key.split('.');
100
+ return {
101
+ isNested: parts.length > 1,
102
+ depth: parts.length,
103
+ parts,
104
+ };
105
+ }
106
+ /**
107
+ * Create metadata object with count information for debugging
108
+ * @param count - Count value
109
+ * @param additionalMetadata - Additional metadata to include
110
+ * @returns Metadata object
111
+ */
112
+ static createCountMetadata(count, additionalMetadata = {}) {
113
+ return {
114
+ count,
115
+ ...additionalMetadata,
116
+ };
117
+ }
118
+ /**
119
+ * Validate that all required ICU variables are provided
120
+ * @param pattern - ICU pattern
121
+ * @param variables - Provided variables
122
+ * @returns Object with validation result
123
+ */
124
+ static validateVariables(pattern, variables) {
125
+ // Extract variable names from ICU pattern
126
+ const variableMatches = pattern.match(/\{([a-zA-Z_][a-zA-Z0-9_]*)/g);
127
+ if (!variableMatches) {
128
+ return { valid: true, missing: [] };
129
+ }
130
+ const required = variableMatches
131
+ .map(match => match.substring(1))
132
+ .filter((name, index, self) => self.indexOf(name) === index);
133
+ const missing = required.filter(name => !(name in variables));
134
+ return {
135
+ valid: missing.length === 0,
136
+ missing,
137
+ };
138
+ }
139
+ }
140
+ exports.EnhancedErrorHelper = EnhancedErrorHelper;
141
+ /**
142
+ * Mixin function to add enhanced i18n features to error classes
143
+ * @param Base - Base error class
144
+ * @returns Enhanced error class
145
+ */
146
+ function withEnhancedI18n(Base) {
147
+ return class extends Base {
148
+ formatMessage(pattern, options = {}) {
149
+ return EnhancedErrorHelper.formatMessage(pattern, options);
150
+ }
151
+ formatPlural(singularPattern, pluralPattern, count, options = {}) {
152
+ return EnhancedErrorHelper.formatPlural(singularPattern, pluralPattern, count, options);
153
+ }
154
+ formatGender(patterns, gender, options = {}) {
155
+ return EnhancedErrorHelper.formatGender(patterns, gender, options);
156
+ }
157
+ formatOrdinal(number, pattern, options = {}) {
158
+ return EnhancedErrorHelper.formatOrdinal(number, pattern, options);
159
+ }
160
+ formatNumber(value, format, pattern, options = {}) {
161
+ return EnhancedErrorHelper.formatNumber(value, format, pattern, options);
162
+ }
163
+ };
164
+ }
165
+ //# sourceMappingURL=enhanced-error-base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enhanced-error-base.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/errors/enhanced-error-base.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAmNH,4CA6CC;AA9PD,4CAAkD;AAoBlD;;;GAGG;AACH,MAAa,mBAAmB;IAC9B;;;;;OAKG;IACH,MAAM,CAAC,aAAa,CAClB,OAAe,EACf,UAAgC,EAAE;QAElC,MAAM,EAAE,SAAS,GAAG,EAAE,EAAE,QAAQ,GAAG,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAEtE,gDAAgD;QAChD,MAAM,OAAO,GAAG;YACd,GAAG,SAAS;YACZ,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAA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M,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QACrE,CAAC;QAEM,YAAY,CACjB,KAAa,EACb,MAA0C,EAC1C,OAAe,EACf,UAAgC,EAAE;YAElC,OAAO,mBAAmB,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAC3E,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -1,9 +1,45 @@
1
1
  import { IHandleable } from '../interfaces/handleable';
2
2
  import { HandleableErrorOptions } from '../interfaces/handleable-error-options';
3
3
  /**
4
- * Base error class that implements IHandleable interface.
4
+ * Base error class that implements IHandleable interface with full i18n support.
5
+ *
5
6
  * Provides enhanced error handling capabilities including status codes, handled state tracking,
6
- * and source data preservation.
7
+ * and source data preservation. Fully compatible with all i18n features when used with
8
+ * translation strings.
9
+ *
10
+ * **Supported i18n Features** (via translation strings in derived classes):
11
+ * - ICU MessageFormat: plural, select, selectordinal
12
+ * - Pluralization: 37 languages with CLDR rules
13
+ * - Gender support: male, female, neutral, other
14
+ * - Number formatting: integer, currency, percent
15
+ * - Nested messages: complex patterns
16
+ *
17
+ * **Usage Pattern:**
18
+ * ```typescript
19
+ * // Extend HandleableError with translated messages
20
+ * class MyHandleableError extends HandleableError {
21
+ * constructor(componentId: string, stringKey: string, variables?: Record<string, any>) {
22
+ * const engine = I18nEngine.getInstance();
23
+ * const message = engine.translate(componentId, stringKey, variables);
24
+ * const error = new Error(message);
25
+ * super(error, { statusCode: 400 });
26
+ * }
27
+ * }
28
+ *
29
+ * // Register translation with ICU features
30
+ * engine.registerComponent({
31
+ * component: { id: 'api', stringKeys: ['validationError'] },
32
+ * strings: {
33
+ * 'en-US': {
34
+ * validationError: \"{count, plural, one {# field is invalid} other {# fields are invalid}}\"
35
+ * }
36
+ * }
37
+ * });
38
+ *
39
+ * // Use with i18n features
40
+ * throw new MyHandleableError('api', 'validationError', { count: 3 });
41
+ * // Result: \"3 fields are invalid\"
42
+ * ```
7
43
  */
8
44
  export declare class HandleableError extends Error implements IHandleable {
9
45
  /** The original error that caused this error */
@@ -1 +1 @@
1
- {"version":3,"file":"handleable.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/errors/handleable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAShF;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,KAAM,YAAW,WAAW;IAC/D,gDAAgD;IAChD,SAAyB,KAAK,CAAC,EAAE,KAAK,CAAC;IACvC,kDAAkD;IAClD,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,gDAAgD;IAChD,SAAgB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrC,+DAA+D;IAC/D,OAAO,CAAC,QAAQ,CAAU;IAE1B;;;;OAIG;gBACS,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,sBAAsB;IAsB3D;;;OAGG;IACH,IAAW,OAAO,IAAI,OAAO,CAE5B;IAED;;;OAGG;IACH,IAAW,OAAO,CAAC,KAAK,EAAE,OAAO,EAEhC;IAED;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAuBtB;;;;OAIG;IACI,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAazC"}
1
+ {"version":3,"file":"handleable.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/errors/handleable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAShF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,qBAAa,eAAgB,SAAQ,KAAM,YAAW,WAAW;IAC/D,gDAAgD;IAChD,SAAyB,KAAK,CAAC,EAAE,KAAK,CAAC;IACvC,kDAAkD;IAClD,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,gDAAgD;IAChD,SAAgB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrC,+DAA+D;IAC/D,OAAO,CAAC,QAAQ,CAAU;IAE1B;;;;OAIG;gBACS,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,sBAAsB;IAsB3D;;;OAGG;IACH,IAAW,OAAO,IAAI,OAAO,CAE5B;IAED;;;OAGG;IACH,IAAW,OAAO,CAAC,KAAK,EAAE,OAAO,EAEhC;IAED;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAuBtB;;;;OAIG;IACI,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAazC"}