@digitaldefiance/i18n-lib 3.8.2 → 3.8.4
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/package.json +8 -7
- package/src/{active-context.ts → active-context.d.ts} +1 -0
- package/src/active-context.d.ts.map +1 -0
- package/src/active-context.js +3 -0
- package/src/active-context.js.map +1 -0
- package/src/builders/i18n-builder.d.ts +26 -0
- package/src/builders/i18n-builder.d.ts.map +1 -0
- package/src/builders/i18n-builder.js +70 -0
- package/src/builders/i18n-builder.js.map +1 -0
- package/src/builders/{index.ts → index.d.ts} +1 -1
- package/src/builders/index.d.ts.map +1 -0
- package/src/builders/index.js +8 -0
- package/src/builders/index.js.map +1 -0
- package/src/component-definition.d.ts +12 -0
- package/src/component-definition.d.ts.map +1 -0
- package/src/component-definition.js +3 -0
- package/src/component-definition.js.map +1 -0
- package/src/component-registration.d.ts +22 -0
- package/src/component-registration.d.ts.map +1 -0
- package/src/component-registration.js +3 -0
- package/src/component-registration.js.map +1 -0
- package/src/component-registry.d.ts +102 -0
- package/src/component-registry.d.ts.map +1 -0
- package/src/component-registry.js +282 -0
- package/src/component-registry.js.map +1 -0
- package/src/context-error-type.d.ts +8 -0
- package/src/context-error-type.d.ts.map +1 -0
- package/src/context-error-type.js +12 -0
- package/src/context-error-type.js.map +1 -0
- package/src/core/component-store.d.ts +93 -0
- package/src/core/component-store.d.ts.map +1 -0
- package/src/core/component-store.js +198 -0
- package/src/core/component-store.js.map +1 -0
- package/src/core/context-manager.d.ts +72 -0
- package/src/core/context-manager.d.ts.map +1 -0
- package/src/core/context-manager.js +98 -0
- package/src/core/context-manager.js.map +1 -0
- package/src/core/enum-registry.d.ts +48 -0
- package/src/core/enum-registry.d.ts.map +1 -0
- package/src/core/enum-registry.js +85 -0
- package/src/core/enum-registry.js.map +1 -0
- package/src/core/i18n-engine.d.ts +241 -0
- package/src/core/i18n-engine.d.ts.map +1 -0
- package/src/core/i18n-engine.js +568 -0
- package/src/core/i18n-engine.js.map +1 -0
- package/src/core/{index.ts → index.d.ts} +1 -4
- package/src/core/index.d.ts.map +1 -0
- package/src/core/index.js +21 -0
- package/src/core/index.js.map +1 -0
- package/src/core/language-registry.d.ts +180 -0
- package/src/core/language-registry.d.ts.map +1 -0
- package/src/core/language-registry.js +298 -0
- package/src/core/language-registry.js.map +1 -0
- package/src/{core-component-id.ts → core-component-id.d.ts} +2 -1
- package/src/core-component-id.d.ts.map +1 -0
- package/src/core-component-id.js +9 -0
- package/src/core-component-id.js.map +1 -0
- package/src/core-i18n.d.ts +69 -0
- package/src/core-i18n.d.ts.map +1 -0
- package/src/core-i18n.js +219 -0
- package/src/core-i18n.js.map +1 -0
- package/src/core-plugin-factory.d.ts +28 -0
- package/src/core-plugin-factory.d.ts.map +1 -0
- package/src/core-plugin-factory.js +80 -0
- package/src/core-plugin-factory.js.map +1 -0
- package/src/core-string-key.d.ts +52 -0
- package/src/core-string-key.d.ts.map +1 -0
- package/src/core-string-key.js +61 -0
- package/src/core-string-key.js.map +1 -0
- package/src/create-translation-adapter.d.ts +33 -0
- package/src/create-translation-adapter.d.ts.map +1 -0
- package/src/create-translation-adapter.js +72 -0
- package/src/create-translation-adapter.js.map +1 -0
- package/src/enum-registry.d.ts +65 -0
- package/src/enum-registry.d.ts.map +1 -0
- package/src/enum-registry.js +123 -0
- package/src/enum-registry.js.map +1 -0
- package/src/errors/{base.ts → base.d.ts} +1 -1
- package/src/errors/base.d.ts.map +1 -0
- package/src/errors/base.js +11 -0
- package/src/errors/base.js.map +1 -0
- package/src/errors/context-error.d.ts +50 -0
- package/src/errors/context-error.d.ts.map +1 -0
- package/src/errors/context-error.js +93 -0
- package/src/errors/context-error.js.map +1 -0
- package/src/errors/enhanced-error-base.d.ts +125 -0
- package/src/errors/enhanced-error-base.d.ts.map +1 -0
- package/src/errors/enhanced-error-base.js +165 -0
- package/src/errors/enhanced-error-base.js.map +1 -0
- package/src/errors/handleable.d.ts +83 -0
- package/src/errors/handleable.d.ts.map +1 -0
- package/src/errors/handleable.js +136 -0
- package/src/errors/handleable.js.map +1 -0
- package/src/errors/i18n-error.d.ts +211 -0
- package/src/errors/i18n-error.d.ts.map +1 -0
- package/src/errors/i18n-error.js +358 -0
- package/src/errors/i18n-error.js.map +1 -0
- package/src/errors/{index.ts → index.d.ts} +1 -4
- package/src/errors/index.d.ts.map +1 -0
- package/src/errors/index.js +17 -0
- package/src/errors/index.js.map +1 -0
- package/src/errors/simple-typed-error.d.ts +53 -0
- package/src/errors/simple-typed-error.d.ts.map +1 -0
- package/src/errors/simple-typed-error.js +51 -0
- package/src/errors/simple-typed-error.js.map +1 -0
- package/src/errors/{translatable-exports.ts → translatable-exports.d.ts} +1 -1
- package/src/errors/translatable-exports.d.ts.map +1 -0
- package/src/errors/translatable-exports.js +15 -0
- package/src/errors/translatable-exports.js.map +1 -0
- package/src/errors/translatable-generic.d.ts +87 -0
- package/src/errors/translatable-generic.d.ts.map +1 -0
- package/src/errors/translatable-generic.js +139 -0
- package/src/errors/translatable-generic.js.map +1 -0
- package/src/errors/translatable-handleable-generic.d.ts +116 -0
- package/src/errors/translatable-handleable-generic.d.ts.map +1 -0
- package/src/errors/translatable-handleable-generic.js +121 -0
- package/src/errors/translatable-handleable-generic.js.map +1 -0
- package/src/errors/translatable.d.ts +63 -0
- package/src/errors/translatable.d.ts.map +1 -0
- package/src/errors/translatable.js +85 -0
- package/src/errors/translatable.js.map +1 -0
- package/src/errors/typed-handleable.d.ts +62 -0
- package/src/errors/typed-handleable.d.ts.map +1 -0
- package/src/errors/typed-handleable.js +108 -0
- package/src/errors/typed-handleable.js.map +1 -0
- package/src/errors/typed.d.ts +206 -0
- package/src/errors/typed.d.ts.map +1 -0
- package/src/errors/typed.js +458 -0
- package/src/errors/typed.js.map +1 -0
- package/src/gender/{gender-categories.ts → gender-categories.d.ts} +2 -6
- package/src/gender/gender-categories.d.ts.map +1 -0
- package/src/gender/gender-categories.js +15 -0
- package/src/gender/gender-categories.js.map +1 -0
- package/src/gender/gender-resolver.d.ts +14 -0
- package/src/gender/gender-resolver.d.ts.map +1 -0
- package/src/gender/gender-resolver.js +35 -0
- package/src/gender/gender-resolver.js.map +1 -0
- package/src/gender/{index.ts → index.d.ts} +1 -0
- package/src/gender/index.d.ts.map +1 -0
- package/src/gender/index.js +6 -0
- package/src/gender/index.js.map +1 -0
- package/src/global-active-context.d.ts +50 -0
- package/src/global-active-context.d.ts.map +1 -0
- package/src/global-active-context.js +185 -0
- package/src/global-active-context.js.map +1 -0
- package/src/icu/ast.d.ts +48 -0
- package/src/icu/ast.d.ts.map +1 -0
- package/src/icu/ast.js +16 -0
- package/src/icu/ast.js.map +1 -0
- package/src/icu/compiler.d.ts +16 -0
- package/src/icu/compiler.d.ts.map +1 -0
- package/src/icu/compiler.js +87 -0
- package/src/icu/compiler.js.map +1 -0
- package/src/icu/formatter-registry.d.ts +10 -0
- package/src/icu/formatter-registry.d.ts.map +1 -0
- package/src/icu/formatter-registry.js +34 -0
- package/src/icu/formatter-registry.js.map +1 -0
- package/src/icu/formatters/base-formatter.d.ts +8 -0
- package/src/icu/formatters/base-formatter.d.ts.map +1 -0
- package/src/icu/formatters/base-formatter.js +3 -0
- package/src/icu/formatters/base-formatter.js.map +1 -0
- package/src/icu/formatters/date-formatter.d.ts +5 -0
- package/src/icu/formatters/date-formatter.d.ts.map +1 -0
- package/src/icu/formatters/date-formatter.js +31 -0
- package/src/icu/formatters/date-formatter.js.map +1 -0
- package/src/icu/formatters/number-formatter.d.ts +5 -0
- package/src/icu/formatters/number-formatter.d.ts.map +1 -0
- package/src/icu/formatters/number-formatter.js +33 -0
- package/src/icu/formatters/number-formatter.js.map +1 -0
- package/src/icu/formatters/plural-formatter.d.ts +5 -0
- package/src/icu/formatters/plural-formatter.d.ts.map +1 -0
- package/src/icu/formatters/plural-formatter.js +15 -0
- package/src/icu/formatters/plural-formatter.js.map +1 -0
- package/src/icu/formatters/select-formatter.d.ts +5 -0
- package/src/icu/formatters/select-formatter.d.ts.map +1 -0
- package/src/icu/formatters/select-formatter.js +10 -0
- package/src/icu/formatters/select-formatter.js.map +1 -0
- package/src/icu/formatters/selectordinal-formatter.d.ts +5 -0
- package/src/icu/formatters/selectordinal-formatter.d.ts.map +1 -0
- package/src/icu/formatters/selectordinal-formatter.js +22 -0
- package/src/icu/formatters/selectordinal-formatter.js.map +1 -0
- package/src/icu/formatters/time-formatter.d.ts +5 -0
- package/src/icu/formatters/time-formatter.d.ts.map +1 -0
- package/src/icu/formatters/time-formatter.js +31 -0
- package/src/icu/formatters/time-formatter.js.map +1 -0
- package/src/icu/helpers.d.ts +9 -0
- package/src/icu/helpers.d.ts.map +1 -0
- package/src/icu/helpers.js +31 -0
- package/src/icu/helpers.js.map +1 -0
- package/src/icu/parser.d.ts +31 -0
- package/src/icu/parser.d.ts.map +1 -0
- package/src/icu/parser.js +203 -0
- package/src/icu/parser.js.map +1 -0
- package/src/icu/runtime.d.ts +10 -0
- package/src/icu/runtime.d.ts.map +1 -0
- package/src/icu/runtime.js +33 -0
- package/src/icu/runtime.js.map +1 -0
- package/src/icu/tokenizer.d.ts +37 -0
- package/src/icu/tokenizer.d.ts.map +1 -0
- package/src/icu/tokenizer.js +187 -0
- package/src/icu/tokenizer.js.map +1 -0
- package/src/icu/validator.d.ts +11 -0
- package/src/icu/validator.d.ts.map +1 -0
- package/src/icu/validator.js +140 -0
- package/src/icu/validator.js.map +1 -0
- package/src/{index.ts → index.d.ts} +6 -38
- package/src/index.d.ts.map +1 -0
- package/src/index.js +76 -0
- package/src/index.js.map +1 -0
- package/src/interfaces/active-context.interface.d.ts +36 -0
- package/src/interfaces/active-context.interface.d.ts.map +1 -0
- package/src/interfaces/active-context.interface.js +3 -0
- package/src/interfaces/active-context.interface.js.map +1 -0
- package/src/interfaces/component-config.interface.d.ts +16 -0
- package/src/interfaces/component-config.interface.d.ts.map +1 -0
- package/src/interfaces/component-config.interface.js +6 -0
- package/src/interfaces/component-config.interface.js.map +1 -0
- package/src/interfaces/engine-config.interface.d.ts +22 -0
- package/src/interfaces/engine-config.interface.d.ts.map +1 -0
- package/src/interfaces/engine-config.interface.js +6 -0
- package/src/interfaces/engine-config.interface.js.map +1 -0
- package/src/interfaces/global-active-context.d.ts +23 -0
- package/src/interfaces/global-active-context.d.ts.map +1 -0
- package/src/interfaces/global-active-context.js +3 -0
- package/src/interfaces/global-active-context.js.map +1 -0
- package/src/interfaces/handleable-error-options.d.ts +14 -0
- package/src/interfaces/handleable-error-options.d.ts.map +1 -0
- package/src/interfaces/handleable-error-options.js +3 -0
- package/src/interfaces/handleable-error-options.js.map +1 -0
- package/src/interfaces/handleable.d.ts +21 -0
- package/src/interfaces/handleable.d.ts.map +1 -0
- package/src/interfaces/handleable.js +3 -0
- package/src/interfaces/handleable.js.map +1 -0
- package/src/interfaces/i18n-engine.interface.d.ts +46 -0
- package/src/interfaces/i18n-engine.interface.d.ts.map +1 -0
- package/src/interfaces/i18n-engine.interface.js +6 -0
- package/src/interfaces/i18n-engine.interface.js.map +1 -0
- package/src/interfaces/{index.ts → index.d.ts} +1 -1
- package/src/interfaces/index.d.ts.map +1 -0
- package/src/interfaces/index.js +7 -0
- package/src/interfaces/index.js.map +1 -0
- package/src/interfaces/language-definition.interface.d.ts +17 -0
- package/src/interfaces/language-definition.interface.d.ts.map +1 -0
- package/src/interfaces/language-definition.interface.js +6 -0
- package/src/interfaces/language-definition.interface.js.map +1 -0
- package/src/interfaces/translation-options.interface.d.ts +15 -0
- package/src/interfaces/translation-options.interface.d.ts.map +1 -0
- package/src/interfaces/translation-options.interface.js +6 -0
- package/src/interfaces/translation-options.interface.js.map +1 -0
- package/src/interfaces/validation-result.interface.d.ts +24 -0
- package/src/interfaces/validation-result.interface.d.ts.map +1 -0
- package/src/interfaces/validation-result.interface.js +6 -0
- package/src/interfaces/validation-result.interface.js.map +1 -0
- package/src/language-codes.d.ts +28 -0
- package/src/language-codes.d.ts.map +1 -0
- package/src/language-codes.js +32 -0
- package/src/language-codes.js.map +1 -0
- package/src/language-definition.d.ts +14 -0
- package/src/language-definition.d.ts.map +1 -0
- package/src/language-definition.js +3 -0
- package/src/language-definition.js.map +1 -0
- package/src/plugin-i18n-engine.d.ts +164 -0
- package/src/plugin-i18n-engine.d.ts.map +1 -0
- package/src/plugin-i18n-engine.js +493 -0
- package/src/plugin-i18n-engine.js.map +1 -0
- package/src/pluralization/{index.ts → index.d.ts} +1 -1
- package/src/pluralization/index.d.ts.map +1 -0
- package/src/pluralization/index.js +10 -0
- package/src/pluralization/index.js.map +1 -0
- package/src/pluralization/language-plural-map.d.ts +29 -0
- package/src/pluralization/language-plural-map.d.ts.map +1 -0
- package/src/pluralization/language-plural-map.js +155 -0
- package/src/pluralization/language-plural-map.js.map +1 -0
- package/src/pluralization/{plural-categories.ts → plural-categories.d.ts} +3 -5
- package/src/pluralization/plural-categories.d.ts.map +1 -0
- package/src/pluralization/plural-categories.js +8 -0
- package/src/pluralization/plural-categories.js.map +1 -0
- package/src/pluralization/plural-rules.d.ts +102 -0
- package/src/pluralization/plural-rules.d.ts.map +1 -0
- package/src/pluralization/plural-rules.js +263 -0
- package/src/pluralization/plural-rules.js.map +1 -0
- package/src/registry-config.d.ts +16 -0
- package/src/registry-config.d.ts.map +1 -0
- package/src/registry-config.js +3 -0
- package/src/registry-config.js.map +1 -0
- package/src/registry-error-type.d.ts +20 -0
- package/src/registry-error-type.d.ts.map +1 -0
- package/src/registry-error-type.js +24 -0
- package/src/registry-error-type.js.map +1 -0
- package/src/registry-error.d.ts +25 -0
- package/src/registry-error.d.ts.map +1 -0
- package/src/registry-error.js +63 -0
- package/src/registry-error.js.map +1 -0
- package/src/strict-types.d.ts +19 -0
- package/src/strict-types.d.ts.map +1 -0
- package/src/strict-types.js +18 -0
- package/src/strict-types.js.map +1 -0
- package/src/strings/de.d.ts +3 -0
- package/src/strings/de.d.ts.map +1 -0
- package/src/strings/de.js +57 -0
- package/src/strings/de.js.map +1 -0
- package/src/strings/en-GB.d.ts +3 -0
- package/src/strings/en-GB.d.ts.map +1 -0
- package/src/strings/en-GB.js +57 -0
- package/src/strings/en-GB.js.map +1 -0
- package/src/strings/en-US.d.ts +3 -0
- package/src/strings/en-US.d.ts.map +1 -0
- package/src/strings/en-US.js +57 -0
- package/src/strings/en-US.js.map +1 -0
- package/src/strings/es.d.ts +3 -0
- package/src/strings/es.d.ts.map +1 -0
- package/src/strings/es.js +57 -0
- package/src/strings/es.js.map +1 -0
- package/src/strings/fr.d.ts +3 -0
- package/src/strings/fr.d.ts.map +1 -0
- package/src/strings/fr.js +57 -0
- package/src/strings/fr.js.map +1 -0
- package/src/strings/ja.d.ts +3 -0
- package/src/strings/ja.d.ts.map +1 -0
- package/src/strings/ja.js +57 -0
- package/src/strings/ja.js.map +1 -0
- package/src/strings/uk.d.ts +3 -0
- package/src/strings/uk.d.ts.map +1 -0
- package/src/strings/uk.js +57 -0
- package/src/strings/uk.js.map +1 -0
- package/src/strings/zh-CN.d.ts +3 -0
- package/src/strings/zh-CN.d.ts.map +1 -0
- package/src/strings/zh-CN.js +57 -0
- package/src/strings/zh-CN.js.map +1 -0
- package/src/template.d.ts +13 -0
- package/src/template.d.ts.map +1 -0
- package/src/template.js +40 -0
- package/src/template.js.map +1 -0
- package/src/translation-engine.d.ts +9 -0
- package/src/translation-engine.d.ts.map +1 -0
- package/src/translation-engine.js +3 -0
- package/src/translation-engine.js.map +1 -0
- package/src/translation-request.d.ts +10 -0
- package/src/translation-request.d.ts.map +1 -0
- package/src/translation-request.js +3 -0
- package/src/translation-request.js.map +1 -0
- package/src/translation-response.d.ts +9 -0
- package/src/translation-response.d.ts.map +1 -0
- package/src/translation-response.js +3 -0
- package/src/translation-response.js.map +1 -0
- package/src/types/engine.d.ts +47 -0
- package/src/types/engine.d.ts.map +1 -0
- package/src/types/engine.js +8 -0
- package/src/types/engine.js.map +1 -0
- package/src/types/{index.ts → index.d.ts} +1 -1
- package/src/types/index.d.ts.map +1 -0
- package/src/types/index.js +9 -0
- package/src/types/index.js.map +1 -0
- package/src/types/{plural-types.ts → plural-types.d.ts} +3 -29
- package/src/types/plural-types.d.ts.map +1 -0
- package/src/types/plural-types.js +39 -0
- package/src/types/plural-types.js.map +1 -0
- package/src/{types.ts → types.d.ts} +21 -72
- package/src/types.d.ts.map +1 -0
- package/src/types.js +23 -0
- package/src/types.js.map +1 -0
- package/src/utils/currency.d.ts +81 -0
- package/src/utils/currency.d.ts.map +1 -0
- package/src/utils/currency.js +99 -0
- package/src/utils/currency.js.map +1 -0
- package/src/utils/html-escape.d.ts +22 -0
- package/src/utils/html-escape.d.ts.map +1 -0
- package/src/utils/html-escape.js +53 -0
- package/src/utils/html-escape.js.map +1 -0
- package/src/utils/{index.ts → index.d.ts} +1 -0
- package/src/utils/index.d.ts.map +1 -0
- package/src/utils/index.js +12 -0
- package/src/utils/index.js.map +1 -0
- package/src/utils/lru-cache.d.ts +42 -0
- package/src/utils/lru-cache.d.ts.map +1 -0
- package/src/utils/lru-cache.js +73 -0
- package/src/utils/lru-cache.js.map +1 -0
- package/src/utils/{plural-helpers.ts → plural-helpers.d.ts} +4 -14
- package/src/utils/plural-helpers.d.ts.map +1 -0
- package/src/utils/plural-helpers.js +35 -0
- package/src/utils/plural-helpers.js.map +1 -0
- package/src/utils/safe-object.d.ts +39 -0
- package/src/utils/safe-object.d.ts.map +1 -0
- package/src/utils/{safe-object.ts → safe-object.js} +34 -37
- package/src/utils/safe-object.js.map +1 -0
- package/src/utils/string-utils.d.ts +28 -0
- package/src/utils/string-utils.d.ts.map +1 -0
- package/src/utils/string-utils.js +63 -0
- package/src/utils/string-utils.js.map +1 -0
- package/src/utils/timezone.d.ts +50 -0
- package/src/utils/timezone.d.ts.map +1 -0
- package/src/utils/timezone.js +74 -0
- package/src/utils/timezone.js.map +1 -0
- package/src/utils/validation.d.ts +40 -0
- package/src/utils/validation.d.ts.map +1 -0
- package/src/utils/validation.js +69 -0
- package/src/utils/validation.js.map +1 -0
- package/src/utils.d.ts +65 -0
- package/src/utils.d.ts.map +1 -0
- package/src/utils.js +129 -0
- package/src/utils.js.map +1 -0
- package/src/validation/{index.ts → index.d.ts} +1 -0
- package/src/validation/index.d.ts.map +1 -0
- package/src/validation/index.js +5 -0
- package/src/validation/index.js.map +1 -0
- package/src/validation/plural-validator.d.ts +46 -0
- package/src/validation/plural-validator.d.ts.map +1 -0
- package/src/validation/plural-validator.js +123 -0
- package/src/validation/plural-validator.js.map +1 -0
- package/src/validation-config.d.ts +12 -0
- package/src/validation-config.d.ts.map +1 -0
- package/src/validation-config.js +3 -0
- package/src/validation-config.js.map +1 -0
- package/src/validation-result.d.ts +13 -0
- package/src/validation-result.d.ts.map +1 -0
- package/src/validation-result.js +3 -0
- package/src/validation-result.js.map +1 -0
- package/LICENSE +0 -21
- package/src/builders/i18n-builder.ts +0 -82
- package/src/component-definition.ts +0 -11
- package/src/component-registration.ts +0 -29
- package/src/component-registry.ts +0 -432
- package/src/context-error-type.ts +0 -7
- package/src/core/component-store.ts +0 -241
- package/src/core/context-manager.ts +0 -113
- package/src/core/enum-registry.ts +0 -106
- package/src/core/i18n-engine.ts +0 -710
- package/src/core/language-registry.ts +0 -345
- package/src/core-i18n.ts +0 -270
- package/src/core-plugin-factory.ts +0 -111
- package/src/core-string-key.ts +0 -59
- package/src/create-translation-adapter.ts +0 -93
- package/src/enum-registry.ts +0 -152
- package/src/errors/context-error.ts +0 -122
- package/src/errors/enhanced-error-base.ts +0 -260
- package/src/errors/handleable.ts +0 -152
- package/src/errors/i18n-error.ts +0 -494
- package/src/errors/simple-typed-error.ts +0 -81
- package/src/errors/translatable-generic.ts +0 -245
- package/src/errors/translatable-handleable-generic.ts +0 -222
- package/src/errors/translatable.ts +0 -138
- package/src/errors/typed-handleable.ts +0 -138
- package/src/errors/typed.ts +0 -617
- package/src/gender/gender-resolver.ts +0 -40
- package/src/global-active-context.ts +0 -266
- package/src/icu/ast.ts +0 -56
- package/src/icu/compiler.ts +0 -96
- package/src/icu/formatter-registry.ts +0 -36
- package/src/icu/formatters/base-formatter.ts +0 -8
- package/src/icu/formatters/date-formatter.ts +0 -30
- package/src/icu/formatters/number-formatter.ts +0 -32
- package/src/icu/formatters/plural-formatter.ts +0 -12
- package/src/icu/formatters/select-formatter.ts +0 -7
- package/src/icu/formatters/selectordinal-formatter.ts +0 -17
- package/src/icu/formatters/time-formatter.ts +0 -30
- package/src/icu/helpers.ts +0 -34
- package/src/icu/parser.ts +0 -242
- package/src/icu/runtime.ts +0 -37
- package/src/icu/tokenizer.ts +0 -212
- package/src/icu/validator.ts +0 -163
- package/src/interfaces/active-context.interface.ts +0 -41
- package/src/interfaces/component-config.interface.ts +0 -17
- package/src/interfaces/engine-config.interface.ts +0 -22
- package/src/interfaces/global-active-context.ts +0 -39
- package/src/interfaces/handleable-error-options.ts +0 -13
- package/src/interfaces/handleable.ts +0 -20
- package/src/interfaces/i18n-engine.interface.ts +0 -57
- package/src/interfaces/language-definition.interface.ts +0 -17
- package/src/interfaces/translation-options.interface.ts +0 -15
- package/src/interfaces/validation-result.interface.ts +0 -24
- package/src/language-codes.ts +0 -40
- package/src/language-definition.ts +0 -13
- package/src/plugin-i18n-engine.ts +0 -707
- package/src/pluralization/language-plural-map.ts +0 -186
- package/src/pluralization/plural-rules.ts +0 -228
- package/src/registry-config.ts +0 -16
- package/src/registry-error-type.ts +0 -19
- package/src/registry-error.ts +0 -100
- package/src/strict-types.ts +0 -35
- package/src/strings/de.ts +0 -75
- package/src/strings/en-GB.ts +0 -74
- package/src/strings/en-US.ts +0 -74
- package/src/strings/es.ts +0 -74
- package/src/strings/fr.ts +0 -75
- package/src/strings/ja.ts +0 -73
- package/src/strings/uk.ts +0 -73
- package/src/strings/zh-CN.ts +0 -72
- package/src/template.ts +0 -72
- package/src/translation-engine.ts +0 -18
- package/src/translation-request.ts +0 -12
- package/src/translation-response.ts +0 -8
- package/src/types/engine.ts +0 -55
- package/src/utils/currency.ts +0 -141
- package/src/utils/html-escape.ts +0 -55
- package/src/utils/lru-cache.ts +0 -76
- package/src/utils/string-utils.ts +0 -77
- package/src/utils/timezone.ts +0 -76
- package/src/utils/validation.ts +0 -66
- package/src/utils.ts +0 -215
- package/src/validation/plural-validator.ts +0 -168
- package/src/validation-config.ts +0 -11
- package/src/validation-result.ts +0 -12
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
import { I18nEngine } from '../core/i18n-engine';
|
|
2
|
-
import { GenderCategory } from '../gender/gender-categories';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Generic translatable error that works with any plugin engine and component.
|
|
6
|
-
*
|
|
7
|
-
* Uses lazy initialization to avoid circular dependencies with core modules.
|
|
8
|
-
* The I18nEngine is only accessed when the error is constructed, not at module load time.
|
|
9
|
-
*
|
|
10
|
-
* **Full i18n 3.0/3.5 Feature Support:**
|
|
11
|
-
* - ICU MessageFormat (all formatters: plural, select, selectordinal)
|
|
12
|
-
* - Pluralization for 37 languages with CLDR rules
|
|
13
|
-
* - Gender-aware translations (male, female, neutral, other)
|
|
14
|
-
* - Number formatting (integer, currency, percent)
|
|
15
|
-
* - Date/Time formatting (short, medium, long, full)
|
|
16
|
-
* - Nested messages up to 4 levels deep
|
|
17
|
-
* - Context variable injection
|
|
18
|
-
*
|
|
19
|
-
* **Usage Examples:**
|
|
20
|
-
* ```typescript
|
|
21
|
-
* // Plural-aware error
|
|
22
|
-
* new TranslatableGenericError('component', 'errorKey', { count: 5 });
|
|
23
|
-
* // Translation: \"{count, plural, one {# error} other {# errors}}\"
|
|
24
|
-
*
|
|
25
|
-
* // Gender-aware error
|
|
26
|
-
* new TranslatableGenericError('component', 'userError', { gender: 'female', name: 'Alice' });
|
|
27
|
-
* // Translation: \"{gender, select, male {He} female {She}} {name} caused an error\"
|
|
28
|
-
*
|
|
29
|
-
* // Number formatting
|
|
30
|
-
* new TranslatableGenericError('component', 'thresholdError', { value: 1500.50, limit: 1000 });
|
|
31
|
-
* // Translation: \"Value {value, number, currency} exceeds {limit, number, currency}\"
|
|
32
|
-
*
|
|
33
|
-
* // SelectOrdinal
|
|
34
|
-
* new TranslatableGenericError('component', 'stepError', { step: 3 });
|
|
35
|
-
* // Translation: \"Failed at {step, selectordinal, one {#st} two {#nd} few {#rd} other {#th}} step\"
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
export class TranslatableGenericError<
|
|
39
|
-
TStringKey extends string = string,
|
|
40
|
-
> extends Error {
|
|
41
|
-
public readonly stringKey: TStringKey;
|
|
42
|
-
public override readonly componentId: string;
|
|
43
|
-
public readonly language?: string;
|
|
44
|
-
public readonly variables?: Record<string, string | number>;
|
|
45
|
-
public override readonly metadata?: Record<string, any>;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Create a translatable error
|
|
49
|
-
* @param componentId - The component ID to translate from
|
|
50
|
-
* @param stringKey - The translation key
|
|
51
|
-
* @param variables - Variables for interpolation
|
|
52
|
-
* @param language - Optional language override
|
|
53
|
-
* @param metadata - Additional error metadata
|
|
54
|
-
* @param instanceKey - Optional engine instance key
|
|
55
|
-
*/
|
|
56
|
-
constructor(
|
|
57
|
-
componentId: string,
|
|
58
|
-
stringKey: TStringKey,
|
|
59
|
-
variables?: Record<string, string | number>,
|
|
60
|
-
language?: string,
|
|
61
|
-
metadata?: Record<string, any>,
|
|
62
|
-
instanceKey?: string,
|
|
63
|
-
) {
|
|
64
|
-
// Lazy initialization: getInstance() is only called when error is constructed
|
|
65
|
-
let translatedMessage: string;
|
|
66
|
-
try {
|
|
67
|
-
const engine = I18nEngine.getInstance(instanceKey);
|
|
68
|
-
translatedMessage = engine.safeTranslate(
|
|
69
|
-
componentId,
|
|
70
|
-
stringKey,
|
|
71
|
-
variables,
|
|
72
|
-
language,
|
|
73
|
-
);
|
|
74
|
-
} catch (error) {
|
|
75
|
-
// Fallback if engine not found - TranslatableGenericError is designed to be flexible
|
|
76
|
-
translatedMessage = `[${componentId}.${stringKey}]`;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
super(translatedMessage);
|
|
80
|
-
this.name = 'TranslatableGenericError';
|
|
81
|
-
this.stringKey = stringKey;
|
|
82
|
-
this.componentId = componentId;
|
|
83
|
-
this.language = language;
|
|
84
|
-
this.variables = variables;
|
|
85
|
-
this.metadata = metadata;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Create error with explicit engine instance
|
|
90
|
-
*/
|
|
91
|
-
static withEngine<TStringKey extends string>(
|
|
92
|
-
engine: I18nEngine,
|
|
93
|
-
componentId: string,
|
|
94
|
-
stringKey: TStringKey,
|
|
95
|
-
variables?: Record<string, string | number>,
|
|
96
|
-
language?: string,
|
|
97
|
-
metadata?: Record<string, any>,
|
|
98
|
-
): TranslatableGenericError<TStringKey> {
|
|
99
|
-
const translatedMessage = engine.safeTranslate(
|
|
100
|
-
componentId,
|
|
101
|
-
stringKey,
|
|
102
|
-
variables,
|
|
103
|
-
language,
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
const error = Object.create(TranslatableGenericError.prototype);
|
|
107
|
-
Error.call(error, translatedMessage);
|
|
108
|
-
error.name = 'TranslatableGenericError';
|
|
109
|
-
error.stringKey = stringKey;
|
|
110
|
-
error.componentId = componentId;
|
|
111
|
-
error.language = language;
|
|
112
|
-
error.variables = variables;
|
|
113
|
-
error.metadata = metadata;
|
|
114
|
-
error.message = translatedMessage;
|
|
115
|
-
|
|
116
|
-
return error;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Retranslate the error message in a different language
|
|
121
|
-
*/
|
|
122
|
-
retranslate(language: string, instanceKey?: string): string {
|
|
123
|
-
try {
|
|
124
|
-
const engine = I18nEngine.getInstance(instanceKey);
|
|
125
|
-
return engine.safeTranslate(
|
|
126
|
-
this.componentId,
|
|
127
|
-
this.stringKey,
|
|
128
|
-
this.variables,
|
|
129
|
-
language,
|
|
130
|
-
);
|
|
131
|
-
} catch (error) {
|
|
132
|
-
// Fallback if engine not found
|
|
133
|
-
return `[${this.componentId}.${this.stringKey}]`;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Create error with plural count
|
|
139
|
-
* Translation string should use ICU plural format
|
|
140
|
-
*/
|
|
141
|
-
static withCount<TStringKey extends string>(
|
|
142
|
-
componentId: string,
|
|
143
|
-
stringKey: TStringKey,
|
|
144
|
-
count: number,
|
|
145
|
-
otherVars?: Record<string, string | number>,
|
|
146
|
-
language?: string,
|
|
147
|
-
instanceKey?: string,
|
|
148
|
-
): TranslatableGenericError<TStringKey> {
|
|
149
|
-
return new TranslatableGenericError(
|
|
150
|
-
componentId,
|
|
151
|
-
stringKey,
|
|
152
|
-
{ ...otherVars, count },
|
|
153
|
-
language,
|
|
154
|
-
undefined,
|
|
155
|
-
instanceKey,
|
|
156
|
-
);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Create error with gender context
|
|
161
|
-
* Translation string should use ICU select format
|
|
162
|
-
*/
|
|
163
|
-
static withGender<TStringKey extends string>(
|
|
164
|
-
componentId: string,
|
|
165
|
-
stringKey: TStringKey,
|
|
166
|
-
gender: GenderCategory,
|
|
167
|
-
otherVars?: Record<string, string | number>,
|
|
168
|
-
language?: string,
|
|
169
|
-
instanceKey?: string,
|
|
170
|
-
): TranslatableGenericError<TStringKey> {
|
|
171
|
-
return new TranslatableGenericError(
|
|
172
|
-
componentId,
|
|
173
|
-
stringKey,
|
|
174
|
-
{ ...otherVars, gender },
|
|
175
|
-
language,
|
|
176
|
-
undefined,
|
|
177
|
-
instanceKey,
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Create error with ordinal number
|
|
183
|
-
* Translation string should use ICU selectordinal format
|
|
184
|
-
*/
|
|
185
|
-
static withOrdinal<TStringKey extends string>(
|
|
186
|
-
componentId: string,
|
|
187
|
-
stringKey: TStringKey,
|
|
188
|
-
ordinalNumber: number,
|
|
189
|
-
otherVars?: Record<string, string | number>,
|
|
190
|
-
language?: string,
|
|
191
|
-
instanceKey?: string,
|
|
192
|
-
): TranslatableGenericError<TStringKey> {
|
|
193
|
-
return new TranslatableGenericError(
|
|
194
|
-
componentId,
|
|
195
|
-
stringKey,
|
|
196
|
-
{ ...otherVars, ordinalNumber },
|
|
197
|
-
language,
|
|
198
|
-
undefined,
|
|
199
|
-
instanceKey,
|
|
200
|
-
);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Create error with number formatting
|
|
205
|
-
* Translation string should use ICU number format
|
|
206
|
-
*/
|
|
207
|
-
static withNumberFormat<TStringKey extends string>(
|
|
208
|
-
componentId: string,
|
|
209
|
-
stringKey: TStringKey,
|
|
210
|
-
value: number,
|
|
211
|
-
otherVars?: Record<string, string | number>,
|
|
212
|
-
language?: string,
|
|
213
|
-
instanceKey?: string,
|
|
214
|
-
): TranslatableGenericError<TStringKey> {
|
|
215
|
-
return new TranslatableGenericError(
|
|
216
|
-
componentId,
|
|
217
|
-
stringKey,
|
|
218
|
-
{ ...otherVars, value },
|
|
219
|
-
language,
|
|
220
|
-
undefined,
|
|
221
|
-
instanceKey,
|
|
222
|
-
);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Create error with multiple i18n features combined
|
|
227
|
-
* Translation string can use nested ICU messages
|
|
228
|
-
*/
|
|
229
|
-
static withMultipleFeatures<TStringKey extends string>(
|
|
230
|
-
componentId: string,
|
|
231
|
-
stringKey: TStringKey,
|
|
232
|
-
features: Record<string, string | number>,
|
|
233
|
-
language?: string,
|
|
234
|
-
instanceKey?: string,
|
|
235
|
-
): TranslatableGenericError<TStringKey> {
|
|
236
|
-
return new TranslatableGenericError(
|
|
237
|
-
componentId,
|
|
238
|
-
stringKey,
|
|
239
|
-
features,
|
|
240
|
-
language,
|
|
241
|
-
undefined,
|
|
242
|
-
instanceKey,
|
|
243
|
-
);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
import { IHandleable } from '../interfaces/handleable';
|
|
2
|
-
import { TranslatableGenericError } from './translatable-generic';
|
|
3
|
-
import { PluralCategory } from '../pluralization/plural-categories';
|
|
4
|
-
import { GenderCategory } from '../gender/gender-categories';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Generic translatable handleable error with full i18n feature support.
|
|
8
|
-
*
|
|
9
|
-
* Combines translation capabilities with handleable error patterns and provides
|
|
10
|
-
* static factory methods for all i18n features.
|
|
11
|
-
*
|
|
12
|
-
* **Supported i18n Features:**
|
|
13
|
-
* - ICU MessageFormat: plural, select, selectordinal
|
|
14
|
-
* - Pluralization: 37 languages with CLDR rules
|
|
15
|
-
* - Gender support: male, female, neutral, other
|
|
16
|
-
* - Number formatting: integer, currency, percent
|
|
17
|
-
* - Nested messages: complex multi-level patterns
|
|
18
|
-
*
|
|
19
|
-
* **Usage Examples:**
|
|
20
|
-
* ```typescript
|
|
21
|
-
* // Pluralization with handleable options
|
|
22
|
-
* throw TranslatableHandleableGenericError.withCount(
|
|
23
|
-
* 'api', 'validationError', 5,
|
|
24
|
-
* {}, 'en-US', 'default',
|
|
25
|
-
* { statusCode: 400 }
|
|
26
|
-
* );
|
|
27
|
-
*
|
|
28
|
-
* // Gender-aware messages
|
|
29
|
-
* throw TranslatableHandleableGenericError.withGender(
|
|
30
|
-
* 'user', 'accountError', 'female',
|
|
31
|
-
* {}, 'en-US', 'default',
|
|
32
|
-
* { statusCode: 403 }
|
|
33
|
-
* );
|
|
34
|
-
*
|
|
35
|
-
* // Number formatting with error handling
|
|
36
|
-
* throw TranslatableHandleableGenericError.withNumberFormat(
|
|
37
|
-
* 'payment', 'amountExceeded', 1599.99,
|
|
38
|
-
* { limit: 1000 }, 'en-US', 'default',
|
|
39
|
-
* { statusCode: 402 }
|
|
40
|
-
* );
|
|
41
|
-
*
|
|
42
|
-
* // Ordinal formatting (1st, 2nd, 3rd)
|
|
43
|
-
* throw TranslatableHandleableGenericError.withOrdinal(
|
|
44
|
-
* 'workflow', 'stepFailed', 3,
|
|
45
|
-
* {}, 'en-US', 'default',
|
|
46
|
-
* { statusCode: 500, retryable: true }
|
|
47
|
-
* );
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
export class TranslatableHandleableGenericError<
|
|
51
|
-
TStringKey extends string = string,
|
|
52
|
-
>
|
|
53
|
-
extends TranslatableGenericError<TStringKey>
|
|
54
|
-
implements IHandleable
|
|
55
|
-
{
|
|
56
|
-
private _handled = false;
|
|
57
|
-
public override readonly cause?: Error;
|
|
58
|
-
public readonly statusCode: number;
|
|
59
|
-
public readonly sourceData?: unknown;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Create a translatable error
|
|
63
|
-
* @param componentId - The component ID to translate from
|
|
64
|
-
* @param stringKey - The translation key
|
|
65
|
-
* @param variables - Variables for interpolation
|
|
66
|
-
* @param language - Optional language override
|
|
67
|
-
* @param metadata - Additional error metadata
|
|
68
|
-
* @param instanceKey - Optional engine instance key
|
|
69
|
-
*/
|
|
70
|
-
constructor(
|
|
71
|
-
componentId: string,
|
|
72
|
-
stringKey: TStringKey,
|
|
73
|
-
variables?: Record<string, string | number>,
|
|
74
|
-
language?: string,
|
|
75
|
-
metadata?: Record<string, any>,
|
|
76
|
-
instanceKey?: string,
|
|
77
|
-
handleableOptions?: {
|
|
78
|
-
statusCode?: number;
|
|
79
|
-
cause?: Error;
|
|
80
|
-
sourceData?: unknown;
|
|
81
|
-
},
|
|
82
|
-
) {
|
|
83
|
-
super(componentId, stringKey, variables, language, metadata, instanceKey);
|
|
84
|
-
this.statusCode = handleableOptions?.statusCode ?? 500;
|
|
85
|
-
this.cause = handleableOptions?.cause;
|
|
86
|
-
this.sourceData = handleableOptions?.sourceData;
|
|
87
|
-
this.name = 'TranslatableHandleableGenericError';
|
|
88
|
-
}
|
|
89
|
-
public get handled(): boolean {
|
|
90
|
-
return this._handled;
|
|
91
|
-
}
|
|
92
|
-
public set handled(value: boolean) {
|
|
93
|
-
this._handled = value;
|
|
94
|
-
}
|
|
95
|
-
toJSON(): Record<string, unknown> {
|
|
96
|
-
return {
|
|
97
|
-
statusCode: this.statusCode,
|
|
98
|
-
message: this.message,
|
|
99
|
-
cause: this.cause,
|
|
100
|
-
sourceData: this.sourceData,
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Create error with pluralization support
|
|
106
|
-
* Translation string should include: "{count, plural, one {...} other {...}}"
|
|
107
|
-
*/
|
|
108
|
-
static override withCount<TStringKey extends string>(
|
|
109
|
-
componentId: string,
|
|
110
|
-
stringKey: TStringKey,
|
|
111
|
-
count: number,
|
|
112
|
-
otherVars?: Record<string, string | number>,
|
|
113
|
-
language?: string,
|
|
114
|
-
instanceKey?: string,
|
|
115
|
-
handleableOptions?: { statusCode?: number; cause?: Error; sourceData?: unknown },
|
|
116
|
-
): TranslatableHandleableGenericError<TStringKey> {
|
|
117
|
-
return new TranslatableHandleableGenericError(
|
|
118
|
-
componentId,
|
|
119
|
-
stringKey,
|
|
120
|
-
{ count, ...otherVars },
|
|
121
|
-
language,
|
|
122
|
-
undefined,
|
|
123
|
-
instanceKey,
|
|
124
|
-
handleableOptions,
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Create error with gender-aware messages
|
|
130
|
-
* Translation string should include: "{gender, select, male {...} female {...} other {...}}"
|
|
131
|
-
*/
|
|
132
|
-
static override withGender<TStringKey extends string>(
|
|
133
|
-
componentId: string,
|
|
134
|
-
stringKey: TStringKey,
|
|
135
|
-
gender: GenderCategory,
|
|
136
|
-
otherVars?: Record<string, string | number>,
|
|
137
|
-
language?: string,
|
|
138
|
-
instanceKey?: string,
|
|
139
|
-
handleableOptions?: { statusCode?: number; cause?: Error; sourceData?: unknown },
|
|
140
|
-
): TranslatableHandleableGenericError<TStringKey> {
|
|
141
|
-
return new TranslatableHandleableGenericError(
|
|
142
|
-
componentId,
|
|
143
|
-
stringKey,
|
|
144
|
-
{ gender, ...otherVars },
|
|
145
|
-
language,
|
|
146
|
-
undefined,
|
|
147
|
-
instanceKey,
|
|
148
|
-
handleableOptions,
|
|
149
|
-
);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Create error with ordinal formatting (1st, 2nd, 3rd)
|
|
154
|
-
* Translation string should include: "{number, selectordinal, one {#st} two {#nd} few {#rd} other {#th}}"
|
|
155
|
-
*/
|
|
156
|
-
static override withOrdinal<TStringKey extends string>(
|
|
157
|
-
componentId: string,
|
|
158
|
-
stringKey: TStringKey,
|
|
159
|
-
ordinalNumber: number,
|
|
160
|
-
otherVars?: Record<string, string | number>,
|
|
161
|
-
language?: string,
|
|
162
|
-
instanceKey?: string,
|
|
163
|
-
handleableOptions?: { statusCode?: number; cause?: Error; sourceData?: unknown },
|
|
164
|
-
): TranslatableHandleableGenericError<TStringKey> {
|
|
165
|
-
return new TranslatableHandleableGenericError(
|
|
166
|
-
componentId,
|
|
167
|
-
stringKey,
|
|
168
|
-
{ number: ordinalNumber, ...otherVars },
|
|
169
|
-
language,
|
|
170
|
-
undefined,
|
|
171
|
-
instanceKey,
|
|
172
|
-
handleableOptions,
|
|
173
|
-
);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* Create error with number formatting (currency, percent, integer)
|
|
178
|
-
* Translation string should include: "{value, number, integer}" or "{amount, number, currency}"
|
|
179
|
-
*/
|
|
180
|
-
static override withNumberFormat<TStringKey extends string>(
|
|
181
|
-
componentId: string,
|
|
182
|
-
stringKey: TStringKey,
|
|
183
|
-
value: number,
|
|
184
|
-
otherVars?: Record<string, string | number>,
|
|
185
|
-
language?: string,
|
|
186
|
-
instanceKey?: string,
|
|
187
|
-
handleableOptions?: { statusCode?: number; cause?: Error; sourceData?: unknown },
|
|
188
|
-
): TranslatableHandleableGenericError<TStringKey> {
|
|
189
|
-
return new TranslatableHandleableGenericError(
|
|
190
|
-
componentId,
|
|
191
|
-
stringKey,
|
|
192
|
-
{ value, ...otherVars },
|
|
193
|
-
language,
|
|
194
|
-
undefined,
|
|
195
|
-
instanceKey,
|
|
196
|
-
handleableOptions,
|
|
197
|
-
);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Create error with multiple i18n features combined
|
|
202
|
-
* Translation string can combine: plural, select, number formatting, etc.
|
|
203
|
-
*/
|
|
204
|
-
static override withMultipleFeatures<TStringKey extends string>(
|
|
205
|
-
componentId: string,
|
|
206
|
-
stringKey: TStringKey,
|
|
207
|
-
features: Record<string, string | number>,
|
|
208
|
-
language?: string,
|
|
209
|
-
instanceKey?: string,
|
|
210
|
-
handleableOptions?: { statusCode?: number; cause?: Error; sourceData?: unknown },
|
|
211
|
-
): TranslatableHandleableGenericError<TStringKey> {
|
|
212
|
-
return new TranslatableHandleableGenericError(
|
|
213
|
-
componentId,
|
|
214
|
-
stringKey,
|
|
215
|
-
features,
|
|
216
|
-
language,
|
|
217
|
-
undefined,
|
|
218
|
-
instanceKey,
|
|
219
|
-
handleableOptions,
|
|
220
|
-
);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { I18nEngine } from '../core/i18n-engine';
|
|
2
|
-
import { GenderCategory } from '../gender/gender-categories';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Translatable error class with full i18n 3.0/3.5 feature support.
|
|
6
|
-
*
|
|
7
|
-
* Uses lazy initialization to avoid circular dependencies with core modules.
|
|
8
|
-
* The I18nEngine is only accessed when the error is constructed, not at module load time.
|
|
9
|
-
* If the i18n engine is not initialized, falls back to displaying the raw key.
|
|
10
|
-
*
|
|
11
|
-
* **Supported Features:**
|
|
12
|
-
* - ICU MessageFormat (variables, plural, select, selectordinal)
|
|
13
|
-
* - Pluralization (37 languages, CLDR rules)
|
|
14
|
-
* - Gender-aware translations
|
|
15
|
-
* - Number formatting (integer, currency, percent)
|
|
16
|
-
* - Date/Time formatting
|
|
17
|
-
* - Nested messages (4 levels deep)
|
|
18
|
-
* - Context variables
|
|
19
|
-
*
|
|
20
|
-
* **Translation String Examples:**
|
|
21
|
-
* ```typescript
|
|
22
|
-
* // ICU plural
|
|
23
|
-
* "{count, plural, one {# error occurred} other {# errors occurred}}"
|
|
24
|
-
*
|
|
25
|
-
* // ICU select + gender
|
|
26
|
-
* "{gender, select, male {He encountered} female {She encountered}} an error"
|
|
27
|
-
*
|
|
28
|
-
* // Number formatting
|
|
29
|
-
* "Threshold {limit, number, integer} exceeded by {value, number, percent}"
|
|
30
|
-
*
|
|
31
|
-
* // SelectOrdinal
|
|
32
|
-
* "Failed at {step, selectordinal, one {#st} two {#nd} few {#rd} other {#th}} step"
|
|
33
|
-
*
|
|
34
|
-
* // Nested messages
|
|
35
|
-
* "{severity, select, low {Minor: {count, plural, one {# issue} other {# issues}}} high {Critical error}}"
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
export class TranslatableError<
|
|
39
|
-
TStringKey extends string = string,
|
|
40
|
-
> extends Error {
|
|
41
|
-
public override readonly componentId: string;
|
|
42
|
-
public readonly stringKey: TStringKey;
|
|
43
|
-
public readonly variables?: Record<string, string | number>;
|
|
44
|
-
public readonly language?: string;
|
|
45
|
-
|
|
46
|
-
constructor(
|
|
47
|
-
componentId: string,
|
|
48
|
-
stringKey: TStringKey,
|
|
49
|
-
otherVars?: Record<string, string | number>,
|
|
50
|
-
language?: string,
|
|
51
|
-
) {
|
|
52
|
-
// Lazy initialization: getInstance() is only called when error is constructed, not at module load
|
|
53
|
-
const engine = I18nEngine.getInstance('default');
|
|
54
|
-
super(engine.safeTranslate(componentId, stringKey, otherVars, language));
|
|
55
|
-
this.name = 'TranslatableError';
|
|
56
|
-
this.componentId = componentId;
|
|
57
|
-
this.stringKey = stringKey;
|
|
58
|
-
this.variables = otherVars;
|
|
59
|
-
this.language = language;
|
|
60
|
-
Object.setPrototypeOf(this, TranslatableError.prototype);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Create error with plural count
|
|
65
|
-
* Translation string should use: {count, plural, one {...} other {...}}
|
|
66
|
-
*/
|
|
67
|
-
static withCount<TStringKey extends string>(
|
|
68
|
-
componentId: string,
|
|
69
|
-
stringKey: TStringKey,
|
|
70
|
-
count: number,
|
|
71
|
-
otherVars?: Record<string, string | number>,
|
|
72
|
-
language?: string,
|
|
73
|
-
): TranslatableError<TStringKey> {
|
|
74
|
-
return new TranslatableError(
|
|
75
|
-
componentId,
|
|
76
|
-
stringKey,
|
|
77
|
-
{ count, ...otherVars },
|
|
78
|
-
language,
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Create error with gender context
|
|
84
|
-
* Translation string should use: {gender, select, male {...} female {...} other {...}}
|
|
85
|
-
*/
|
|
86
|
-
static withGender<TStringKey extends string>(
|
|
87
|
-
componentId: string,
|
|
88
|
-
stringKey: TStringKey,
|
|
89
|
-
gender: GenderCategory,
|
|
90
|
-
otherVars?: Record<string, string | number>,
|
|
91
|
-
language?: string,
|
|
92
|
-
): TranslatableError<TStringKey> {
|
|
93
|
-
return new TranslatableError(
|
|
94
|
-
componentId,
|
|
95
|
-
stringKey,
|
|
96
|
-
{ gender, ...otherVars },
|
|
97
|
-
language,
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Create error with ordinal number
|
|
103
|
-
* Translation string should use: {number, selectordinal, one {#st} two {#nd} few {#rd} other {#th}}
|
|
104
|
-
*/
|
|
105
|
-
static withOrdinal<TStringKey extends string>(
|
|
106
|
-
componentId: string,
|
|
107
|
-
stringKey: TStringKey,
|
|
108
|
-
number: number,
|
|
109
|
-
otherVars?: Record<string, string | number>,
|
|
110
|
-
language?: string,
|
|
111
|
-
): TranslatableError<TStringKey> {
|
|
112
|
-
return new TranslatableError(
|
|
113
|
-
componentId,
|
|
114
|
-
stringKey,
|
|
115
|
-
{ number, ...otherVars },
|
|
116
|
-
language,
|
|
117
|
-
);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Create error with formatted number
|
|
122
|
-
* Translation string should use: {value, number, integer|currency|percent}
|
|
123
|
-
*/
|
|
124
|
-
static withNumber<TStringKey extends string>(
|
|
125
|
-
componentId: string,
|
|
126
|
-
stringKey: TStringKey,
|
|
127
|
-
value: number,
|
|
128
|
-
otherVars?: Record<string, string | number>,
|
|
129
|
-
language?: string,
|
|
130
|
-
): TranslatableError<TStringKey> {
|
|
131
|
-
return new TranslatableError(
|
|
132
|
-
componentId,
|
|
133
|
-
stringKey,
|
|
134
|
-
{ value, ...otherVars },
|
|
135
|
-
language,
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
}
|