@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-registry.js","sourceRoot":"","sources":["../../../../packages/digitaldefiance-i18n-lib/src/component-registry.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAIH,qDAAiD;AACjD,+DAA0D;AAS1D,mCAAuD;AAIvD;;GAEG;AACH,MAAa,iBAAiB;IACX,UAAU,GAAG,IAAI,GAAG,EAAoC,CAAC;IACzD,gBAAgB,GAAG,IAAI,GAAG,EAGxC,CAAC;IACa,gBAAgB,CAAmB;IACnC,mBAAmB,CAAkB;IACrC,SAAS,CAAuB;IAEjD;;;;;OAKG;IACH,YACE,SAAgC,EAChC,gBAAkC,EAClC,SAA+B;QAE/B,IAAI,CAAC,mBAAmB,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC;QAC9C,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED;;;OAGG;IACI,yBAAyB,CAAC,SAAgC;QAC/D,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,CAAC;QACjC,SAAS,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAClE,CAAC;IAED;;;;;OAKG;IACI,iBAAiB,CACtB,YAA4D;QAE5D,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,YAAY,CAAC;QAE5C,gCAAgC;QAChC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC;YACtC,MAAM,8BAAa,CAAC,YAAY,CAC9B,uCAAiB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AAE,CAAC;oBACzD,+BAA+B;oBAC/B,eAAe,CAAC,SAAS,CAAC,GAAG,eAAe,CAAC,SAAS,CAAE,CAAC;gBAC3D,CAAC;qBAAM,CAAC;oBACN,iCAAiC;oBACjC,eAAe,CAAC,SAAS,CAAC,GAAG,IAAI,SAAS,CAAC,EAAE,IAAI,SAAS,GAAG,CAAC;gBAChE,CAAC;YACH,CAAC;YAED,MAAM,CAAC,UAAU,CAAC,GAAG,eAAgD,CAAC;QACxE,CAAC;QAED,OAAO,MAA2D,CAAC;IACrE,CAAC;IAED;;;;;OAKG;IACK,YAAY,CAClB,QAA2D,EAC3D,OAAiE;QAEjE,MAAM,MAAM,GACV,EAAE,CAAC;QAEL,wBAAwB;QACxB,KAAK,MAAM,CAAC,UAAU,EAAE,eAAe,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAGhE,EAAE,CAAC;YACJ,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,eAAe,EAAE,CAAC;QAC9C,CAAC;QAED,gBAAgB;QAChB,KAAK,MAAM,CAAC,UAAU,EAAE,eAAe,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAG/D,EAAE,CAAC;YACJ,IAAI,eAAe,EAAE,CAAC;gBACpB,MAAM,CAAC,UAAU,CAAC,GAAG;oBACnB,GAAG,MAAM,CAAC,UAAU,CAAC;oBACrB,GAAG,eAAe;iBACnB,CAAC;YACJ,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;OAEG;IACI,kBAAkB;QACvB,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QACxB,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;IAChC,CAAC;CACF;AAxZD,8CAwZC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-error-type.d.ts","sourceRoot":"","sources":["../../../../packages/digitaldefiance-i18n-lib/src/context-error-type.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,gBAAgB;IAC1B,0DAA0D;IAC1D,cAAc,mBAAmB;CAClC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ContextErrorType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Types of context-related errors
|
|
6
|
+
*/
|
|
7
|
+
var ContextErrorType;
|
|
8
|
+
(function (ContextErrorType) {
|
|
9
|
+
/** Error indicating an invalid or non-existent context */
|
|
10
|
+
ContextErrorType["InvalidContext"] = "InvalidContext";
|
|
11
|
+
})(ContextErrorType || (exports.ContextErrorType = ContextErrorType = {}));
|
|
12
|
+
//# sourceMappingURL=context-error-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-error-type.js","sourceRoot":"","sources":["../../../../packages/digitaldefiance-i18n-lib/src/context-error-type.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,0DAA0D;IAC1D,qDAAiC,CAAA;AACnC,CAAC,EAHW,gBAAgB,gCAAhB,gBAAgB,QAG3B"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component storage (no generics)
|
|
3
|
+
*/
|
|
4
|
+
import { ComponentConfig, ValidationResult } from '../interfaces';
|
|
5
|
+
/**
|
|
6
|
+
* Class representing a storage for component configurations and translations.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ComponentStore {
|
|
9
|
+
private components;
|
|
10
|
+
private aliasMap;
|
|
11
|
+
private constants?;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new ComponentStore instance.
|
|
14
|
+
* @param constants - Optional constants to be used in variable replacement.
|
|
15
|
+
*/
|
|
16
|
+
constructor(constants?: Record<string, any>);
|
|
17
|
+
/**
|
|
18
|
+
* Registers a new component configuration.
|
|
19
|
+
* @param config - The component configuration to register.
|
|
20
|
+
* @returns ValidationResult indicating the result of the registration.
|
|
21
|
+
* @throws {I18nError} If the component ID is already registered.
|
|
22
|
+
*/
|
|
23
|
+
register(config: ComponentConfig): ValidationResult;
|
|
24
|
+
/**
|
|
25
|
+
* Updates an existing component's strings.
|
|
26
|
+
* @param componentId - The ID of the component to update.
|
|
27
|
+
* @param strings - The new strings to merge into the component.
|
|
28
|
+
* @returns ValidationResult indicating the result of the update.
|
|
29
|
+
* @throws {I18nError} If the component is not found.
|
|
30
|
+
*/
|
|
31
|
+
update(componentId: string, strings: Record<string, Record<string, string>>): ValidationResult;
|
|
32
|
+
/**
|
|
33
|
+
* Checks if a component or alias is registered.
|
|
34
|
+
* @param componentId - The component ID or alias to check.
|
|
35
|
+
* @returns True if the component or alias is registered, false otherwise.
|
|
36
|
+
*/
|
|
37
|
+
has(componentId: string): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Retrieves a component configuration by ID or alias.
|
|
40
|
+
* @param componentId - The component ID or alias to retrieve.
|
|
41
|
+
* @returns The component configuration.
|
|
42
|
+
* @throws {I18nError} If the component is not found.
|
|
43
|
+
*/
|
|
44
|
+
get(componentId: string): ComponentConfig;
|
|
45
|
+
/**
|
|
46
|
+
* Retrieves all registered component configurations.
|
|
47
|
+
* @returns An array of all component configurations.
|
|
48
|
+
*/
|
|
49
|
+
getAll(): readonly ComponentConfig[];
|
|
50
|
+
/**
|
|
51
|
+
* Translates a key for a component in a given language, replacing variables.
|
|
52
|
+
* @param componentId - The component ID.
|
|
53
|
+
* @param key - The translation key.
|
|
54
|
+
* @param variables - Optional variables for replacement.
|
|
55
|
+
* @param language - Optional language code (default is 'en-US').
|
|
56
|
+
* @returns The translated string.
|
|
57
|
+
* @throws {I18nError} If the language or translation key is not found.
|
|
58
|
+
*/
|
|
59
|
+
translate(componentId: string, key: string, variables?: Record<string, any>, language?: string): string;
|
|
60
|
+
/**
|
|
61
|
+
* Resolve plural form from a PluralString based on count variable.
|
|
62
|
+
* @param value - The string or PluralString to resolve.
|
|
63
|
+
* @param count - The count for pluralization.
|
|
64
|
+
* @param language - The language code.
|
|
65
|
+
* @returns The resolved plural form string.
|
|
66
|
+
*/
|
|
67
|
+
private resolvePluralForm;
|
|
68
|
+
/**
|
|
69
|
+
* Safely translates a key for a component, returning a fallback string on error.
|
|
70
|
+
* @param componentId - The component ID.
|
|
71
|
+
* @param key - The translation key.
|
|
72
|
+
* @param variables - Optional variables for replacement.
|
|
73
|
+
* @param language - Optional language code.
|
|
74
|
+
* @returns The translated string or a fallback string if translation fails.
|
|
75
|
+
*/
|
|
76
|
+
safeTranslate(componentId: string, key: string, variables?: Record<string, any>, language?: string): string;
|
|
77
|
+
/**
|
|
78
|
+
* Validates a component configuration for missing keys across languages.
|
|
79
|
+
* @param config - The component configuration to validate.
|
|
80
|
+
* @returns ValidationResult containing errors and warnings.
|
|
81
|
+
*/
|
|
82
|
+
private validate;
|
|
83
|
+
/**
|
|
84
|
+
* Sets constants for variable replacement.
|
|
85
|
+
* @param constants - The constants to set.
|
|
86
|
+
*/
|
|
87
|
+
setConstants(constants: Record<string, any>): void;
|
|
88
|
+
/**
|
|
89
|
+
* Clears all registered components and aliases.
|
|
90
|
+
*/
|
|
91
|
+
clear(): void;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=component-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-store.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/core/component-store.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAKlE;;GAEG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,UAAU,CAAsC;IACxD,OAAO,CAAC,QAAQ,CAA6B;IAC7C,OAAO,CAAC,SAAS,CAAC,CAAsB;IAExC;;;OAGG;gBACS,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAI3C;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,eAAe,GAAG,gBAAgB;IAkBnD;;;;;;OAMG;IACH,MAAM,CACJ,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAC9C,gBAAgB;IAenB;;;;OAIG;IACH,GAAG,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO;IAIjC;;;;;OAKG;IACH,GAAG,CAAC,WAAW,EAAE,MAAM,GAAG,eAAe;IASzC;;;OAGG;IACH,MAAM,IAAI,SAAS,eAAe,EAAE;IAIpC;;;;;;;;OAQG;IACH,SAAS,CACP,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,MAAM,EACX,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC/B,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM;IAoBT;;;;;;OAMG;IACH,OAAO,CAAC,iBAAiB;IAsBzB;;;;;;;OAOG;IACH,aAAa,CACX,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,MAAM,EACX,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC/B,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM;IAQT;;;;OAIG;IACH,OAAO,CAAC,QAAQ;IA6BhB;;;OAGG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;IAIlD;;OAEG;IACH,KAAK,IAAI,IAAI;CAId"}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Component storage (no generics)
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ComponentStore = void 0;
|
|
7
|
+
const i18n_error_1 = require("../errors/i18n-error");
|
|
8
|
+
const language_plural_map_1 = require("../pluralization/language-plural-map");
|
|
9
|
+
const plural_types_1 = require("../types/plural-types");
|
|
10
|
+
const utils_1 = require("../utils");
|
|
11
|
+
/**
|
|
12
|
+
* Class representing a storage for component configurations and translations.
|
|
13
|
+
*/
|
|
14
|
+
class ComponentStore {
|
|
15
|
+
components = new Map();
|
|
16
|
+
aliasMap = new Map();
|
|
17
|
+
constants;
|
|
18
|
+
/**
|
|
19
|
+
* Creates a new ComponentStore instance.
|
|
20
|
+
* @param constants - Optional constants to be used in variable replacement.
|
|
21
|
+
*/
|
|
22
|
+
constructor(constants) {
|
|
23
|
+
this.constants = constants;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Registers a new component configuration.
|
|
27
|
+
* @param config - The component configuration to register.
|
|
28
|
+
* @returns ValidationResult indicating the result of the registration.
|
|
29
|
+
* @throws {I18nError} If the component ID is already registered.
|
|
30
|
+
*/
|
|
31
|
+
register(config) {
|
|
32
|
+
if (this.components.has(config.id)) {
|
|
33
|
+
throw i18n_error_1.I18nError.duplicateComponent(config.id);
|
|
34
|
+
}
|
|
35
|
+
const validation = this.validate(config);
|
|
36
|
+
this.components.set(config.id, config);
|
|
37
|
+
// Register aliases
|
|
38
|
+
if (config.aliases) {
|
|
39
|
+
for (const alias of config.aliases) {
|
|
40
|
+
this.aliasMap.set(alias, config.id);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return validation;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Updates an existing component's strings.
|
|
47
|
+
* @param componentId - The ID of the component to update.
|
|
48
|
+
* @param strings - The new strings to merge into the component.
|
|
49
|
+
* @returns ValidationResult indicating the result of the update.
|
|
50
|
+
* @throws {I18nError} If the component is not found.
|
|
51
|
+
*/
|
|
52
|
+
update(componentId, strings) {
|
|
53
|
+
const existing = this.components.get(componentId);
|
|
54
|
+
if (!existing) {
|
|
55
|
+
throw i18n_error_1.I18nError.componentNotFound(componentId);
|
|
56
|
+
}
|
|
57
|
+
const updated = {
|
|
58
|
+
...existing,
|
|
59
|
+
strings: { ...existing.strings, ...strings },
|
|
60
|
+
};
|
|
61
|
+
this.components.set(componentId, updated);
|
|
62
|
+
return this.validate(updated);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Checks if a component or alias is registered.
|
|
66
|
+
* @param componentId - The component ID or alias to check.
|
|
67
|
+
* @returns True if the component or alias is registered, false otherwise.
|
|
68
|
+
*/
|
|
69
|
+
has(componentId) {
|
|
70
|
+
return this.components.has(componentId) || this.aliasMap.has(componentId);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Retrieves a component configuration by ID or alias.
|
|
74
|
+
* @param componentId - The component ID or alias to retrieve.
|
|
75
|
+
* @returns The component configuration.
|
|
76
|
+
* @throws {I18nError} If the component is not found.
|
|
77
|
+
*/
|
|
78
|
+
get(componentId) {
|
|
79
|
+
const id = this.aliasMap.get(componentId) || componentId;
|
|
80
|
+
const component = this.components.get(id);
|
|
81
|
+
if (!component) {
|
|
82
|
+
throw i18n_error_1.I18nError.componentNotFound(componentId);
|
|
83
|
+
}
|
|
84
|
+
return component;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Retrieves all registered component configurations.
|
|
88
|
+
* @returns An array of all component configurations.
|
|
89
|
+
*/
|
|
90
|
+
getAll() {
|
|
91
|
+
return Array.from(this.components.values());
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Translates a key for a component in a given language, replacing variables.
|
|
95
|
+
* @param componentId - The component ID.
|
|
96
|
+
* @param key - The translation key.
|
|
97
|
+
* @param variables - Optional variables for replacement.
|
|
98
|
+
* @param language - Optional language code (default is 'en-US').
|
|
99
|
+
* @returns The translated string.
|
|
100
|
+
* @throws {I18nError} If the language or translation key is not found.
|
|
101
|
+
*/
|
|
102
|
+
translate(componentId, key, variables, language) {
|
|
103
|
+
const component = this.get(componentId);
|
|
104
|
+
const lang = language || 'en-US';
|
|
105
|
+
const langStrings = component.strings[lang];
|
|
106
|
+
if (!langStrings) {
|
|
107
|
+
throw i18n_error_1.I18nError.languageNotFound(lang);
|
|
108
|
+
}
|
|
109
|
+
const value = langStrings[key];
|
|
110
|
+
if (!value) {
|
|
111
|
+
throw i18n_error_1.I18nError.translationMissing(componentId, key, lang);
|
|
112
|
+
}
|
|
113
|
+
// Resolve plural form if needed
|
|
114
|
+
const translation = this.resolvePluralForm(value, variables?.count, lang);
|
|
115
|
+
return (0, utils_1.replaceVariables)(translation, variables, this.constants);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Resolve plural form from a PluralString based on count variable.
|
|
119
|
+
* @param value - The string or PluralString to resolve.
|
|
120
|
+
* @param count - The count for pluralization.
|
|
121
|
+
* @param language - The language code.
|
|
122
|
+
* @returns The resolved plural form string.
|
|
123
|
+
*/
|
|
124
|
+
resolvePluralForm(value, count, language) {
|
|
125
|
+
// If it's a simple string, return as-is
|
|
126
|
+
if (typeof value === 'string') {
|
|
127
|
+
return value;
|
|
128
|
+
}
|
|
129
|
+
// If no count provided, use 'other' form or first available
|
|
130
|
+
if (count === undefined) {
|
|
131
|
+
return (0, plural_types_1.resolvePluralString)(value, 'other') || '';
|
|
132
|
+
}
|
|
133
|
+
// Get the appropriate plural category for this count and language
|
|
134
|
+
const category = (0, language_plural_map_1.getPluralCategory)(language, count);
|
|
135
|
+
// Resolve the plural form with fallback logic
|
|
136
|
+
return (0, plural_types_1.resolvePluralString)(value, category) || '';
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Safely translates a key for a component, returning a fallback string on error.
|
|
140
|
+
* @param componentId - The component ID.
|
|
141
|
+
* @param key - The translation key.
|
|
142
|
+
* @param variables - Optional variables for replacement.
|
|
143
|
+
* @param language - Optional language code.
|
|
144
|
+
* @returns The translated string or a fallback string if translation fails.
|
|
145
|
+
*/
|
|
146
|
+
safeTranslate(componentId, key, variables, language) {
|
|
147
|
+
try {
|
|
148
|
+
return this.translate(componentId, key, variables, language);
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
return `[${componentId}.${key}]`;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Validates a component configuration for missing keys across languages.
|
|
156
|
+
* @param config - The component configuration to validate.
|
|
157
|
+
* @returns ValidationResult containing errors and warnings.
|
|
158
|
+
*/
|
|
159
|
+
validate(config) {
|
|
160
|
+
const errors = [];
|
|
161
|
+
const warnings = [];
|
|
162
|
+
// Check if all languages have all keys
|
|
163
|
+
const allKeys = new Set();
|
|
164
|
+
for (const langStrings of Object.values(config.strings)) {
|
|
165
|
+
for (const key of Object.keys(langStrings)) {
|
|
166
|
+
allKeys.add(key);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
for (const [lang, langStrings] of Object.entries(config.strings)) {
|
|
170
|
+
for (const key of allKeys) {
|
|
171
|
+
if (!langStrings[key]) {
|
|
172
|
+
warnings.push(`Missing key '${key}' for language '${lang}' in component '${config.id}'`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return {
|
|
177
|
+
isValid: errors.length === 0,
|
|
178
|
+
errors,
|
|
179
|
+
warnings,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Sets constants for variable replacement.
|
|
184
|
+
* @param constants - The constants to set.
|
|
185
|
+
*/
|
|
186
|
+
setConstants(constants) {
|
|
187
|
+
this.constants = constants;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Clears all registered components and aliases.
|
|
191
|
+
*/
|
|
192
|
+
clear() {
|
|
193
|
+
this.components.clear();
|
|
194
|
+
this.aliasMap.clear();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
exports.ComponentStore = ComponentStore;
|
|
198
|
+
//# sourceMappingURL=component-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-store.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/core/component-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
+
/** Current user-facing language code. */
|
|
6
|
+
language: string;
|
|
7
|
+
/** Current administrative language code. */
|
|
8
|
+
adminLanguage: string;
|
|
9
|
+
/** Active context space: 'admin' or 'user'. */
|
|
10
|
+
currentSpace: 'admin' | 'user';
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* ContextManager handles creation and management of per-instance translation contexts,
|
|
14
|
+
* including separate user and admin languages and context switching.
|
|
15
|
+
*/
|
|
16
|
+
export declare class ContextManager {
|
|
17
|
+
private contexts;
|
|
18
|
+
/**
|
|
19
|
+
* Creates a new context for a given instance key with a default language.
|
|
20
|
+
*
|
|
21
|
+
* @param instanceKey Unique identifier for the context instance.
|
|
22
|
+
* @param defaultLanguage Language code to initialize both user and admin contexts.
|
|
23
|
+
* @returns The newly created Context object.
|
|
24
|
+
*/
|
|
25
|
+
create(instanceKey: string, defaultLanguage: string): Context;
|
|
26
|
+
/**
|
|
27
|
+
* Retrieves the context for a given instance key.
|
|
28
|
+
*
|
|
29
|
+
* @param instanceKey Unique identifier for the context instance.
|
|
30
|
+
* @returns The Context object associated with the key.
|
|
31
|
+
* @throws {Error} If no context exists for the provided key.
|
|
32
|
+
*/
|
|
33
|
+
get(instanceKey: string): Context;
|
|
34
|
+
/**
|
|
35
|
+
* Sets the user-facing language for the specified context.
|
|
36
|
+
*
|
|
37
|
+
* @param instanceKey Unique identifier for the context instance.
|
|
38
|
+
* @param language New language code for user-facing translations.
|
|
39
|
+
*/
|
|
40
|
+
setLanguage(instanceKey: string, language: string): void;
|
|
41
|
+
/**
|
|
42
|
+
* Sets the administrative language for the specified context.
|
|
43
|
+
*
|
|
44
|
+
* @param instanceKey Unique identifier for the context instance.
|
|
45
|
+
* @param language New language code for administrative translations.
|
|
46
|
+
*/
|
|
47
|
+
setAdminLanguage(instanceKey: string, language: string): void;
|
|
48
|
+
/**
|
|
49
|
+
* Switches the active context space to 'admin'.
|
|
50
|
+
*
|
|
51
|
+
* @param instanceKey Unique identifier for the context instance.
|
|
52
|
+
*/
|
|
53
|
+
switchToAdmin(instanceKey: string): void;
|
|
54
|
+
/**
|
|
55
|
+
* Switches the active context space to 'user'.
|
|
56
|
+
*
|
|
57
|
+
* @param instanceKey Unique identifier for the context instance.
|
|
58
|
+
*/
|
|
59
|
+
switchToUser(instanceKey: string): void;
|
|
60
|
+
/**
|
|
61
|
+
* Retrieves the currently active language based on the context space.
|
|
62
|
+
*
|
|
63
|
+
* @param instanceKey Unique identifier for the context instance.
|
|
64
|
+
* @returns The active language code ('adminLanguage' or 'language').
|
|
65
|
+
*/
|
|
66
|
+
getCurrentLanguage(instanceKey: string): string;
|
|
67
|
+
/**
|
|
68
|
+
* Clears all stored contexts, removing all instance data.
|
|
69
|
+
*/
|
|
70
|
+
clear(): void;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=context-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-manager.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/core/context-manager.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,aAAa,EAAE,MAAM,CAAC;IACtB,+CAA+C;IAC/C,YAAY,EAAE,OAAO,GAAG,MAAM,CAAC;CAChC;AAED;;;GAGG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAA8B;IAE9C;;;;;;OAMG;IACH,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO;IAU7D;;;;;;OAMG;IACH,GAAG,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO;IAQjC;;;;;OAKG;IACH,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAKxD;;;;;OAKG;IACH,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAK7D;;;;OAIG;IACH,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAKxC;;;;OAIG;IACH,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAKvC;;;;;OAKG;IACH,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM;IAO/C;;OAEG;IACH,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ContextManager = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* ContextManager handles creation and management of per-instance translation contexts,
|
|
6
|
+
* including separate user and admin languages and context switching.
|
|
7
|
+
*/
|
|
8
|
+
class ContextManager {
|
|
9
|
+
contexts = new Map();
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new context for a given instance key with a default language.
|
|
12
|
+
*
|
|
13
|
+
* @param instanceKey Unique identifier for the context instance.
|
|
14
|
+
* @param defaultLanguage Language code to initialize both user and admin contexts.
|
|
15
|
+
* @returns The newly created Context object.
|
|
16
|
+
*/
|
|
17
|
+
create(instanceKey, defaultLanguage) {
|
|
18
|
+
const context = {
|
|
19
|
+
language: defaultLanguage,
|
|
20
|
+
adminLanguage: defaultLanguage,
|
|
21
|
+
currentSpace: 'user',
|
|
22
|
+
};
|
|
23
|
+
this.contexts.set(instanceKey, context);
|
|
24
|
+
return context;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Retrieves the context for a given instance key.
|
|
28
|
+
*
|
|
29
|
+
* @param instanceKey Unique identifier for the context instance.
|
|
30
|
+
* @returns The Context object associated with the key.
|
|
31
|
+
* @throws {Error} If no context exists for the provided key.
|
|
32
|
+
*/
|
|
33
|
+
get(instanceKey) {
|
|
34
|
+
const context = this.contexts.get(instanceKey);
|
|
35
|
+
if (!context) {
|
|
36
|
+
throw new Error(`Context '${instanceKey}' not found`);
|
|
37
|
+
}
|
|
38
|
+
return context;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Sets the user-facing language for the specified context.
|
|
42
|
+
*
|
|
43
|
+
* @param instanceKey Unique identifier for the context instance.
|
|
44
|
+
* @param language New language code for user-facing translations.
|
|
45
|
+
*/
|
|
46
|
+
setLanguage(instanceKey, language) {
|
|
47
|
+
const context = this.get(instanceKey);
|
|
48
|
+
context.language = language;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Sets the administrative language for the specified context.
|
|
52
|
+
*
|
|
53
|
+
* @param instanceKey Unique identifier for the context instance.
|
|
54
|
+
* @param language New language code for administrative translations.
|
|
55
|
+
*/
|
|
56
|
+
setAdminLanguage(instanceKey, language) {
|
|
57
|
+
const context = this.get(instanceKey);
|
|
58
|
+
context.adminLanguage = language;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Switches the active context space to 'admin'.
|
|
62
|
+
*
|
|
63
|
+
* @param instanceKey Unique identifier for the context instance.
|
|
64
|
+
*/
|
|
65
|
+
switchToAdmin(instanceKey) {
|
|
66
|
+
const context = this.get(instanceKey);
|
|
67
|
+
context.currentSpace = 'admin';
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Switches the active context space to 'user'.
|
|
71
|
+
*
|
|
72
|
+
* @param instanceKey Unique identifier for the context instance.
|
|
73
|
+
*/
|
|
74
|
+
switchToUser(instanceKey) {
|
|
75
|
+
const context = this.get(instanceKey);
|
|
76
|
+
context.currentSpace = 'user';
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Retrieves the currently active language based on the context space.
|
|
80
|
+
*
|
|
81
|
+
* @param instanceKey Unique identifier for the context instance.
|
|
82
|
+
* @returns The active language code ('adminLanguage' or 'language').
|
|
83
|
+
*/
|
|
84
|
+
getCurrentLanguage(instanceKey) {
|
|
85
|
+
const context = this.get(instanceKey);
|
|
86
|
+
return context.currentSpace === 'admin'
|
|
87
|
+
? context.adminLanguage
|
|
88
|
+
: context.language;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Clears all stored contexts, removing all instance data.
|
|
92
|
+
*/
|
|
93
|
+
clear() {
|
|
94
|
+
this.contexts.clear();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.ContextManager = ContextManager;
|
|
98
|
+
//# sourceMappingURL=context-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-manager.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/core/context-manager.ts"],"names":[],"mappings":";;;AAYA;;;GAGG;AACH,MAAa,cAAc;IACjB,QAAQ,GAAG,IAAI,GAAG,EAAmB,CAAC;IAE9C;;;;;;OAMG;IACH,MAAM,CAAC,WAAmB,EAAE,eAAuB;QACjD,MAAM,OAAO,GAAY;YACvB,QAAQ,EAAE,eAAe;YACzB,aAAa,EAAE,eAAe;YAC9B,YAAY,EAAE,MAAM;SACrB,CAAC;QACF,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QACxC,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;;;;;OAMG;IACH,GAAG,CAAC,WAAmB;QACrB,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAC/C,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,YAAY,WAAW,aAAa,CAAC,CAAC;QACxD,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;;;;OAKG;IACH,WAAW,CAAC,WAAmB,EAAE,QAAgB;QAC/C,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACtC,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC9B,CAAC;IAED;;;;;OAKG;IACH,gBAAgB,CAAC,WAAmB,EAAE,QAAgB;QACpD,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACtC,OAAO,CAAC,aAAa,GAAG,QAAQ,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACH,aAAa,CAAC,WAAmB;QAC/B,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACtC,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACH,YAAY,CAAC,WAAmB;QAC9B,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACtC,OAAO,CAAC,YAAY,GAAG,MAAM,CAAC;IAChC,CAAC;IAED;;;;;OAKG;IACH,kBAAkB,CAAC,WAAmB;QACpC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACtC,OAAO,OAAO,CAAC,YAAY,KAAK,OAAO;YACrC,CAAC,CAAC,OAAO,CAAC,aAAa;YACvB,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;CACF;AAhGD,wCAgGC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enum translation registry (v2 - no generics)
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Registry for managing translations of enum values across multiple languages.
|
|
6
|
+
* Provides a centralized way to register and translate enum values.
|
|
7
|
+
*/
|
|
8
|
+
export declare class EnumRegistry {
|
|
9
|
+
private translations;
|
|
10
|
+
private enumNames;
|
|
11
|
+
private translateFn?;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new EnumRegistry instance.
|
|
14
|
+
* @param translateFn - Optional translation function for error messages
|
|
15
|
+
*/
|
|
16
|
+
constructor(translateFn?: (key: string, vars?: Record<string, any>) => string);
|
|
17
|
+
/**
|
|
18
|
+
* Registers an enum with its translations for all languages.
|
|
19
|
+
* @template TEnum - The enum value type (string or number)
|
|
20
|
+
* @param enumObj - The enum object to register
|
|
21
|
+
* @param translations - Mapping of language codes to enum value translations
|
|
22
|
+
* @param enumName - Human-readable name for the enum (used in error messages)
|
|
23
|
+
*/
|
|
24
|
+
register<TEnum extends string | number>(enumObj: Record<string, TEnum>, translations: Record<string, Record<string, string>>, enumName: string): void;
|
|
25
|
+
/**
|
|
26
|
+
* Translates an enum value to a specific language.
|
|
27
|
+
* @template TEnum - The enum value type
|
|
28
|
+
* @param enumObj - The registered enum object
|
|
29
|
+
* @param value - The enum value to translate
|
|
30
|
+
* @param language - The target language code
|
|
31
|
+
* @returns The translated string
|
|
32
|
+
* @throws {I18nError} If the enum, language, or value is not found
|
|
33
|
+
*/
|
|
34
|
+
translate<TEnum extends string | number>(enumObj: Record<string, TEnum>, value: TEnum, language: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* Checks if an enum has been registered.
|
|
37
|
+
* @param enumObj - The enum object to check
|
|
38
|
+
* @returns True if the enum is registered, false otherwise
|
|
39
|
+
*/
|
|
40
|
+
has(enumObj: any): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Gets the human-readable name of an enum.
|
|
43
|
+
* @param enumObj - The enum object
|
|
44
|
+
* @returns The enum name or 'UnknownEnum' if not set
|
|
45
|
+
*/
|
|
46
|
+
private getEnumName;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=enum-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enum-registry.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/core/enum-registry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,YAAY,CAA0D;IAC9E,OAAO,CAAC,SAAS,CAA8B;IAC/C,OAAO,CAAC,WAAW,CAAC,CAAsD;IAE1E;;;OAGG;gBAED,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,MAAM;IAKnE;;;;;;OAMG;IACH,QAAQ,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,EACpC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAC9B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EACpD,QAAQ,EAAE,MAAM,GACf,IAAI;IAKP;;;;;;;;OAQG;IACH,SAAS,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,EACrC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAC9B,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,MAAM,GACf,MAAM;IAkCT;;;;OAIG;IACH,GAAG,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO;IAI1B;;;;OAIG;IACH,OAAO,CAAC,WAAW;CAGpB"}
|