@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,111 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Factory for creating core plugin I18n engine instances
|
|
3
|
-
* This file breaks the circular dependency between core-i18n.ts and plugin-i18n-engine.ts
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
createCoreComponentRegistration,
|
|
8
|
-
createDefaultLanguages,
|
|
9
|
-
} from './core-i18n';
|
|
10
|
-
import { PluginI18nEngine } from './plugin-i18n-engine';
|
|
11
|
-
import { RegistryConfig } from './registry-config';
|
|
12
|
-
|
|
13
|
-
const DefaultInstanceKey = 'default';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Create a pre-configured I18n engine with core components
|
|
17
|
-
* Returns engine with string type - use registry for language validation
|
|
18
|
-
*/
|
|
19
|
-
export function createCorePluginI18nEngine(
|
|
20
|
-
instanceKey: string = DefaultInstanceKey,
|
|
21
|
-
config?: Partial<RegistryConfig<string>>,
|
|
22
|
-
): PluginI18nEngine<string> {
|
|
23
|
-
const languages = createDefaultLanguages();
|
|
24
|
-
const engine = PluginI18nEngine.createInstance<string>(
|
|
25
|
-
instanceKey,
|
|
26
|
-
languages,
|
|
27
|
-
config,
|
|
28
|
-
);
|
|
29
|
-
engine.registerComponent(createCoreComponentRegistration());
|
|
30
|
-
return engine;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Note: Lazy initialization to avoid circular dependency issues
|
|
34
|
-
// Tests should call resetCorePluginI18nEngine() after PluginI18nEngine.resetAll()
|
|
35
|
-
let _corePluginI18nEngine: PluginI18nEngine<string> | undefined;
|
|
36
|
-
|
|
37
|
-
export function getCorePluginI18nEngine(): PluginI18nEngine<string> {
|
|
38
|
-
// Lazy initialization on first access
|
|
39
|
-
if (!_corePluginI18nEngine) {
|
|
40
|
-
_corePluginI18nEngine = createCorePluginI18nEngine();
|
|
41
|
-
return _corePluginI18nEngine;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Lazy re-initialization if instance was cleared
|
|
45
|
-
try {
|
|
46
|
-
PluginI18nEngine.getInstance<string>(DefaultInstanceKey);
|
|
47
|
-
return _corePluginI18nEngine;
|
|
48
|
-
} catch {
|
|
49
|
-
_corePluginI18nEngine = createCorePluginI18nEngine();
|
|
50
|
-
return _corePluginI18nEngine;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Getter for direct reference - lazily initialized
|
|
55
|
-
export const corePluginI18nEngine = new Proxy({} as PluginI18nEngine<string>, {
|
|
56
|
-
get(_target, prop) {
|
|
57
|
-
const engine = getCorePluginI18nEngine();
|
|
58
|
-
return engine[prop as keyof PluginI18nEngine<string>];
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
// Reset function for tests
|
|
63
|
-
export function resetCorePluginI18nEngine(): void {
|
|
64
|
-
_corePluginI18nEngine = undefined;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Type alias for easier usage
|
|
69
|
-
*/
|
|
70
|
-
export type CorePluginI18nEngine = PluginI18nEngine<string>;
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Helper function to get core translation
|
|
74
|
-
* Uses the core engine instance to ensure core strings are available
|
|
75
|
-
*/
|
|
76
|
-
export function getCorePluginTranslation(
|
|
77
|
-
stringKey: string,
|
|
78
|
-
variables?: Record<string, string | number>,
|
|
79
|
-
language?: string,
|
|
80
|
-
instanceKey?: string,
|
|
81
|
-
): string {
|
|
82
|
-
// Use string literal to avoid circular dependency
|
|
83
|
-
const coreComponentId = 'core';
|
|
84
|
-
|
|
85
|
-
// Use core engine if no instance key specified, otherwise use specified instance
|
|
86
|
-
const engine = instanceKey
|
|
87
|
-
? PluginI18nEngine.getInstance<string>(instanceKey)
|
|
88
|
-
: getCorePluginI18nEngine();
|
|
89
|
-
return engine.translate(coreComponentId, stringKey, variables, language);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Helper function to safely get core translation with fallback
|
|
94
|
-
*/
|
|
95
|
-
export function safeCorePluginTranslation(
|
|
96
|
-
stringKey: string,
|
|
97
|
-
variables?: Record<string, string | number>,
|
|
98
|
-
language?: string,
|
|
99
|
-
instanceKey?: string,
|
|
100
|
-
): string {
|
|
101
|
-
try {
|
|
102
|
-
return getCorePluginTranslation(
|
|
103
|
-
stringKey,
|
|
104
|
-
variables,
|
|
105
|
-
language,
|
|
106
|
-
instanceKey,
|
|
107
|
-
);
|
|
108
|
-
} catch {
|
|
109
|
-
return `[CoreStringKey.${stringKey}]`;
|
|
110
|
-
}
|
|
111
|
-
}
|
package/src/core-string-key.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Core system string keys
|
|
3
|
-
*/
|
|
4
|
-
export enum CoreStringKey {
|
|
5
|
-
// Common/General
|
|
6
|
-
Common_Yes = 'common_yes',
|
|
7
|
-
Common_No = 'common_no',
|
|
8
|
-
Common_Cancel = 'common_cancel',
|
|
9
|
-
Common_OK = 'common_ok',
|
|
10
|
-
Common_Save = 'common_save',
|
|
11
|
-
Common_Delete = 'common_delete',
|
|
12
|
-
Common_Edit = 'common_edit',
|
|
13
|
-
Common_Create = 'common_create',
|
|
14
|
-
Common_Update = 'common_update',
|
|
15
|
-
Common_Loading = 'common_loading',
|
|
16
|
-
Common_Error = 'common_error',
|
|
17
|
-
Common_Success = 'common_success',
|
|
18
|
-
Common_Warning = 'common_warning',
|
|
19
|
-
Common_Info = 'common_info',
|
|
20
|
-
Common_Disposed = 'common_disposed',
|
|
21
|
-
Common_Test = 'common_test',
|
|
22
|
-
// Error Messages
|
|
23
|
-
Error_InvalidInput = 'error_invalidInput',
|
|
24
|
-
Error_NetworkError = 'error_networkError',
|
|
25
|
-
Error_NotFound = 'error_notFound',
|
|
26
|
-
Error_AccessDenied = 'error_accessDenied',
|
|
27
|
-
Error_InternalServer = 'error_internalServer',
|
|
28
|
-
Error_ValidationFailed = 'error_validationFailed',
|
|
29
|
-
Error_RequiredField = 'error_requiredField',
|
|
30
|
-
Error_InvalidContext = 'error_invalidContext',
|
|
31
|
-
Error_InvalidContextTemplate = 'error_invalidContextTemplate',
|
|
32
|
-
Error_InvalidCurrencyCodeTemplate = 'error_invalidCurrencyCodeTemplate',
|
|
33
|
-
|
|
34
|
-
// Registry Errors (templates support variables)
|
|
35
|
-
Error_ComponentNotFoundTemplate = 'error_componentNotFoundTemplate',
|
|
36
|
-
Error_LanguageNotFoundTemplate = 'error_languageNotFoundTemplate',
|
|
37
|
-
Error_StringKeyNotFoundTemplate = 'error_stringKeyNotFoundTemplate',
|
|
38
|
-
Error_IncompleteRegistrationTemplate = 'error_incompleteRegistrationTemplate',
|
|
39
|
-
Error_DuplicateComponentTemplate = 'error_duplicateComponentTemplate',
|
|
40
|
-
Error_DuplicateLanguageTemplate = 'error_duplicateLanguageTemplate',
|
|
41
|
-
Error_ValidationFailedTemplate = 'error_validationFailedTemplate',
|
|
42
|
-
Error_MissingTranslationKeyTemplate = 'error_missingTranslationKeyTemplate',
|
|
43
|
-
|
|
44
|
-
// System Messages
|
|
45
|
-
System_Welcome = 'system_welcome',
|
|
46
|
-
System_Goodbye = 'system_goodbye',
|
|
47
|
-
System_PleaseWait = 'system_pleaseWait',
|
|
48
|
-
System_ProcessingRequest = 'system_processingRequest',
|
|
49
|
-
System_OperationComplete = 'system_operationComplete',
|
|
50
|
-
System_NoDataAvailable = 'system_noDataAvailable',
|
|
51
|
-
|
|
52
|
-
// DefaultStringKey
|
|
53
|
-
Error_InstanceAlreadyExistsTemplate = 'error_instanceAlreadyExistsTemplate',
|
|
54
|
-
Error_InstanceNotFoundTemplate = 'error_instanceNotFoundTemplate',
|
|
55
|
-
Error_MissingStringCollectionTemplate = 'error_missingStringCollectionTemplate',
|
|
56
|
-
Error_MissingTranslationTemplate = 'error_missingTranslationTemplate',
|
|
57
|
-
Error_DefaultLanguageNoCollectionTemplate = 'error_defaultLanguageNoCollectionTemplate',
|
|
58
|
-
Error_MissingTranslationKeyForTypeTemplate = 'error_missingTranslationKeyForTypeTemplate',
|
|
59
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { PluginI18nEngine } from './plugin-i18n-engine';
|
|
2
|
-
import { TranslationEngine } from './translation-engine';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Creates a TranslationEngine adapter from a PluginI18nEngine for a specific component.
|
|
6
|
-
* This allows PluginI18nEngine to be used where TranslationEngine interface is expected.
|
|
7
|
-
*
|
|
8
|
-
* The adapter supports both calling conventions:
|
|
9
|
-
* - Full TranslationEngine interface: `translate(componentId, key, vars, lang)`
|
|
10
|
-
* - Simplified interface: `translate(key, vars, lang)` (componentId is bound)
|
|
11
|
-
*
|
|
12
|
-
* @param pluginEngine - The PluginI18nEngine instance to wrap
|
|
13
|
-
* @param componentId - The component ID to use for translations
|
|
14
|
-
* @returns A TranslationEngine that delegates to the PluginI18nEngine
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* const pluginEngine = getMyPluginI18nEngine();
|
|
19
|
-
* const adapter = createTranslationAdapter(pluginEngine, 'my-component');
|
|
20
|
-
*
|
|
21
|
-
* // Simplified interface (componentId is bound)
|
|
22
|
-
* const text1 = adapter.translate('key');
|
|
23
|
-
* const text2 = adapter.translate('key', { var: 'value' });
|
|
24
|
-
* const text3 = adapter.translate('key', { var: 'value' }, 'fr');
|
|
25
|
-
*
|
|
26
|
-
* // Full TranslationEngine interface
|
|
27
|
-
* const text4 = adapter.translate('other-component', 'key', { var: 'value' }, 'fr');
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
export function createTranslationAdapter<
|
|
31
|
-
TStringKey extends string,
|
|
32
|
-
TLanguage extends string,
|
|
33
|
-
>(
|
|
34
|
-
pluginEngine: PluginI18nEngine<TLanguage>,
|
|
35
|
-
componentId: string,
|
|
36
|
-
): TranslationEngine<TStringKey> & {
|
|
37
|
-
translate(key: TStringKey, vars?: Record<string, string | number>, lang?: TLanguage): string;
|
|
38
|
-
safeTranslate(key: TStringKey, vars?: Record<string, string | number>, lang?: TLanguage): string;
|
|
39
|
-
} {
|
|
40
|
-
const adapter: any = {
|
|
41
|
-
translate: (
|
|
42
|
-
keyOrComponentId: string | TStringKey,
|
|
43
|
-
varsOrKey?: TStringKey | Record<string, string | number>,
|
|
44
|
-
langOrVars?: TLanguage | Record<string, string | number>,
|
|
45
|
-
maybeLang?: TLanguage,
|
|
46
|
-
): string => {
|
|
47
|
-
let actualKey: TStringKey;
|
|
48
|
-
let actualVars: Record<string, string | number> | undefined;
|
|
49
|
-
let actualLang: TLanguage | undefined;
|
|
50
|
-
|
|
51
|
-
if (arguments.length >= 4 || (typeof varsOrKey === 'string')) {
|
|
52
|
-
actualKey = varsOrKey as TStringKey;
|
|
53
|
-
actualVars = langOrVars as Record<string, string | number> | undefined;
|
|
54
|
-
actualLang = maybeLang;
|
|
55
|
-
} else {
|
|
56
|
-
actualKey = keyOrComponentId as TStringKey;
|
|
57
|
-
actualVars = varsOrKey as Record<string, string | number> | undefined;
|
|
58
|
-
actualLang = langOrVars as TLanguage | undefined;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
try {
|
|
62
|
-
return pluginEngine.translate(componentId, actualKey, actualVars, actualLang);
|
|
63
|
-
} catch (error) {
|
|
64
|
-
return String(actualKey);
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
safeTranslate: (
|
|
69
|
-
keyOrComponentId: string | TStringKey,
|
|
70
|
-
varsOrKey?: TStringKey | Record<string, string | number>,
|
|
71
|
-
langOrVars?: TLanguage | Record<string, string | number>,
|
|
72
|
-
maybeLang?: TLanguage,
|
|
73
|
-
): string => {
|
|
74
|
-
let actualKey: TStringKey;
|
|
75
|
-
let actualVars: Record<string, string | number> | undefined;
|
|
76
|
-
let actualLang: TLanguage | undefined;
|
|
77
|
-
|
|
78
|
-
if (arguments.length >= 4 || (typeof varsOrKey === 'string')) {
|
|
79
|
-
actualKey = varsOrKey as TStringKey;
|
|
80
|
-
actualVars = langOrVars as Record<string, string | number> | undefined;
|
|
81
|
-
actualLang = maybeLang;
|
|
82
|
-
} else {
|
|
83
|
-
actualKey = keyOrComponentId as TStringKey;
|
|
84
|
-
actualVars = varsOrKey as Record<string, string | number> | undefined;
|
|
85
|
-
actualLang = langOrVars as TLanguage | undefined;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return pluginEngine.safeTranslate(componentId, actualKey, actualVars, actualLang);
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
return adapter;
|
|
93
|
-
}
|
package/src/enum-registry.ts
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { EnumLanguageTranslation } from './types';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Registry for managing translations of enum values across multiple languages.
|
|
5
|
-
*
|
|
6
|
-
* @template TStringKey Type of translation key used in error messages.
|
|
7
|
-
* @template TLanguage Type of supported language codes.
|
|
8
|
-
*/
|
|
9
|
-
export class EnumTranslationRegistry<
|
|
10
|
-
TStringKey extends string,
|
|
11
|
-
TLanguage extends string,
|
|
12
|
-
> {
|
|
13
|
-
protected translations = new Map<any, EnumLanguageTranslation<any, TLanguage>>();
|
|
14
|
-
protected enumNames = new WeakMap<any, string>();
|
|
15
|
-
protected availableLanguages: Set<TLanguage>;
|
|
16
|
-
protected translateFn?: (key: TStringKey, vars?: Record<string, any>) => string;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Creates a new EnumTranslationRegistry.
|
|
20
|
-
*
|
|
21
|
-
* @param availableLanguages Array of supported language codes.
|
|
22
|
-
* @param translateFn Optional translation function for error templates.
|
|
23
|
-
*/
|
|
24
|
-
constructor(
|
|
25
|
-
availableLanguages: TLanguage[],
|
|
26
|
-
translateFn?: (key: TStringKey, vars?: Record<string, any>) => string,
|
|
27
|
-
) {
|
|
28
|
-
this.availableLanguages = new Set(availableLanguages);
|
|
29
|
-
this.translateFn = translateFn;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Registers an enum and its language-specific translations.
|
|
34
|
-
*
|
|
35
|
-
* @template TEnum Enum value type (string or number).
|
|
36
|
-
* @param enumObj The enum object to register.
|
|
37
|
-
* @param translations Mapping of language codes to value-to-string translations.
|
|
38
|
-
* @param enumName Human-readable name of the enum (used in errors).
|
|
39
|
-
* @throws {Error} If translations contain languages not in availableLanguages.
|
|
40
|
-
*/
|
|
41
|
-
public register<TEnum extends string | number>(
|
|
42
|
-
enumObj: Record<string, TEnum>,
|
|
43
|
-
translations: EnumLanguageTranslation<TEnum, TLanguage>,
|
|
44
|
-
enumName: string,
|
|
45
|
-
): void {
|
|
46
|
-
this.validateTranslations(translations, enumName);
|
|
47
|
-
this.translations.set(enumObj, translations);
|
|
48
|
-
this.enumNames.set(enumObj, enumName);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Translates a specific enum value into the target language.
|
|
53
|
-
*
|
|
54
|
-
* @template TEnum Enum value type.
|
|
55
|
-
* @param enumObj The enum object registered previously.
|
|
56
|
-
* @param value The enum value to translate.
|
|
57
|
-
* @param language The target language code.
|
|
58
|
-
* @returns The translated string.
|
|
59
|
-
* @throws {Error} If the enum or language or value is not found.
|
|
60
|
-
*/
|
|
61
|
-
public translate<TEnum extends string | number>(
|
|
62
|
-
enumObj: Record<string, TEnum>,
|
|
63
|
-
value: TEnum,
|
|
64
|
-
language: TLanguage,
|
|
65
|
-
): string {
|
|
66
|
-
const translations = this.translations.get(enumObj);
|
|
67
|
-
if (!translations) {
|
|
68
|
-
const message = this.translateFn
|
|
69
|
-
? this.translateFn('Error_EnumNotFoundTemplate' as TStringKey, {
|
|
70
|
-
enumName: this.getEnumName(enumObj),
|
|
71
|
-
})
|
|
72
|
-
: `No translations found for enum: ${this.getEnumName(enumObj)}`;
|
|
73
|
-
throw new Error(message);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const langTranslations = translations[language];
|
|
77
|
-
if (!langTranslations) {
|
|
78
|
-
const message = this.translateFn
|
|
79
|
-
? this.translateFn('Error_EnumLanguageNotFoundTemplate' as TStringKey, {
|
|
80
|
-
language,
|
|
81
|
-
})
|
|
82
|
-
: `No translations found for language: ${language}`;
|
|
83
|
-
throw new Error(message);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
let result = langTranslations[value];
|
|
87
|
-
if (!result && typeof value === 'number') {
|
|
88
|
-
const stringKey = Object.keys(enumObj).find(
|
|
89
|
-
(key) => enumObj[key] === value,
|
|
90
|
-
);
|
|
91
|
-
if (stringKey) {
|
|
92
|
-
result = langTranslations[stringKey as TEnum];
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (!result) {
|
|
97
|
-
const message = this.translateFn
|
|
98
|
-
? this.translateFn('Error_EnumValueNotFoundTemplate' as TStringKey, {
|
|
99
|
-
value: String(value),
|
|
100
|
-
})
|
|
101
|
-
: `No translation found for value: ${String(value)}`;
|
|
102
|
-
throw new Error(message);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return result;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Checks whether translations exist for the given enum object.
|
|
110
|
-
*
|
|
111
|
-
* @param enumObj The enum object to check.
|
|
112
|
-
* @returns True if registered, false otherwise.
|
|
113
|
-
*/
|
|
114
|
-
public has(enumObj: any): boolean {
|
|
115
|
-
return this.translations.has(enumObj);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Internal: Retrieves the human-readable name of the enum.
|
|
120
|
-
*
|
|
121
|
-
* @param enumObj The enum object.
|
|
122
|
-
* @returns Registered enum name or 'UnknownEnum' if not set.
|
|
123
|
-
*/
|
|
124
|
-
private getEnumName(enumObj: any): string {
|
|
125
|
-
return this.enumNames.get(enumObj) || 'UnknownEnum';
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Internal: Validates that translation entries only use available languages.
|
|
130
|
-
*
|
|
131
|
-
* @template TEnum Enum value type.
|
|
132
|
-
* @param translations Mapping of language codes to translations.
|
|
133
|
-
* @param enumName Enum name for error reporting.
|
|
134
|
-
* @throws {Error} If a translation language is not available.
|
|
135
|
-
*/
|
|
136
|
-
private validateTranslations<TEnum extends string | number>(
|
|
137
|
-
translations: EnumLanguageTranslation<TEnum, TLanguage>,
|
|
138
|
-
enumName: string,
|
|
139
|
-
): void {
|
|
140
|
-
for (const language of Object.keys(translations) as TLanguage[]) {
|
|
141
|
-
if (!this.availableLanguages.has(language)) {
|
|
142
|
-
const message = this.translateFn
|
|
143
|
-
? this.translateFn(
|
|
144
|
-
'Error_EnumLanguageNotAvailableTemplate' as TStringKey,
|
|
145
|
-
{ language, enumName },
|
|
146
|
-
)
|
|
147
|
-
: `Language '${language}' in enum '${enumName}' is not available in this registry`;
|
|
148
|
-
throw new Error(message);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { ContextErrorType } from '../context-error-type';
|
|
2
|
-
import { CoreI18nComponentId } from '../core-component-id';
|
|
3
|
-
import { CoreStringKey } from '../core-string-key';
|
|
4
|
-
import { EnhancedErrorHelper } from './enhanced-error-base';
|
|
5
|
-
|
|
6
|
-
// Lazy reference to I18nEngine to avoid circular dependencies
|
|
7
|
-
let engineGetter: (() => any) | undefined;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Error class for context-related failures in the i18n system.
|
|
11
|
-
* Thrown when attempting to access or manipulate an invalid or non-existent context.
|
|
12
|
-
*
|
|
13
|
-
* **i18n Feature Support:**
|
|
14
|
-
* - ICU MessageFormat variable substitution
|
|
15
|
-
* - Nested message paths detection
|
|
16
|
-
* - Number formatting for context depths/positions
|
|
17
|
-
* - SelectOrdinal for context priority levels
|
|
18
|
-
*
|
|
19
|
-
* **Translation String Examples:**
|
|
20
|
-
* ```typescript
|
|
21
|
-
* // ICU plural
|
|
22
|
-
* "Context has {count, plural, one {# issue} other {# issues}}"
|
|
23
|
-
*
|
|
24
|
-
* // ICU select + nested
|
|
25
|
-
* "{severity, select, low {Minor context issue} high {Critical context error}}"
|
|
26
|
-
*
|
|
27
|
-
* // Number formatting
|
|
28
|
-
* "Context exceeded {limit, number, integer} maximum depth"
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
export class ContextError extends Error {
|
|
32
|
-
/** The type of context error */
|
|
33
|
-
public override readonly type: ContextErrorType;
|
|
34
|
-
/** The context key that caused the error, if applicable */
|
|
35
|
-
public readonly contextKey?: string;
|
|
36
|
-
/** Additional context metadata */
|
|
37
|
-
public override readonly metadata?: Record<string, any>;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Creates a new ContextError instance.
|
|
41
|
-
* @param type - The type of context error
|
|
42
|
-
* @param contextKey - Optional context key that caused the error
|
|
43
|
-
* @param variables - Additional variables for ICU message formatting
|
|
44
|
-
* @param language - Optional language code
|
|
45
|
-
*/
|
|
46
|
-
constructor(
|
|
47
|
-
type: ContextErrorType,
|
|
48
|
-
contextKey?: string,
|
|
49
|
-
variables?: Record<string, string | number>,
|
|
50
|
-
language?: string,
|
|
51
|
-
) {
|
|
52
|
-
// Lazy initialization: get engine instance at runtime to avoid circular dependencies
|
|
53
|
-
let message: string;
|
|
54
|
-
try {
|
|
55
|
-
// Lazy load I18nEngine to break circular dependency
|
|
56
|
-
if (!engineGetter) {
|
|
57
|
-
// Dynamically import at runtime
|
|
58
|
-
const coreModule = eval('require')('../core');
|
|
59
|
-
engineGetter = () => coreModule.I18nEngine.getInstance('default');
|
|
60
|
-
}
|
|
61
|
-
const engine = engineGetter();
|
|
62
|
-
const allVars = { ...variables, contextKey: contextKey || '' };
|
|
63
|
-
message = contextKey
|
|
64
|
-
? engine.safeTranslate(
|
|
65
|
-
CoreI18nComponentId,
|
|
66
|
-
CoreStringKey.Error_InvalidContextTemplate,
|
|
67
|
-
allVars,
|
|
68
|
-
language,
|
|
69
|
-
)
|
|
70
|
-
: engine.safeTranslate(
|
|
71
|
-
CoreI18nComponentId,
|
|
72
|
-
CoreStringKey.Error_InvalidContext,
|
|
73
|
-
allVars,
|
|
74
|
-
language,
|
|
75
|
-
);
|
|
76
|
-
} catch {
|
|
77
|
-
// Fallback if engine not available
|
|
78
|
-
message = contextKey
|
|
79
|
-
? `Invalid context: ${contextKey}`
|
|
80
|
-
: 'Invalid context';
|
|
81
|
-
}
|
|
82
|
-
super(message);
|
|
83
|
-
this.name = 'ContextError';
|
|
84
|
-
this.type = type;
|
|
85
|
-
this.contextKey = contextKey;
|
|
86
|
-
this.metadata = variables;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Create context error with nested path information
|
|
91
|
-
* Demonstrates selectordinal for depth level
|
|
92
|
-
*/
|
|
93
|
-
static withNestedPath(
|
|
94
|
-
type: ContextErrorType,
|
|
95
|
-
contextPath: string,
|
|
96
|
-
language = 'en-US',
|
|
97
|
-
): ContextError {
|
|
98
|
-
const analysis = EnhancedErrorHelper.analyzeKeyPath(contextPath);
|
|
99
|
-
return new ContextError(
|
|
100
|
-
type,
|
|
101
|
-
contextPath,
|
|
102
|
-
{
|
|
103
|
-
depth: analysis.depth,
|
|
104
|
-
isNested: analysis.isNested ? 'true' : 'false',
|
|
105
|
-
},
|
|
106
|
-
language,
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Create context error with count information
|
|
112
|
-
* Demonstrates plural formatting
|
|
113
|
-
*/
|
|
114
|
-
static withCount(
|
|
115
|
-
type: ContextErrorType,
|
|
116
|
-
contextKey: string,
|
|
117
|
-
count: number,
|
|
118
|
-
language = 'en-US',
|
|
119
|
-
): ContextError {
|
|
120
|
-
return new ContextError(type, contextKey, { count }, language);
|
|
121
|
-
}
|
|
122
|
-
}
|