@digitaldefiance/i18n-lib 3.7.5 → 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 +261 -0
- package/package.json +12 -4
- package/src/active-context.ts +4 -0
- 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.ts +16 -0
- package/src/core/language-registry.ts +345 -0
- package/src/core-component-id.ts +5 -0
- 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.ts +8 -0
- 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.ts +15 -0
- package/src/errors/simple-typed-error.ts +81 -0
- package/src/errors/{index.d.ts → translatable-exports.ts} +3 -5
- 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} +46 -14
- 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.ts +13 -0
- 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.ts +142 -0
- 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 +0 -36
- 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 -13
- 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 +0 -9
- package/src/core/index.d.ts.map +0 -1
- package/src/core/index.js +0 -12
- 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 -295
- package/src/core/language-registry.js.map +0 -1
- package/src/core-i18n.d.ts +0 -91
- package/src/core-i18n.d.ts.map +0 -1
- package/src/core-i18n.js +0 -287
- package/src/core-i18n.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/context-error.d.ts +0 -50
- package/src/errors/context-error.d.ts.map +0 -1
- package/src/errors/context-error.js +0 -75
- 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-generic.d.ts +0 -84
- package/src/errors/translatable-generic.d.ts.map +0 -1
- package/src/errors/translatable-generic.js +0 -134
- 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 -59
- package/src/errors/translatable.d.ts.map +0 -1
- package/src/errors/translatable.js +0 -80
- 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 -106
- 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 -452
- 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/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 +0 -11
- package/src/interfaces/index.d.ts.map +0 -1
- package/src/interfaces/index.js +0 -14
- 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 -489
- 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 -19
- package/src/registry-error.d.ts.map +0 -1
- package/src/registry-error.js +0 -49
- 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 +0 -96
- 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 -101
- 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
|
@@ -1,24 +1,44 @@
|
|
|
1
|
+
// V2 Exports (primary)
|
|
1
2
|
export * from './builders';
|
|
2
3
|
export * from './core';
|
|
3
4
|
export * from './errors';
|
|
5
|
+
export * from './gender';
|
|
4
6
|
export * from './interfaces';
|
|
5
|
-
export * from './utils';
|
|
6
|
-
export * from './types';
|
|
7
7
|
export * from './pluralization';
|
|
8
|
-
export * from './
|
|
8
|
+
export * from './types';
|
|
9
|
+
export * from './utils';
|
|
9
10
|
export * from './validation';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export type { CurrencyData, CurrencyFormat, CurrencyPosition } from './utils/currency';
|
|
13
|
-
export { createPluralString, createGenderedString } from './utils/plural-helpers';
|
|
14
|
-
export type { PluralString } from './types/plural-types';
|
|
11
|
+
|
|
12
|
+
// Explicit exports for type safety
|
|
15
13
|
export type { GenderedString } from './gender/gender-categories';
|
|
16
|
-
export {
|
|
14
|
+
export type { PluralString } from './types/plural-types';
|
|
15
|
+
export { CurrencyCode, getCurrencyFormat } from './utils/currency';
|
|
16
|
+
export type {
|
|
17
|
+
CurrencyData,
|
|
18
|
+
CurrencyFormat,
|
|
19
|
+
CurrencyPosition,
|
|
20
|
+
} from './utils/currency';
|
|
21
|
+
export {
|
|
22
|
+
createGenderedString,
|
|
23
|
+
createPluralString,
|
|
24
|
+
} from './utils/plural-helpers';
|
|
25
|
+
export { isValidTimezone, Timezone } from './utils/timezone';
|
|
26
|
+
|
|
27
|
+
// Convenience aliases
|
|
17
28
|
export { I18nBuilder as Builder } from './builders/i18n-builder';
|
|
18
|
-
export
|
|
29
|
+
export { I18nEngine as I18n } from './core/i18n-engine';
|
|
30
|
+
|
|
31
|
+
// Reset utility
|
|
32
|
+
import { I18nEngine } from './core/i18n-engine';
|
|
33
|
+
export function resetAll(): void {
|
|
34
|
+
I18nEngine.resetAll();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Legacy exports (deprecated - for backwards compatibility)
|
|
19
38
|
export * from './active-context';
|
|
20
39
|
export * from './component-definition';
|
|
21
40
|
export * from './global-active-context';
|
|
41
|
+
// export * from './language-registry'; // Removed - conflicts with v2 core/language-registry
|
|
22
42
|
export * from './component-registration';
|
|
23
43
|
export * from './component-registry';
|
|
24
44
|
export * from './context-error-type';
|
|
@@ -39,8 +59,20 @@ export * from './translation-request';
|
|
|
39
59
|
export * from './translation-response';
|
|
40
60
|
export * from './types';
|
|
41
61
|
export * from './validation-config';
|
|
42
|
-
|
|
43
|
-
|
|
62
|
+
|
|
63
|
+
// Legacy convenience exports
|
|
64
|
+
export {
|
|
65
|
+
createCorePluginI18nEngine as createCoreI18n,
|
|
66
|
+
createCorePluginI18nEngine as createCoreI18nEngine,
|
|
67
|
+
getCorePluginTranslation as getCoreTranslation,
|
|
68
|
+
safeCorePluginTranslation as safeCoreTranslation,
|
|
69
|
+
} from './core-plugin-factory';
|
|
70
|
+
// Export core plugin factory functions
|
|
71
|
+
export * from './core-plugin-factory';
|
|
44
72
|
export { PluginI18nEngine as PluginI18n } from './plugin-i18n-engine';
|
|
45
|
-
|
|
46
|
-
|
|
73
|
+
|
|
74
|
+
// Legacy testing utilities
|
|
75
|
+
import { PluginI18nEngine } from './plugin-i18n-engine';
|
|
76
|
+
export function resetAllI18nEngines(): void {
|
|
77
|
+
PluginI18nEngine.resetAll();
|
|
78
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { LanguageContextSpace } from '../types';
|
|
2
|
+
import type { CurrencyCode } from '../utils/currency';
|
|
3
|
+
import type { Timezone } from '../utils/timezone';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents the active internationalization context for user and admin interfaces,
|
|
7
|
+
* including language, currency, and timezone settings.
|
|
8
|
+
*
|
|
9
|
+
* @template TLanguage The type of language codes (e.g., 'en-US', 'fr').
|
|
10
|
+
*/
|
|
11
|
+
export interface IActiveContext<TLanguage extends string> {
|
|
12
|
+
/**
|
|
13
|
+
* The default language for the user-facing application.
|
|
14
|
+
*/
|
|
15
|
+
language: TLanguage;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The default language for the admin interface.
|
|
19
|
+
*/
|
|
20
|
+
adminLanguage: TLanguage;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The default currency code for the user-facing application.
|
|
24
|
+
*/
|
|
25
|
+
currencyCode: CurrencyCode;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The current language context space (e.g., 'user' or 'admin').
|
|
29
|
+
*/
|
|
30
|
+
currentContext: LanguageContextSpace;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The default timezone for the user-facing application.
|
|
34
|
+
*/
|
|
35
|
+
timezone: Timezone;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The default timezone for the admin interface.
|
|
39
|
+
*/
|
|
40
|
+
adminTimezone: Timezone;
|
|
41
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simplified component configuration
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { PluralString } from '../types/plural-types';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Configuration for registering a component with the i18n system.
|
|
9
|
+
*/
|
|
10
|
+
export interface ComponentConfig {
|
|
11
|
+
/** Unique identifier for the component */
|
|
12
|
+
readonly id: string;
|
|
13
|
+
/** Translation strings organized by language and key */
|
|
14
|
+
readonly strings: Record<string, Record<string, string | PluralString>>;
|
|
15
|
+
/** Optional alternative names for referencing this component */
|
|
16
|
+
readonly aliases?: readonly string[];
|
|
17
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engine configuration interface
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Configuration options for the I18n engine.
|
|
7
|
+
*/
|
|
8
|
+
export interface EngineConfig {
|
|
9
|
+
/** Default language to use when none is specified */
|
|
10
|
+
defaultLanguage?: string;
|
|
11
|
+
/** Fallback language to use when a translation is missing */
|
|
12
|
+
fallbackLanguage?: string;
|
|
13
|
+
/** Constants available for variable replacement in templates */
|
|
14
|
+
constants?: Record<string, any>;
|
|
15
|
+
/** Validation configuration */
|
|
16
|
+
validation?: {
|
|
17
|
+
/** Whether all string keys must be provided for all languages */
|
|
18
|
+
requireCompleteStrings?: boolean;
|
|
19
|
+
/** Whether to allow component registration with missing translations */
|
|
20
|
+
allowPartialRegistration?: boolean;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { LanguageContextSpace } from '../types';
|
|
2
|
+
import type { CurrencyCode } from '../utils/currency';
|
|
3
|
+
import type { Timezone } from '../utils/timezone';
|
|
4
|
+
import type { IActiveContext } from './active-context.interface';
|
|
5
|
+
|
|
6
|
+
export interface IGlobalActiveContext<
|
|
7
|
+
TLanguage extends string,
|
|
8
|
+
TActiveContext extends IActiveContext<TLanguage>,
|
|
9
|
+
> {
|
|
10
|
+
context: TActiveContext;
|
|
11
|
+
userLanguage: TLanguage;
|
|
12
|
+
currencyCode: CurrencyCode;
|
|
13
|
+
adminLanguage: TLanguage;
|
|
14
|
+
languageContextSpace: LanguageContextSpace;
|
|
15
|
+
userTimezone: Timezone;
|
|
16
|
+
adminTimezone: Timezone;
|
|
17
|
+
|
|
18
|
+
createContext(
|
|
19
|
+
defaultLanguage: TLanguage,
|
|
20
|
+
defaultAdminLanguage?: TLanguage,
|
|
21
|
+
key?: string,
|
|
22
|
+
): TActiveContext;
|
|
23
|
+
|
|
24
|
+
getContext(key?: string): TActiveContext;
|
|
25
|
+
|
|
26
|
+
setUserLanguage(language: TLanguage, key?: string): void;
|
|
27
|
+
|
|
28
|
+
setCurrencyCode(code: CurrencyCode, key?: string): void;
|
|
29
|
+
|
|
30
|
+
setAdminLanguage(language: TLanguage, key?: string): void;
|
|
31
|
+
|
|
32
|
+
setLanguageContextSpace(context: LanguageContextSpace, key?: string): void;
|
|
33
|
+
|
|
34
|
+
getLanguageContextSpace(key?: string): LanguageContextSpace;
|
|
35
|
+
|
|
36
|
+
setUserTimezone(tz: Timezone, key?: string): void;
|
|
37
|
+
|
|
38
|
+
setAdminTimezone(tz: Timezone, key?: string): void;
|
|
39
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for creating a HandleableError.
|
|
3
|
+
*/
|
|
4
|
+
export interface HandleableErrorOptions {
|
|
5
|
+
/** The original error that caused this error */
|
|
6
|
+
cause?: Error;
|
|
7
|
+
/** Whether this error has been handled */
|
|
8
|
+
handled?: boolean;
|
|
9
|
+
/** HTTP status code associated with this error */
|
|
10
|
+
statusCode?: number;
|
|
11
|
+
/** Optional source data related to the error */
|
|
12
|
+
sourceData?: unknown;
|
|
13
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface for errors that can be marked as handled and serialized to JSON.
|
|
3
|
+
*/
|
|
4
|
+
export interface IHandleable {
|
|
5
|
+
/**
|
|
6
|
+
* Converts the error to a JSON-serializable object.
|
|
7
|
+
* @returns A plain object representation of the error
|
|
8
|
+
*/
|
|
9
|
+
toJSON(): Record<string, unknown>;
|
|
10
|
+
/**
|
|
11
|
+
* Gets the handled state of this error.
|
|
12
|
+
* @returns True if the error has been handled, false otherwise
|
|
13
|
+
*/
|
|
14
|
+
get handled(): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Sets the handled state of this error.
|
|
17
|
+
* @param value - The new handled state
|
|
18
|
+
*/
|
|
19
|
+
set handled(value: boolean);
|
|
20
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core I18n Engine interface
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { ComponentConfig } from './component-config.interface';
|
|
6
|
+
import { LanguageDefinition } from './language-definition.interface';
|
|
7
|
+
import { TranslationOptions } from './translation-options.interface';
|
|
8
|
+
import { ValidationResult } from './validation-result.interface';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Main interface for the I18n engine, defining all translation and management operations.
|
|
12
|
+
*/
|
|
13
|
+
export interface II18nEngine {
|
|
14
|
+
// Component management
|
|
15
|
+
/** Registers a new component with its translations */
|
|
16
|
+
register(config: ComponentConfig): ValidationResult;
|
|
17
|
+
/** Registers a component only if it doesn't already exist */
|
|
18
|
+
registerIfNotExists(config: ComponentConfig): ValidationResult;
|
|
19
|
+
/** Updates strings for an existing component */
|
|
20
|
+
updateStrings(componentId: string, strings: Record<string, Record<string, string>>): ValidationResult;
|
|
21
|
+
/** Checks if a component is registered */
|
|
22
|
+
hasComponent(componentId: string): boolean;
|
|
23
|
+
/** Gets all registered components */
|
|
24
|
+
getComponents(): readonly ComponentConfig[];
|
|
25
|
+
|
|
26
|
+
// Translation
|
|
27
|
+
/** Translates a string key for a component */
|
|
28
|
+
translate(componentId: string, key: string, variables?: Record<string, any>, language?: string): string;
|
|
29
|
+
/** Safely translates a string key, returning a fallback on error */
|
|
30
|
+
safeTranslate(componentId: string, key: string, variables?: Record<string, any>, language?: string): string;
|
|
31
|
+
/** Template processor that handles embedded component.key patterns */
|
|
32
|
+
t(template: string, variables?: Record<string, any>, language?: string): string;
|
|
33
|
+
|
|
34
|
+
// Language management
|
|
35
|
+
/** Registers a new language */
|
|
36
|
+
registerLanguage(language: LanguageDefinition): void;
|
|
37
|
+
/** Sets the current user-facing language */
|
|
38
|
+
setLanguage(language: string): void;
|
|
39
|
+
/** Sets the administrative language */
|
|
40
|
+
setAdminLanguage(language: string): void;
|
|
41
|
+
/** Gets all registered languages */
|
|
42
|
+
getLanguages(): readonly LanguageDefinition[];
|
|
43
|
+
/** Checks if a language is registered */
|
|
44
|
+
hasLanguage(language: string): boolean;
|
|
45
|
+
|
|
46
|
+
// Context management
|
|
47
|
+
/** Switches to admin context */
|
|
48
|
+
switchToAdmin(): void;
|
|
49
|
+
/** Switches to user context */
|
|
50
|
+
switchToUser(): void;
|
|
51
|
+
/** Gets the currently active language based on context */
|
|
52
|
+
getCurrentLanguage(): string;
|
|
53
|
+
|
|
54
|
+
// Validation
|
|
55
|
+
/** Validates all registered components */
|
|
56
|
+
validate(): ValidationResult;
|
|
57
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface exports
|
|
3
|
+
* Using type-only exports to prevent runtime circular dependencies
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export type * from './active-context.interface';
|
|
7
|
+
export type * from './component-config.interface';
|
|
8
|
+
export type * from './engine-config.interface';
|
|
9
|
+
export type * from './global-active-context';
|
|
10
|
+
export type * from './i18n-engine.interface';
|
|
11
|
+
export type * from './language-definition.interface';
|
|
12
|
+
export type * from './translation-options.interface';
|
|
13
|
+
export type * from './validation-result.interface';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Language definition interface
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Defines a language with its metadata.
|
|
7
|
+
*/
|
|
8
|
+
export interface LanguageDefinition {
|
|
9
|
+
/** Unique identifier for the language (e.g., 'en-US') */
|
|
10
|
+
readonly id: string;
|
|
11
|
+
/** Display name in the native language */
|
|
12
|
+
readonly name: string;
|
|
13
|
+
/** ISO language code */
|
|
14
|
+
readonly code: string;
|
|
15
|
+
/** Whether this is the default/fallback language */
|
|
16
|
+
readonly isDefault?: boolean;
|
|
17
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Translation options interface
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Options that can be passed when requesting a translation.
|
|
7
|
+
*/
|
|
8
|
+
export interface TranslationOptions {
|
|
9
|
+
/** Variables to replace in template strings */
|
|
10
|
+
readonly variables?: Record<string, any>;
|
|
11
|
+
/** Language code to use for the translation */
|
|
12
|
+
readonly language?: string;
|
|
13
|
+
/** Fallback value to return if translation fails */
|
|
14
|
+
readonly fallback?: string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation result interface
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Result of validating a component registration or the entire engine.
|
|
7
|
+
*/
|
|
8
|
+
export interface ValidationResult {
|
|
9
|
+
/** Whether the validation passed */
|
|
10
|
+
readonly isValid: boolean;
|
|
11
|
+
/** Array of validation errors */
|
|
12
|
+
readonly errors: readonly string[];
|
|
13
|
+
/** Array of validation warnings */
|
|
14
|
+
readonly warnings: readonly string[];
|
|
15
|
+
/** Detailed information about missing translation keys */
|
|
16
|
+
readonly missingKeys?: readonly {
|
|
17
|
+
/** The language ID where the key is missing */
|
|
18
|
+
languageId: string;
|
|
19
|
+
/** The component ID where the key is missing */
|
|
20
|
+
componentId: string;
|
|
21
|
+
/** The string key that is missing */
|
|
22
|
+
stringKey: string;
|
|
23
|
+
}[];
|
|
24
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common language codes following BCP 47 standard.
|
|
3
|
+
* These are provided as constants for convenience, but any string can be used as a language code.
|
|
4
|
+
* Site builders can use these or define their own custom language codes.
|
|
5
|
+
*/
|
|
6
|
+
export const LanguageCodes = {
|
|
7
|
+
EN_US: 'en-US',
|
|
8
|
+
EN_GB: 'en-GB',
|
|
9
|
+
FR: 'fr',
|
|
10
|
+
ES: 'es',
|
|
11
|
+
DE: 'de',
|
|
12
|
+
ZH_CN: 'zh-CN',
|
|
13
|
+
JA: 'ja',
|
|
14
|
+
UK: 'uk',
|
|
15
|
+
} as const;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Type representing any language code (string)
|
|
19
|
+
*/
|
|
20
|
+
export type LanguageCode = string;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Type representing the common language codes provided by this library
|
|
24
|
+
*/
|
|
25
|
+
export type CommonLanguageCode =
|
|
26
|
+
(typeof LanguageCodes)[keyof typeof LanguageCodes];
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Helper to get display names for common language codes
|
|
30
|
+
*/
|
|
31
|
+
export const LanguageDisplayNames: Record<CommonLanguageCode, string> = {
|
|
32
|
+
[LanguageCodes.EN_US]: 'English (US)',
|
|
33
|
+
[LanguageCodes.EN_GB]: 'English (UK)',
|
|
34
|
+
[LanguageCodes.FR]: 'Français',
|
|
35
|
+
[LanguageCodes.ES]: 'Español',
|
|
36
|
+
[LanguageCodes.DE]: 'Deutsch',
|
|
37
|
+
[LanguageCodes.ZH_CN]: '中文',
|
|
38
|
+
[LanguageCodes.JA]: '日本語',
|
|
39
|
+
[LanguageCodes.UK]: 'Українська',
|
|
40
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Language definition with its properties
|
|
3
|
+
*/
|
|
4
|
+
export interface LanguageDefinition {
|
|
5
|
+
/** Unique identifier for the language */
|
|
6
|
+
readonly id: string;
|
|
7
|
+
/** Display name in the native language */
|
|
8
|
+
readonly name: string;
|
|
9
|
+
/** ISO language code (e.g., 'en', 'fr', 'zh-CN') */
|
|
10
|
+
readonly code: string;
|
|
11
|
+
/** Whether this is the fallback/default language */
|
|
12
|
+
readonly isDefault?: boolean;
|
|
13
|
+
}
|