@digitaldefiance/i18n-lib 3.8.0 → 3.8.1
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/LICENSE +21 -0
- package/README.md +182 -0
- package/package.json +12 -4
- package/src/{active-context.d.ts → active-context.ts} +0 -1
- package/src/builders/i18n-builder.ts +82 -0
- package/src/builders/{index.d.ts → index.ts} +1 -1
- package/src/component-definition.ts +11 -0
- package/src/component-registration.ts +29 -0
- package/src/component-registry.ts +432 -0
- package/src/context-error-type.ts +7 -0
- package/src/core/component-store.ts +241 -0
- package/src/core/context-manager.ts +113 -0
- package/src/core/enum-registry.ts +106 -0
- package/src/core/i18n-engine.ts +710 -0
- package/src/core/{index.d.ts → index.ts} +4 -1
- package/src/core/language-registry.ts +345 -0
- package/src/{core-component-id.d.ts → core-component-id.ts} +1 -2
- package/src/core-i18n.ts +270 -0
- package/src/core-plugin-factory.ts +111 -0
- package/src/core-string-key.ts +59 -0
- package/src/create-translation-adapter.ts +93 -0
- package/src/enum-registry.ts +152 -0
- package/src/errors/{base.d.ts → base.ts} +1 -1
- package/src/errors/context-error.ts +122 -0
- package/src/errors/enhanced-error-base.ts +260 -0
- package/src/errors/handleable.ts +152 -0
- package/src/errors/i18n-error.ts +494 -0
- package/src/errors/{index.d.ts → index.ts} +4 -1
- package/src/errors/simple-typed-error.ts +81 -0
- package/src/errors/{translatable-exports.d.ts → translatable-exports.ts} +1 -1
- package/src/errors/translatable-generic.ts +245 -0
- package/src/errors/translatable-handleable-generic.ts +222 -0
- package/src/errors/translatable.ts +138 -0
- package/src/errors/typed-handleable.ts +138 -0
- package/src/errors/typed.ts +617 -0
- package/src/gender/{gender-categories.d.ts → gender-categories.ts} +6 -2
- package/src/gender/gender-resolver.ts +40 -0
- package/src/gender/{index.d.ts → index.ts} +0 -1
- package/src/global-active-context.ts +266 -0
- package/src/icu/ast.ts +56 -0
- package/src/icu/compiler.ts +96 -0
- package/src/icu/formatter-registry.ts +36 -0
- package/src/icu/formatters/base-formatter.ts +8 -0
- package/src/icu/formatters/date-formatter.ts +30 -0
- package/src/icu/formatters/number-formatter.ts +32 -0
- package/src/icu/formatters/plural-formatter.ts +12 -0
- package/src/icu/formatters/select-formatter.ts +7 -0
- package/src/icu/formatters/selectordinal-formatter.ts +17 -0
- package/src/icu/formatters/time-formatter.ts +30 -0
- package/src/icu/helpers.ts +34 -0
- package/src/icu/parser.ts +242 -0
- package/src/icu/runtime.ts +37 -0
- package/src/icu/tokenizer.ts +212 -0
- package/src/icu/validator.ts +163 -0
- package/src/{index.d.ts → index.ts} +38 -6
- package/src/interfaces/active-context.interface.ts +41 -0
- package/src/interfaces/component-config.interface.ts +17 -0
- package/src/interfaces/engine-config.interface.ts +22 -0
- package/src/interfaces/global-active-context.ts +39 -0
- package/src/interfaces/handleable-error-options.ts +13 -0
- package/src/interfaces/handleable.ts +20 -0
- package/src/interfaces/i18n-engine.interface.ts +57 -0
- package/src/interfaces/{index.d.ts → index.ts} +1 -1
- package/src/interfaces/language-definition.interface.ts +17 -0
- package/src/interfaces/translation-options.interface.ts +15 -0
- package/src/interfaces/validation-result.interface.ts +24 -0
- package/src/language-codes.ts +40 -0
- package/src/language-definition.ts +13 -0
- package/src/plugin-i18n-engine.ts +707 -0
- package/src/pluralization/{index.d.ts → index.ts} +1 -1
- package/src/pluralization/language-plural-map.ts +186 -0
- package/src/pluralization/{plural-categories.d.ts → plural-categories.ts} +5 -3
- package/src/pluralization/plural-rules.ts +228 -0
- package/src/registry-config.ts +16 -0
- package/src/registry-error-type.ts +19 -0
- package/src/registry-error.ts +100 -0
- package/src/strict-types.ts +35 -0
- package/src/strings/de.ts +75 -0
- package/src/strings/en-GB.ts +74 -0
- package/src/strings/en-US.ts +74 -0
- package/src/strings/es.ts +74 -0
- package/src/strings/fr.ts +75 -0
- package/src/strings/ja.ts +73 -0
- package/src/strings/uk.ts +73 -0
- package/src/strings/zh-CN.ts +72 -0
- package/src/template.ts +72 -0
- package/src/translation-engine.ts +18 -0
- package/src/translation-request.ts +12 -0
- package/src/translation-response.ts +8 -0
- package/src/types/engine.ts +55 -0
- package/src/types/{index.d.ts → index.ts} +1 -1
- package/src/types/{plural-types.d.ts → plural-types.ts} +29 -3
- package/src/{types.d.ts → types.ts} +72 -21
- package/src/utils/currency.ts +141 -0
- package/src/utils/html-escape.ts +55 -0
- package/src/utils/{index.d.ts → index.ts} +0 -1
- package/src/utils/lru-cache.ts +76 -0
- package/src/utils/{plural-helpers.d.ts → plural-helpers.ts} +14 -4
- package/src/utils/{safe-object.js → safe-object.ts} +37 -34
- package/src/utils/string-utils.ts +77 -0
- package/src/utils/timezone.ts +76 -0
- package/src/utils/validation.ts +66 -0
- package/src/utils.ts +215 -0
- package/src/validation/{index.d.ts → index.ts} +0 -1
- package/src/validation/plural-validator.ts +168 -0
- package/src/validation-config.ts +11 -0
- package/src/validation-result.ts +12 -0
- package/src/active-context.d.ts.map +0 -1
- package/src/active-context.js +0 -3
- package/src/active-context.js.map +0 -1
- package/src/builders/i18n-builder.d.ts +0 -26
- package/src/builders/i18n-builder.d.ts.map +0 -1
- package/src/builders/i18n-builder.js +0 -70
- package/src/builders/i18n-builder.js.map +0 -1
- package/src/builders/index.d.ts.map +0 -1
- package/src/builders/index.js +0 -8
- package/src/builders/index.js.map +0 -1
- package/src/component-definition.d.ts +0 -12
- package/src/component-definition.d.ts.map +0 -1
- package/src/component-definition.js +0 -3
- package/src/component-definition.js.map +0 -1
- package/src/component-registration.d.ts +0 -22
- package/src/component-registration.d.ts.map +0 -1
- package/src/component-registration.js +0 -3
- package/src/component-registration.js.map +0 -1
- package/src/component-registry.d.ts +0 -102
- package/src/component-registry.d.ts.map +0 -1
- package/src/component-registry.js +0 -282
- package/src/component-registry.js.map +0 -1
- package/src/context-error-type.d.ts +0 -8
- package/src/context-error-type.d.ts.map +0 -1
- package/src/context-error-type.js +0 -12
- package/src/context-error-type.js.map +0 -1
- package/src/core/component-store.d.ts +0 -93
- package/src/core/component-store.d.ts.map +0 -1
- package/src/core/component-store.js +0 -198
- package/src/core/component-store.js.map +0 -1
- package/src/core/context-manager.d.ts +0 -72
- package/src/core/context-manager.d.ts.map +0 -1
- package/src/core/context-manager.js +0 -98
- package/src/core/context-manager.js.map +0 -1
- package/src/core/enum-registry.d.ts +0 -48
- package/src/core/enum-registry.d.ts.map +0 -1
- package/src/core/enum-registry.js +0 -85
- package/src/core/enum-registry.js.map +0 -1
- package/src/core/i18n-engine.d.ts +0 -241
- package/src/core/i18n-engine.d.ts.map +0 -1
- package/src/core/i18n-engine.js +0 -568
- package/src/core/i18n-engine.js.map +0 -1
- package/src/core/index.d.ts.map +0 -1
- package/src/core/index.js +0 -21
- package/src/core/index.js.map +0 -1
- package/src/core/language-registry.d.ts +0 -180
- package/src/core/language-registry.d.ts.map +0 -1
- package/src/core/language-registry.js +0 -298
- package/src/core/language-registry.js.map +0 -1
- package/src/core-component-id.d.ts.map +0 -1
- package/src/core-component-id.js +0 -9
- package/src/core-component-id.js.map +0 -1
- package/src/core-i18n.d.ts +0 -69
- package/src/core-i18n.d.ts.map +0 -1
- package/src/core-i18n.js +0 -219
- package/src/core-i18n.js.map +0 -1
- package/src/core-plugin-factory.d.ts +0 -28
- package/src/core-plugin-factory.d.ts.map +0 -1
- package/src/core-plugin-factory.js +0 -80
- package/src/core-plugin-factory.js.map +0 -1
- package/src/core-string-key.d.ts +0 -52
- package/src/core-string-key.d.ts.map +0 -1
- package/src/core-string-key.js +0 -61
- package/src/core-string-key.js.map +0 -1
- package/src/create-translation-adapter.d.ts +0 -33
- package/src/create-translation-adapter.d.ts.map +0 -1
- package/src/create-translation-adapter.js +0 -72
- package/src/create-translation-adapter.js.map +0 -1
- package/src/enum-registry.d.ts +0 -65
- package/src/enum-registry.d.ts.map +0 -1
- package/src/enum-registry.js +0 -123
- package/src/enum-registry.js.map +0 -1
- package/src/errors/base.d.ts.map +0 -1
- package/src/errors/base.js +0 -11
- package/src/errors/base.js.map +0 -1
- package/src/errors/context-error.d.ts +0 -50
- package/src/errors/context-error.d.ts.map +0 -1
- package/src/errors/context-error.js +0 -93
- package/src/errors/context-error.js.map +0 -1
- package/src/errors/enhanced-error-base.d.ts +0 -125
- package/src/errors/enhanced-error-base.d.ts.map +0 -1
- package/src/errors/enhanced-error-base.js +0 -165
- package/src/errors/enhanced-error-base.js.map +0 -1
- package/src/errors/handleable.d.ts +0 -83
- package/src/errors/handleable.d.ts.map +0 -1
- package/src/errors/handleable.js +0 -136
- package/src/errors/handleable.js.map +0 -1
- package/src/errors/i18n-error.d.ts +0 -211
- package/src/errors/i18n-error.d.ts.map +0 -1
- package/src/errors/i18n-error.js +0 -358
- package/src/errors/i18n-error.js.map +0 -1
- package/src/errors/index.d.ts.map +0 -1
- package/src/errors/index.js +0 -17
- package/src/errors/index.js.map +0 -1
- package/src/errors/simple-typed-error.d.ts +0 -53
- package/src/errors/simple-typed-error.d.ts.map +0 -1
- package/src/errors/simple-typed-error.js +0 -51
- package/src/errors/simple-typed-error.js.map +0 -1
- package/src/errors/translatable-exports.d.ts.map +0 -1
- package/src/errors/translatable-exports.js +0 -15
- package/src/errors/translatable-exports.js.map +0 -1
- package/src/errors/translatable-generic.d.ts +0 -87
- package/src/errors/translatable-generic.d.ts.map +0 -1
- package/src/errors/translatable-generic.js +0 -139
- package/src/errors/translatable-generic.js.map +0 -1
- package/src/errors/translatable-handleable-generic.d.ts +0 -116
- package/src/errors/translatable-handleable-generic.d.ts.map +0 -1
- package/src/errors/translatable-handleable-generic.js +0 -121
- package/src/errors/translatable-handleable-generic.js.map +0 -1
- package/src/errors/translatable.d.ts +0 -63
- package/src/errors/translatable.d.ts.map +0 -1
- package/src/errors/translatable.js +0 -85
- package/src/errors/translatable.js.map +0 -1
- package/src/errors/typed-handleable.d.ts +0 -62
- package/src/errors/typed-handleable.d.ts.map +0 -1
- package/src/errors/typed-handleable.js +0 -108
- package/src/errors/typed-handleable.js.map +0 -1
- package/src/errors/typed.d.ts +0 -206
- package/src/errors/typed.d.ts.map +0 -1
- package/src/errors/typed.js +0 -458
- package/src/errors/typed.js.map +0 -1
- package/src/gender/gender-categories.d.ts.map +0 -1
- package/src/gender/gender-categories.js +0 -15
- package/src/gender/gender-categories.js.map +0 -1
- package/src/gender/gender-resolver.d.ts +0 -14
- package/src/gender/gender-resolver.d.ts.map +0 -1
- package/src/gender/gender-resolver.js +0 -35
- package/src/gender/gender-resolver.js.map +0 -1
- package/src/gender/index.d.ts.map +0 -1
- package/src/gender/index.js +0 -6
- package/src/gender/index.js.map +0 -1
- package/src/global-active-context.d.ts +0 -50
- package/src/global-active-context.d.ts.map +0 -1
- package/src/global-active-context.js +0 -185
- package/src/global-active-context.js.map +0 -1
- package/src/icu/ast.d.ts +0 -48
- package/src/icu/ast.d.ts.map +0 -1
- package/src/icu/ast.js +0 -16
- package/src/icu/ast.js.map +0 -1
- package/src/icu/compiler.d.ts +0 -16
- package/src/icu/compiler.d.ts.map +0 -1
- package/src/icu/compiler.js +0 -87
- package/src/icu/compiler.js.map +0 -1
- package/src/icu/formatter-registry.d.ts +0 -10
- package/src/icu/formatter-registry.d.ts.map +0 -1
- package/src/icu/formatter-registry.js +0 -34
- package/src/icu/formatter-registry.js.map +0 -1
- package/src/icu/formatters/base-formatter.d.ts +0 -8
- package/src/icu/formatters/base-formatter.d.ts.map +0 -1
- package/src/icu/formatters/base-formatter.js +0 -3
- package/src/icu/formatters/base-formatter.js.map +0 -1
- package/src/icu/formatters/date-formatter.d.ts +0 -5
- package/src/icu/formatters/date-formatter.d.ts.map +0 -1
- package/src/icu/formatters/date-formatter.js +0 -31
- package/src/icu/formatters/date-formatter.js.map +0 -1
- package/src/icu/formatters/number-formatter.d.ts +0 -5
- package/src/icu/formatters/number-formatter.d.ts.map +0 -1
- package/src/icu/formatters/number-formatter.js +0 -33
- package/src/icu/formatters/number-formatter.js.map +0 -1
- package/src/icu/formatters/plural-formatter.d.ts +0 -5
- package/src/icu/formatters/plural-formatter.d.ts.map +0 -1
- package/src/icu/formatters/plural-formatter.js +0 -15
- package/src/icu/formatters/plural-formatter.js.map +0 -1
- package/src/icu/formatters/select-formatter.d.ts +0 -5
- package/src/icu/formatters/select-formatter.d.ts.map +0 -1
- package/src/icu/formatters/select-formatter.js +0 -10
- package/src/icu/formatters/select-formatter.js.map +0 -1
- package/src/icu/formatters/selectordinal-formatter.d.ts +0 -5
- package/src/icu/formatters/selectordinal-formatter.d.ts.map +0 -1
- package/src/icu/formatters/selectordinal-formatter.js +0 -22
- package/src/icu/formatters/selectordinal-formatter.js.map +0 -1
- package/src/icu/formatters/time-formatter.d.ts +0 -5
- package/src/icu/formatters/time-formatter.d.ts.map +0 -1
- package/src/icu/formatters/time-formatter.js +0 -31
- package/src/icu/formatters/time-formatter.js.map +0 -1
- package/src/icu/helpers.d.ts +0 -9
- package/src/icu/helpers.d.ts.map +0 -1
- package/src/icu/helpers.js +0 -31
- package/src/icu/helpers.js.map +0 -1
- package/src/icu/parser.d.ts +0 -31
- package/src/icu/parser.d.ts.map +0 -1
- package/src/icu/parser.js +0 -203
- package/src/icu/parser.js.map +0 -1
- package/src/icu/runtime.d.ts +0 -10
- package/src/icu/runtime.d.ts.map +0 -1
- package/src/icu/runtime.js +0 -33
- package/src/icu/runtime.js.map +0 -1
- package/src/icu/tokenizer.d.ts +0 -37
- package/src/icu/tokenizer.d.ts.map +0 -1
- package/src/icu/tokenizer.js +0 -187
- package/src/icu/tokenizer.js.map +0 -1
- package/src/icu/validator.d.ts +0 -11
- package/src/icu/validator.d.ts.map +0 -1
- package/src/icu/validator.js +0 -140
- package/src/icu/validator.js.map +0 -1
- package/src/index.d.ts.map +0 -1
- package/src/index.js +0 -76
- package/src/index.js.map +0 -1
- package/src/interfaces/active-context.interface.d.ts +0 -36
- package/src/interfaces/active-context.interface.d.ts.map +0 -1
- package/src/interfaces/active-context.interface.js +0 -3
- package/src/interfaces/active-context.interface.js.map +0 -1
- package/src/interfaces/component-config.interface.d.ts +0 -16
- package/src/interfaces/component-config.interface.d.ts.map +0 -1
- package/src/interfaces/component-config.interface.js +0 -6
- package/src/interfaces/component-config.interface.js.map +0 -1
- package/src/interfaces/engine-config.interface.d.ts +0 -22
- package/src/interfaces/engine-config.interface.d.ts.map +0 -1
- package/src/interfaces/engine-config.interface.js +0 -6
- package/src/interfaces/engine-config.interface.js.map +0 -1
- package/src/interfaces/global-active-context.d.ts +0 -23
- package/src/interfaces/global-active-context.d.ts.map +0 -1
- package/src/interfaces/global-active-context.js +0 -3
- package/src/interfaces/global-active-context.js.map +0 -1
- package/src/interfaces/handleable-error-options.d.ts +0 -14
- package/src/interfaces/handleable-error-options.d.ts.map +0 -1
- package/src/interfaces/handleable-error-options.js +0 -3
- package/src/interfaces/handleable-error-options.js.map +0 -1
- package/src/interfaces/handleable.d.ts +0 -21
- package/src/interfaces/handleable.d.ts.map +0 -1
- package/src/interfaces/handleable.js +0 -3
- package/src/interfaces/handleable.js.map +0 -1
- package/src/interfaces/i18n-engine.interface.d.ts +0 -46
- package/src/interfaces/i18n-engine.interface.d.ts.map +0 -1
- package/src/interfaces/i18n-engine.interface.js +0 -6
- package/src/interfaces/i18n-engine.interface.js.map +0 -1
- package/src/interfaces/index.d.ts.map +0 -1
- package/src/interfaces/index.js +0 -7
- package/src/interfaces/index.js.map +0 -1
- package/src/interfaces/language-definition.interface.d.ts +0 -17
- package/src/interfaces/language-definition.interface.d.ts.map +0 -1
- package/src/interfaces/language-definition.interface.js +0 -6
- package/src/interfaces/language-definition.interface.js.map +0 -1
- package/src/interfaces/translation-options.interface.d.ts +0 -15
- package/src/interfaces/translation-options.interface.d.ts.map +0 -1
- package/src/interfaces/translation-options.interface.js +0 -6
- package/src/interfaces/translation-options.interface.js.map +0 -1
- package/src/interfaces/validation-result.interface.d.ts +0 -24
- package/src/interfaces/validation-result.interface.d.ts.map +0 -1
- package/src/interfaces/validation-result.interface.js +0 -6
- package/src/interfaces/validation-result.interface.js.map +0 -1
- package/src/language-codes.d.ts +0 -28
- package/src/language-codes.d.ts.map +0 -1
- package/src/language-codes.js +0 -32
- package/src/language-codes.js.map +0 -1
- package/src/language-definition.d.ts +0 -14
- package/src/language-definition.d.ts.map +0 -1
- package/src/language-definition.js +0 -3
- package/src/language-definition.js.map +0 -1
- package/src/plugin-i18n-engine.d.ts +0 -164
- package/src/plugin-i18n-engine.d.ts.map +0 -1
- package/src/plugin-i18n-engine.js +0 -493
- package/src/plugin-i18n-engine.js.map +0 -1
- package/src/pluralization/index.d.ts.map +0 -1
- package/src/pluralization/index.js +0 -10
- package/src/pluralization/index.js.map +0 -1
- package/src/pluralization/language-plural-map.d.ts +0 -29
- package/src/pluralization/language-plural-map.d.ts.map +0 -1
- package/src/pluralization/language-plural-map.js +0 -155
- package/src/pluralization/language-plural-map.js.map +0 -1
- package/src/pluralization/plural-categories.d.ts.map +0 -1
- package/src/pluralization/plural-categories.js +0 -8
- package/src/pluralization/plural-categories.js.map +0 -1
- package/src/pluralization/plural-rules.d.ts +0 -102
- package/src/pluralization/plural-rules.d.ts.map +0 -1
- package/src/pluralization/plural-rules.js +0 -263
- package/src/pluralization/plural-rules.js.map +0 -1
- package/src/registry-config.d.ts +0 -16
- package/src/registry-config.d.ts.map +0 -1
- package/src/registry-config.js +0 -3
- package/src/registry-config.js.map +0 -1
- package/src/registry-error-type.d.ts +0 -20
- package/src/registry-error-type.d.ts.map +0 -1
- package/src/registry-error-type.js +0 -24
- package/src/registry-error-type.js.map +0 -1
- package/src/registry-error.d.ts +0 -25
- package/src/registry-error.d.ts.map +0 -1
- package/src/registry-error.js +0 -63
- package/src/registry-error.js.map +0 -1
- package/src/strict-types.d.ts +0 -19
- package/src/strict-types.d.ts.map +0 -1
- package/src/strict-types.js +0 -18
- package/src/strict-types.js.map +0 -1
- package/src/strings/de.d.ts +0 -3
- package/src/strings/de.d.ts.map +0 -1
- package/src/strings/de.js +0 -57
- package/src/strings/de.js.map +0 -1
- package/src/strings/en-GB.d.ts +0 -3
- package/src/strings/en-GB.d.ts.map +0 -1
- package/src/strings/en-GB.js +0 -57
- package/src/strings/en-GB.js.map +0 -1
- package/src/strings/en-US.d.ts +0 -3
- package/src/strings/en-US.d.ts.map +0 -1
- package/src/strings/en-US.js +0 -57
- package/src/strings/en-US.js.map +0 -1
- package/src/strings/es.d.ts +0 -3
- package/src/strings/es.d.ts.map +0 -1
- package/src/strings/es.js +0 -57
- package/src/strings/es.js.map +0 -1
- package/src/strings/fr.d.ts +0 -3
- package/src/strings/fr.d.ts.map +0 -1
- package/src/strings/fr.js +0 -57
- package/src/strings/fr.js.map +0 -1
- package/src/strings/ja.d.ts +0 -3
- package/src/strings/ja.d.ts.map +0 -1
- package/src/strings/ja.js +0 -57
- package/src/strings/ja.js.map +0 -1
- package/src/strings/uk.d.ts +0 -3
- package/src/strings/uk.d.ts.map +0 -1
- package/src/strings/uk.js +0 -57
- package/src/strings/uk.js.map +0 -1
- package/src/strings/zh-CN.d.ts +0 -3
- package/src/strings/zh-CN.d.ts.map +0 -1
- package/src/strings/zh-CN.js +0 -57
- package/src/strings/zh-CN.js.map +0 -1
- package/src/template.d.ts +0 -13
- package/src/template.d.ts.map +0 -1
- package/src/template.js +0 -40
- package/src/template.js.map +0 -1
- package/src/translation-engine.d.ts +0 -9
- package/src/translation-engine.d.ts.map +0 -1
- package/src/translation-engine.js +0 -3
- package/src/translation-engine.js.map +0 -1
- package/src/translation-request.d.ts +0 -10
- package/src/translation-request.d.ts.map +0 -1
- package/src/translation-request.js +0 -3
- package/src/translation-request.js.map +0 -1
- package/src/translation-response.d.ts +0 -9
- package/src/translation-response.d.ts.map +0 -1
- package/src/translation-response.js +0 -3
- package/src/translation-response.js.map +0 -1
- package/src/types/engine.d.ts +0 -47
- package/src/types/engine.d.ts.map +0 -1
- package/src/types/engine.js +0 -8
- package/src/types/engine.js.map +0 -1
- package/src/types/index.d.ts.map +0 -1
- package/src/types/index.js +0 -9
- package/src/types/index.js.map +0 -1
- package/src/types/plural-types.d.ts.map +0 -1
- package/src/types/plural-types.js +0 -39
- package/src/types/plural-types.js.map +0 -1
- package/src/types.d.ts.map +0 -1
- package/src/types.js +0 -23
- package/src/types.js.map +0 -1
- package/src/utils/currency.d.ts +0 -81
- package/src/utils/currency.d.ts.map +0 -1
- package/src/utils/currency.js +0 -99
- package/src/utils/currency.js.map +0 -1
- package/src/utils/html-escape.d.ts +0 -22
- package/src/utils/html-escape.d.ts.map +0 -1
- package/src/utils/html-escape.js +0 -53
- package/src/utils/html-escape.js.map +0 -1
- package/src/utils/index.d.ts.map +0 -1
- package/src/utils/index.js +0 -12
- package/src/utils/index.js.map +0 -1
- package/src/utils/lru-cache.d.ts +0 -42
- package/src/utils/lru-cache.d.ts.map +0 -1
- package/src/utils/lru-cache.js +0 -73
- package/src/utils/lru-cache.js.map +0 -1
- package/src/utils/plural-helpers.d.ts.map +0 -1
- package/src/utils/plural-helpers.js +0 -35
- package/src/utils/plural-helpers.js.map +0 -1
- package/src/utils/safe-object.d.ts +0 -39
- package/src/utils/safe-object.d.ts.map +0 -1
- package/src/utils/safe-object.js.map +0 -1
- package/src/utils/string-utils.d.ts +0 -28
- package/src/utils/string-utils.d.ts.map +0 -1
- package/src/utils/string-utils.js +0 -63
- package/src/utils/string-utils.js.map +0 -1
- package/src/utils/timezone.d.ts +0 -50
- package/src/utils/timezone.d.ts.map +0 -1
- package/src/utils/timezone.js +0 -74
- package/src/utils/timezone.js.map +0 -1
- package/src/utils/validation.d.ts +0 -40
- package/src/utils/validation.d.ts.map +0 -1
- package/src/utils/validation.js +0 -69
- package/src/utils/validation.js.map +0 -1
- package/src/utils.d.ts +0 -65
- package/src/utils.d.ts.map +0 -1
- package/src/utils.js +0 -129
- package/src/utils.js.map +0 -1
- package/src/validation/index.d.ts.map +0 -1
- package/src/validation/index.js +0 -5
- package/src/validation/index.js.map +0 -1
- package/src/validation/plural-validator.d.ts +0 -46
- package/src/validation/plural-validator.d.ts.map +0 -1
- package/src/validation/plural-validator.js +0 -123
- package/src/validation/plural-validator.js.map +0 -1
- package/src/validation-config.d.ts +0 -12
- package/src/validation-config.d.ts.map +0 -1
- package/src/validation-config.js +0 -3
- package/src/validation-config.js.map +0 -1
- package/src/validation-result.d.ts +0 -13
- package/src/validation-result.d.ts.map +0 -1
- package/src/validation-result.js +0 -3
- package/src/validation-result.js.map +0 -1
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plural form validation
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { PluralCategory } from '../pluralization/plural-categories';
|
|
6
|
+
import { PluralString, isPluralString } from '../types/plural-types';
|
|
7
|
+
import { getRequiredPluralForms, getAllPluralForms } from '../pluralization/language-plural-map';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Result of validating plural forms.
|
|
11
|
+
*/
|
|
12
|
+
export interface PluralValidationResult {
|
|
13
|
+
/** Whether the validation passed */
|
|
14
|
+
isValid: boolean;
|
|
15
|
+
/** Array of validation errors */
|
|
16
|
+
errors: string[];
|
|
17
|
+
/** Array of validation warnings */
|
|
18
|
+
warnings: string[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Options for plural form validation.
|
|
23
|
+
*/
|
|
24
|
+
export interface PluralValidationOptions {
|
|
25
|
+
/** If true, treat missing required forms as errors instead of warnings */
|
|
26
|
+
strict?: boolean;
|
|
27
|
+
/** If true, warn about unused plural forms */
|
|
28
|
+
checkUnused?: boolean;
|
|
29
|
+
/** If true, check for consistent variable usage across forms */
|
|
30
|
+
checkVariables?: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Validate plural forms for a specific language.
|
|
35
|
+
* Checks that all required plural forms are present and optionally validates variable consistency.
|
|
36
|
+
* @param value - The plural string value to validate
|
|
37
|
+
* @param language - The language code
|
|
38
|
+
* @param key - The translation key (for error messages)
|
|
39
|
+
* @param options - Validation options
|
|
40
|
+
* @returns Validation result with errors and warnings
|
|
41
|
+
*/
|
|
42
|
+
export function validatePluralForms(
|
|
43
|
+
value: PluralString,
|
|
44
|
+
language: string,
|
|
45
|
+
key: string,
|
|
46
|
+
options: PluralValidationOptions = {}
|
|
47
|
+
): PluralValidationResult {
|
|
48
|
+
const errors: string[] = [];
|
|
49
|
+
const warnings: string[] = [];
|
|
50
|
+
|
|
51
|
+
if (!isPluralString(value)) {
|
|
52
|
+
return { isValid: true, errors, warnings };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const required = getRequiredPluralForms(language);
|
|
56
|
+
const all = getAllPluralForms(language);
|
|
57
|
+
const provided = Object.keys(value) as PluralCategory[];
|
|
58
|
+
|
|
59
|
+
// Check required forms
|
|
60
|
+
for (const form of required) {
|
|
61
|
+
if (!value[form as PluralCategory]) {
|
|
62
|
+
if (options.strict) {
|
|
63
|
+
errors.push(`Missing required plural form '${form}' for language '${language}' in key '${key}'`);
|
|
64
|
+
} else {
|
|
65
|
+
warnings.push(`Missing required plural form '${form}' for language '${language}' in key '${key}'`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Check unused forms
|
|
71
|
+
if (options.checkUnused) {
|
|
72
|
+
for (const form of provided) {
|
|
73
|
+
if (!all.includes(form)) {
|
|
74
|
+
warnings.push(`Unused plural form '${form}' for language '${language}' in key '${key}'`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Check variable consistency
|
|
80
|
+
if (options.checkVariables) {
|
|
81
|
+
const variables = extractVariables(value);
|
|
82
|
+
const inconsistent = findInconsistentVariables(value, variables);
|
|
83
|
+
for (const [form, missing] of Object.entries(inconsistent)) {
|
|
84
|
+
warnings.push(`Plural form '${form}' in key '${key}' missing variables: ${missing.join(', ')}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
isValid: errors.length === 0,
|
|
90
|
+
errors,
|
|
91
|
+
warnings,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Extract all variables from plural forms.
|
|
97
|
+
* Scans all plural form texts for {variable} patterns.
|
|
98
|
+
* @param value - The plural string value
|
|
99
|
+
* @returns Set of all variable names found
|
|
100
|
+
*/
|
|
101
|
+
function extractVariables(value: PluralString): Set<string> {
|
|
102
|
+
const vars = new Set<string>();
|
|
103
|
+
if (typeof value === 'string') return vars;
|
|
104
|
+
|
|
105
|
+
for (const text of Object.values(value)) {
|
|
106
|
+
if (text) {
|
|
107
|
+
const matches = text.match(/\{(\w+)\}/g);
|
|
108
|
+
if (matches) {
|
|
109
|
+
matches.forEach(m => vars.add(m.slice(1, -1)));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return vars;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Find forms with inconsistent variables.
|
|
118
|
+
* Identifies plural forms that are missing variables used in other forms.
|
|
119
|
+
* @param value - The plural string value
|
|
120
|
+
* @param allVars - Set of all variables found across all forms
|
|
121
|
+
* @returns Object mapping form names to arrays of missing variable names
|
|
122
|
+
*/
|
|
123
|
+
function findInconsistentVariables(
|
|
124
|
+
value: PluralString,
|
|
125
|
+
allVars: Set<string>
|
|
126
|
+
): Record<string, string[]> {
|
|
127
|
+
const inconsistent: Record<string, string[]> = {};
|
|
128
|
+
if (typeof value === 'string') return inconsistent;
|
|
129
|
+
|
|
130
|
+
for (const [form, text] of Object.entries(value)) {
|
|
131
|
+
if (text) {
|
|
132
|
+
const formVars = new Set<string>();
|
|
133
|
+
const matches = text.match(/\{(\w+)\}/g);
|
|
134
|
+
if (matches) {
|
|
135
|
+
matches.forEach(m => formVars.add(m.slice(1, -1)));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const missing = Array.from(allVars).filter(v => !formVars.has(v));
|
|
139
|
+
if (missing.length > 0) {
|
|
140
|
+
inconsistent[form] = missing;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return inconsistent;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Validate that count variable exists when plural forms are used.
|
|
149
|
+
* Pluralization requires a 'count' variable to determine which form to use.
|
|
150
|
+
* @param value - The plural string value
|
|
151
|
+
* @param variables - The variables object to check
|
|
152
|
+
* @param key - The translation key (for error messages)
|
|
153
|
+
* @returns Validation result with warnings if count is missing
|
|
154
|
+
*/
|
|
155
|
+
export function validateCountVariable(
|
|
156
|
+
value: PluralString,
|
|
157
|
+
variables: Record<string, any> | undefined,
|
|
158
|
+
key: string
|
|
159
|
+
): PluralValidationResult {
|
|
160
|
+
const errors: string[] = [];
|
|
161
|
+
const warnings: string[] = [];
|
|
162
|
+
|
|
163
|
+
if (isPluralString(value) && (!variables || variables.count === undefined)) {
|
|
164
|
+
warnings.push(`Plural forms used in key '${key}' but no 'count' variable provided`);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return { isValid: true, errors, warnings };
|
|
168
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration for component registration validation
|
|
3
|
+
*/
|
|
4
|
+
export interface ValidationConfig {
|
|
5
|
+
/** Whether to require all languages to have all strings */
|
|
6
|
+
readonly requireCompleteStrings: boolean;
|
|
7
|
+
/** Whether to allow registration with missing strings (will use fallbacks) */
|
|
8
|
+
readonly allowPartialRegistration: boolean;
|
|
9
|
+
/** Default language to fall back to for missing strings */
|
|
10
|
+
readonly fallbackLanguageId: string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation result for component registration
|
|
3
|
+
*/
|
|
4
|
+
export interface ValidationResult {
|
|
5
|
+
readonly isValid: boolean;
|
|
6
|
+
readonly missingKeys: ReadonlyArray<{
|
|
7
|
+
readonly languageId: string;
|
|
8
|
+
readonly componentId: string;
|
|
9
|
+
readonly stringKey: string;
|
|
10
|
+
}>;
|
|
11
|
+
readonly errors: readonly string[];
|
|
12
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"active-context.d.ts","sourceRoot":"","sources":["../../../../packages/digitaldefiance-i18n-lib/src/active-context.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,YAAY,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC"}
|
package/src/active-context.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"active-context.js","sourceRoot":"","sources":["../../../../packages/digitaldefiance-i18n-lib/src/active-context.ts"],"names":[],"mappings":""}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Fluent builder for I18n Engine
|
|
3
|
-
*/
|
|
4
|
-
import { I18nEngine } from '../core/i18n-engine';
|
|
5
|
-
import { EngineConfig, LanguageDefinition } from '../interfaces';
|
|
6
|
-
export declare class I18nBuilder {
|
|
7
|
-
private languages;
|
|
8
|
-
private config;
|
|
9
|
-
private instanceKey;
|
|
10
|
-
private registerInstance;
|
|
11
|
-
private setAsDefault;
|
|
12
|
-
private constructor();
|
|
13
|
-
static create(): I18nBuilder;
|
|
14
|
-
withLanguages(languages: readonly LanguageDefinition[]): this;
|
|
15
|
-
withDefaultLanguage(languageId: string): this;
|
|
16
|
-
withFallbackLanguage(languageId: string): this;
|
|
17
|
-
withConstants(constants: Record<string, any>): this;
|
|
18
|
-
withValidation(validation: EngineConfig['validation']): this;
|
|
19
|
-
withInstanceKey(key: string): this;
|
|
20
|
-
withRegisterInstance(register: boolean): this;
|
|
21
|
-
withSetAsDefault(setDefault: boolean): this;
|
|
22
|
-
isolated(): this;
|
|
23
|
-
asDefault(): this;
|
|
24
|
-
build(): I18nEngine;
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=i18n-builder.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"i18n-builder.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/builders/i18n-builder.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEjE,qBAAa,WAAW;IACtB,OAAO,CAAC,SAAS,CAA4B;IAC7C,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,gBAAgB,CAAQ;IAChC,OAAO,CAAC,YAAY,CAAQ;IAE5B,OAAO;IAEP,MAAM,CAAC,MAAM,IAAI,WAAW;IAI5B,aAAa,CAAC,SAAS,EAAE,SAAS,kBAAkB,EAAE,GAAG,IAAI;IAK7D,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAK7C,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAK9C,aAAa,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;IAKnD,cAAc,CAAC,UAAU,EAAE,YAAY,CAAC,YAAY,CAAC,GAAG,IAAI;IAK5D,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAKlC,oBAAoB,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;IAK7C,gBAAgB,CAAC,UAAU,EAAE,OAAO,GAAG,IAAI;IAK3C,QAAQ,IAAI,IAAI;IAKhB,SAAS,IAAI,IAAI;IAKjB,KAAK,IAAI,UAAU;CAWpB"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Fluent builder for I18n Engine
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.I18nBuilder = void 0;
|
|
7
|
-
const i18n_engine_1 = require("../core/i18n-engine");
|
|
8
|
-
class I18nBuilder {
|
|
9
|
-
languages = [];
|
|
10
|
-
config = {};
|
|
11
|
-
instanceKey = 'default';
|
|
12
|
-
registerInstance = true;
|
|
13
|
-
setAsDefault = true;
|
|
14
|
-
constructor() { }
|
|
15
|
-
static create() {
|
|
16
|
-
return new I18nBuilder();
|
|
17
|
-
}
|
|
18
|
-
withLanguages(languages) {
|
|
19
|
-
this.languages = [...languages];
|
|
20
|
-
return this;
|
|
21
|
-
}
|
|
22
|
-
withDefaultLanguage(languageId) {
|
|
23
|
-
this.config.defaultLanguage = languageId;
|
|
24
|
-
return this;
|
|
25
|
-
}
|
|
26
|
-
withFallbackLanguage(languageId) {
|
|
27
|
-
this.config.fallbackLanguage = languageId;
|
|
28
|
-
return this;
|
|
29
|
-
}
|
|
30
|
-
withConstants(constants) {
|
|
31
|
-
this.config.constants = constants;
|
|
32
|
-
return this;
|
|
33
|
-
}
|
|
34
|
-
withValidation(validation) {
|
|
35
|
-
this.config.validation = validation;
|
|
36
|
-
return this;
|
|
37
|
-
}
|
|
38
|
-
withInstanceKey(key) {
|
|
39
|
-
this.instanceKey = key;
|
|
40
|
-
return this;
|
|
41
|
-
}
|
|
42
|
-
withRegisterInstance(register) {
|
|
43
|
-
this.registerInstance = register;
|
|
44
|
-
return this;
|
|
45
|
-
}
|
|
46
|
-
withSetAsDefault(setDefault) {
|
|
47
|
-
this.setAsDefault = setDefault;
|
|
48
|
-
return this;
|
|
49
|
-
}
|
|
50
|
-
isolated() {
|
|
51
|
-
this.registerInstance = false;
|
|
52
|
-
return this;
|
|
53
|
-
}
|
|
54
|
-
asDefault() {
|
|
55
|
-
this.setAsDefault = true;
|
|
56
|
-
return this;
|
|
57
|
-
}
|
|
58
|
-
build() {
|
|
59
|
-
if (this.languages.length === 0) {
|
|
60
|
-
throw new Error('At least one language must be provided');
|
|
61
|
-
}
|
|
62
|
-
return new i18n_engine_1.I18nEngine(this.languages, this.config, {
|
|
63
|
-
instanceKey: this.instanceKey,
|
|
64
|
-
registerInstance: this.registerInstance,
|
|
65
|
-
setAsDefault: this.setAsDefault,
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
exports.I18nBuilder = I18nBuilder;
|
|
70
|
-
//# sourceMappingURL=i18n-builder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"i18n-builder.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/builders/i18n-builder.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,qDAAiD;AAGjD,MAAa,WAAW;IACd,SAAS,GAAyB,EAAE,CAAC;IACrC,MAAM,GAAiB,EAAE,CAAC;IAC1B,WAAW,GAAG,SAAS,CAAC;IACxB,gBAAgB,GAAG,IAAI,CAAC;IACxB,YAAY,GAAG,IAAI,CAAC;IAE5B,gBAAuB,CAAC;IAExB,MAAM,CAAC,MAAM;QACX,OAAO,IAAI,WAAW,EAAE,CAAC;IAC3B,CAAC;IAED,aAAa,CAAC,SAAwC;QACpD,IAAI,CAAC,SAAS,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,mBAAmB,CAAC,UAAkB;QACpC,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,UAAU,CAAC;QACzC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,oBAAoB,CAAC,UAAkB;QACrC,IAAI,CAAC,MAAM,CAAC,gBAAgB,GAAG,UAAU,CAAC;QAC1C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,aAAa,CAAC,SAA8B;QAC1C,IAAI,CAAC,MAAM,CAAC,SAAS,GAAG,SAAS,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,cAAc,CAAC,UAAsC;QACnD,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,UAAU,CAAC;QACpC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,eAAe,CAAC,GAAW;QACzB,IAAI,CAAC,WAAW,GAAG,GAAG,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,oBAAoB,CAAC,QAAiB;QACpC,IAAI,CAAC,gBAAgB,GAAG,QAAQ,CAAC;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,gBAAgB,CAAC,UAAmB;QAClC,IAAI,CAAC,YAAY,GAAG,UAAU,CAAC;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,QAAQ;QACN,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,SAAS;QACP,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK;QACH,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;QAC5D,CAAC;QAED,OAAO,IAAI,wBAAU,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,EAAE;YACjD,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,YAAY,EAAE,IAAI,CAAC,YAAY;SAChC,CAAC,CAAC;IACL,CAAC;CACF;AA1ED,kCA0EC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/builders/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,gBAAgB,CAAC"}
|
package/src/builders/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/builders/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,yDAA+B"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Component definition with its string keys
|
|
3
|
-
*/
|
|
4
|
-
export interface ComponentDefinition<TStringKeys extends string> {
|
|
5
|
-
/** Unique identifier for the component */
|
|
6
|
-
readonly id: string;
|
|
7
|
-
/** Human-readable name for the component */
|
|
8
|
-
readonly name: string;
|
|
9
|
-
/** Array of all string keys this component requires */
|
|
10
|
-
readonly stringKeys: readonly TStringKeys[];
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=component-definition.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"component-definition.d.ts","sourceRoot":"","sources":["../../../../packages/digitaldefiance-i18n-lib/src/component-definition.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,mBAAmB,CAAC,WAAW,SAAS,MAAM;IAC7D,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,4CAA4C;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,uDAAuD;IACvD,QAAQ,CAAC,UAAU,EAAE,SAAS,WAAW,EAAE,CAAC;CAC7C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"component-definition.js","sourceRoot":"","sources":["../../../../packages/digitaldefiance-i18n-lib/src/component-definition.ts"],"names":[],"mappings":""}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { ComponentDefinition } from './component-definition';
|
|
2
|
-
import { PartialComponentLanguageStrings } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* Registration payload for a component with its strings
|
|
5
|
-
*/
|
|
6
|
-
export interface ComponentRegistration<TStringKeys extends string, TLanguages extends string> {
|
|
7
|
-
readonly component: ComponentDefinition<TStringKeys>;
|
|
8
|
-
readonly strings: PartialComponentLanguageStrings<TStringKeys, TLanguages>;
|
|
9
|
-
readonly enumName?: string;
|
|
10
|
-
readonly enumObject?: Record<string, TStringKeys>;
|
|
11
|
-
readonly aliases?: readonly string[];
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Type utility to extract string keys from a component definition
|
|
15
|
-
*/
|
|
16
|
-
type ExtractStringKeys<T> = T extends ComponentDefinition<infer K> ? K : never;
|
|
17
|
-
/**
|
|
18
|
-
* Type utility to create a strongly typed component registration
|
|
19
|
-
*/
|
|
20
|
-
export type CreateComponentRegistration<TComponent extends ComponentDefinition<any>, TLanguages extends string> = ComponentRegistration<ExtractStringKeys<TComponent>, TLanguages>;
|
|
21
|
-
export {};
|
|
22
|
-
//# sourceMappingURL=component-registration.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"component-registration.d.ts","sourceRoot":"","sources":["../../../../packages/digitaldefiance-i18n-lib/src/component-registration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,+BAA+B,EAAE,MAAM,SAAS,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,qBAAqB,CACpC,WAAW,SAAS,MAAM,EAC1B,UAAU,SAAS,MAAM;IAEzB,QAAQ,CAAC,SAAS,EAAE,mBAAmB,CAAC,WAAW,CAAC,CAAC;IACrD,QAAQ,CAAC,OAAO,EAAE,+BAA+B,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IAC3E,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAClD,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC;AAED;;GAEG;AACH,KAAK,iBAAiB,CAAC,CAAC,IAAI,CAAC,SAAS,mBAAmB,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAE/E;;GAEG;AACH,MAAM,MAAM,2BAA2B,CACrC,UAAU,SAAS,mBAAmB,CAAC,GAAG,CAAC,EAC3C,UAAU,SAAS,MAAM,IACvB,qBAAqB,CAAC,iBAAiB,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"component-registration.js","sourceRoot":"","sources":["../../../../packages/digitaldefiance-i18n-lib/src/component-registration.ts"],"names":[],"mappings":""}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Component registry for managing internationalization components and their string translations
|
|
3
|
-
*/
|
|
4
|
-
import { ComponentDefinition } from './component-definition';
|
|
5
|
-
import { ComponentRegistration } from './component-registration';
|
|
6
|
-
import { TranslationRequest } from './translation-request';
|
|
7
|
-
import { TranslationResponse } from './translation-response';
|
|
8
|
-
import { ComponentLanguageStrings, PartialComponentLanguageStrings } from './types';
|
|
9
|
-
import { ValidationConfig } from './validation-config';
|
|
10
|
-
import { ValidationResult } from './validation-result';
|
|
11
|
-
/**
|
|
12
|
-
* Registry for managing components and their translations
|
|
13
|
-
*/
|
|
14
|
-
export declare class ComponentRegistry<TLanguages extends string> {
|
|
15
|
-
private readonly components;
|
|
16
|
-
private readonly componentStrings;
|
|
17
|
-
private readonly validationConfig;
|
|
18
|
-
private readonly registeredLanguages;
|
|
19
|
-
private readonly constants?;
|
|
20
|
-
/**
|
|
21
|
-
* Creates a new ComponentRegistry.
|
|
22
|
-
* @param languages - Array of supported language codes.
|
|
23
|
-
* @param validationConfig - Configuration for validation rules.
|
|
24
|
-
* @param constants - Optional constants for variable replacement in templates.
|
|
25
|
-
*/
|
|
26
|
-
constructor(languages: readonly TLanguages[], validationConfig: ValidationConfig, constants?: Record<string, any>);
|
|
27
|
-
/**
|
|
28
|
-
* Update the set of registered languages (for dynamic language addition).
|
|
29
|
-
* @param languages - Array of language codes to register.
|
|
30
|
-
*/
|
|
31
|
-
updateRegisteredLanguages(languages: readonly TLanguages[]): void;
|
|
32
|
-
/**
|
|
33
|
-
* Register a new component with its translations.
|
|
34
|
-
* @param registration - Component registration payload.
|
|
35
|
-
* @returns ValidationResult indicating success or errors.
|
|
36
|
-
* @throws RegistryError if component is already registered or validation fails.
|
|
37
|
-
*/
|
|
38
|
-
registerComponent<TStringKeys extends string>(registration: ComponentRegistration<TStringKeys, TLanguages>): ValidationResult;
|
|
39
|
-
/**
|
|
40
|
-
* Update strings for an existing component.
|
|
41
|
-
* @param componentId - The ID of the component to update.
|
|
42
|
-
* @param strings - Partial strings to update.
|
|
43
|
-
* @returns ValidationResult indicating success or errors.
|
|
44
|
-
* @throws RegistryError if component is not found.
|
|
45
|
-
*/
|
|
46
|
-
updateComponentStrings<TStringKeys extends string>(componentId: string, strings: PartialComponentLanguageStrings<TStringKeys, TLanguages>): ValidationResult;
|
|
47
|
-
/**
|
|
48
|
-
* Get a translation for a specific component, string key, and language.
|
|
49
|
-
* @param request - Translation request containing componentId, stringKey, language, and variables.
|
|
50
|
-
* @returns TranslationResponse with the translated string and metadata.
|
|
51
|
-
* @throws RegistryError if component, language, or string key is not found.
|
|
52
|
-
*/
|
|
53
|
-
getTranslation<TStringKeys extends string>(request: TranslationRequest<TStringKeys, TLanguages>): TranslationResponse;
|
|
54
|
-
/**
|
|
55
|
-
* Get all registered components.
|
|
56
|
-
* @returns Array of all registered ComponentDefinition objects.
|
|
57
|
-
*/
|
|
58
|
-
getComponents(): ReadonlyArray<ComponentDefinition<any>>;
|
|
59
|
-
/**
|
|
60
|
-
* Get a specific component by ID.
|
|
61
|
-
* @param componentId - The ID of the component to retrieve.
|
|
62
|
-
* @returns The ComponentDefinition or undefined if not found.
|
|
63
|
-
*/
|
|
64
|
-
getComponent<TStringKeys extends string>(componentId: string): ComponentDefinition<TStringKeys> | undefined;
|
|
65
|
-
/**
|
|
66
|
-
* Check if a component is registered.
|
|
67
|
-
* @param componentId - The ID of the component to check.
|
|
68
|
-
* @returns True if the component is registered, false otherwise.
|
|
69
|
-
*/
|
|
70
|
-
hasComponent(componentId: string): boolean;
|
|
71
|
-
/**
|
|
72
|
-
* Get all strings for a component in all languages.
|
|
73
|
-
* @param componentId - The ID of the component.
|
|
74
|
-
* @returns ComponentLanguageStrings or undefined if not found.
|
|
75
|
-
*/
|
|
76
|
-
getComponentStrings<TStringKeys extends string>(componentId: string): ComponentLanguageStrings<TStringKeys, TLanguages> | undefined;
|
|
77
|
-
/**
|
|
78
|
-
* Validate a component registration.
|
|
79
|
-
* @param registration - Component registration to validate.
|
|
80
|
-
* @returns ValidationResult with details of missing keys and errors.
|
|
81
|
-
*/
|
|
82
|
-
private validateComponentRegistration;
|
|
83
|
-
/**
|
|
84
|
-
* Complete missing strings with fallbacks.
|
|
85
|
-
* @param component - The component definition.
|
|
86
|
-
* @param strings - Partial strings provided.
|
|
87
|
-
* @returns Complete strings with fallbacks filled in.
|
|
88
|
-
*/
|
|
89
|
-
private completeStringsWithFallbacks;
|
|
90
|
-
/**
|
|
91
|
-
* Merge existing strings with new strings.
|
|
92
|
-
* @param existing - Existing complete strings.
|
|
93
|
-
* @param updates - Partial updates to apply.
|
|
94
|
-
* @returns Merged partial strings.
|
|
95
|
-
*/
|
|
96
|
-
private mergeStrings;
|
|
97
|
-
/**
|
|
98
|
-
* Clear all components and their strings (useful for testing).
|
|
99
|
-
*/
|
|
100
|
-
clearAllComponents(): void;
|
|
101
|
-
}
|
|
102
|
-
//# sourceMappingURL=component-registry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"component-registry.d.ts","sourceRoot":"","sources":["../../../../packages/digitaldefiance-i18n-lib/src/component-registry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAGjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EACL,wBAAwB,EAExB,+BAA+B,EAEhC,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;GAEG;AACH,qBAAa,iBAAiB,CAAC,UAAU,SAAS,MAAM;IACtD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA+C;IAC1E,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAG7B;IACJ,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAmB;IACpD,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAkB;IACtD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAsB;IAEjD;;;;;OAKG;gBAED,SAAS,EAAE,SAAS,UAAU,EAAE,EAChC,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAOjC;;;OAGG;IACI,yBAAyB,CAAC,SAAS,EAAE,SAAS,UAAU,EAAE,GAAG,IAAI;IAKxE;;;;;OAKG;IACI,iBAAiB,CAAC,WAAW,SAAS,MAAM,EACjD,YAAY,EAAE,qBAAqB,CAAC,WAAW,EAAE,UAAU,CAAC,GAC3D,gBAAgB;IA6CnB;;;;;;OAMG;IACI,sBAAsB,CAAC,WAAW,SAAS,MAAM,EACtD,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,+BAA+B,CAAC,WAAW,EAAE,UAAU,CAAC,GAChE,gBAAgB;IAoCnB;;;;;OAKG;IACI,cAAc,CAAC,WAAW,SAAS,MAAM,EAC9C,OAAO,EAAE,kBAAkB,CAAC,WAAW,EAAE,UAAU,CAAC,GACnD,mBAAmB;IA4EtB;;;OAGG;IACI,aAAa,IAAI,aAAa,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;IAI/D;;;;OAIG;IACI,YAAY,CAAC,WAAW,SAAS,MAAM,EAC5C,WAAW,EAAE,MAAM,GAClB,mBAAmB,CAAC,WAAW,CAAC,GAAG,SAAS;IAM/C;;;;OAIG;IACI,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO;IAIjD;;;;OAIG;IACI,mBAAmB,CAAC,WAAW,SAAS,MAAM,EACnD,WAAW,EAAE,MAAM,GAClB,wBAAwB,CAAC,WAAW,EAAE,UAAU,CAAC,GAAG,SAAS;IAMhE;;;;OAIG;IACH,OAAO,CAAC,6BAA6B;IAyDrC;;;;;OAKG;IACH,OAAO,CAAC,4BAA4B;IAmCpC;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IA+BpB;;OAEG;IACI,kBAAkB,IAAI,IAAI;CAIlC"}
|