@digitaldefiance/i18n-lib 3.7.2 → 3.8.0
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/README.md +204 -34
- package/package.json +4 -1
- package/src/active-context.d.ts +2 -33
- package/src/active-context.d.ts.map +1 -1
- package/src/builders/i18n-builder.d.ts +2 -2
- package/src/builders/i18n-builder.d.ts.map +1 -1
- package/src/builders/i18n-builder.js +1 -1
- package/src/builders/i18n-builder.js.map +1 -1
- package/src/component-registration.d.ts +9 -0
- package/src/component-registration.d.ts.map +1 -1
- package/src/component-registry.d.ts.map +1 -1
- package/src/component-registry.js.map +1 -1
- package/src/core/component-store.d.ts.map +1 -1
- package/src/core/component-store.js +8 -8
- package/src/core/component-store.js.map +1 -1
- package/src/core/enum-registry.d.ts +1 -1
- package/src/core/enum-registry.d.ts.map +1 -1
- package/src/core/enum-registry.js +8 -5
- package/src/core/enum-registry.js.map +1 -1
- package/src/core/i18n-engine.d.ts.map +1 -1
- package/src/core/i18n-engine.js +31 -19
- package/src/core/i18n-engine.js.map +1 -1
- package/src/core/index.d.ts +9 -5
- package/src/core/index.d.ts.map +1 -1
- package/src/core/index.js +15 -6
- package/src/core/index.js.map +1 -1
- package/src/core/language-registry.d.ts.map +1 -1
- package/src/core/language-registry.js +11 -8
- package/src/core/language-registry.js.map +1 -1
- package/src/core-component-id.d.ts +6 -0
- 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 +4 -26
- package/src/core-i18n.d.ts.map +1 -1
- package/src/core-i18n.js +18 -83
- package/src/core-i18n.js.map +1 -1
- 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/errors/base.d.ts +8 -0
- 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.map +1 -1
- package/src/errors/context-error.js +24 -6
- package/src/errors/context-error.js.map +1 -1
- package/src/errors/enhanced-error-base.d.ts +5 -0
- package/src/errors/enhanced-error-base.d.ts.map +1 -1
- package/src/errors/i18n-error.d.ts.map +1 -1
- package/src/errors/i18n-error.js +97 -30
- package/src/errors/i18n-error.js.map +1 -1
- package/src/errors/index.d.ts +8 -9
- package/src/errors/index.d.ts.map +1 -1
- package/src/errors/index.js +10 -9
- package/src/errors/index.js.map +1 -1
- 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.d.ts +12 -0
- 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 +4 -1
- package/src/errors/translatable-generic.d.ts.map +1 -1
- package/src/errors/translatable-generic.js +9 -4
- package/src/errors/translatable-generic.js.map +1 -1
- package/src/errors/translatable.d.ts +4 -0
- package/src/errors/translatable.d.ts.map +1 -1
- package/src/errors/translatable.js +9 -4
- package/src/errors/translatable.js.map +1 -1
- package/src/errors/typed-handleable.d.ts +1 -1
- package/src/errors/typed-handleable.d.ts.map +1 -1
- package/src/errors/typed-handleable.js +15 -11
- package/src/errors/typed-handleable.js.map +1 -1
- package/src/errors/typed.d.ts +7 -5
- package/src/errors/typed.d.ts.map +1 -1
- package/src/errors/typed.js +44 -31
- package/src/errors/typed.js.map +1 -1
- package/src/global-active-context.d.ts +3 -3
- package/src/global-active-context.d.ts.map +1 -1
- package/src/global-active-context.js +2 -2
- package/src/global-active-context.js.map +1 -1
- package/src/index.d.ts +11 -11
- package/src/index.d.ts.map +1 -1
- package/src/index.js +17 -17
- package/src/index.js.map +1 -1
- 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/global-active-context.d.ts +4 -4
- package/src/interfaces/global-active-context.d.ts.map +1 -1
- package/src/interfaces/index.d.ts +9 -7
- package/src/interfaces/index.d.ts.map +1 -1
- package/src/interfaces/index.js +1 -8
- package/src/interfaces/index.js.map +1 -1
- package/src/plugin-i18n-engine.d.ts +1 -1
- package/src/plugin-i18n-engine.d.ts.map +1 -1
- package/src/plugin-i18n-engine.js +10 -6
- package/src/plugin-i18n-engine.js.map +1 -1
- package/src/pluralization/language-plural-map.d.ts +2 -2
- package/src/pluralization/language-plural-map.d.ts.map +1 -1
- package/src/pluralization/language-plural-map.js +90 -71
- package/src/pluralization/language-plural-map.js.map +1 -1
- package/src/registry-error.d.ts +8 -2
- package/src/registry-error.d.ts.map +1 -1
- package/src/registry-error.js +19 -5
- package/src/registry-error.js.map +1 -1
- 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.d.ts +1 -0
- package/src/types/index.d.ts.map +1 -1
- package/src/types/index.js +1 -0
- package/src/types/index.js.map +1 -1
- package/src/types.d.ts +0 -5
- package/src/types.d.ts.map +1 -1
- package/src/types.js.map +1 -1
- package/src/utils/currency.d.ts +1 -1
- package/src/utils/currency.d.ts.map +1 -1
- package/src/utils/currency.js +2 -4
- package/src/utils/currency.js.map +1 -1
- package/src/utils/safe-object.d.ts.map +1 -1
- package/src/utils/safe-object.js +1 -0
- package/src/utils/safe-object.js.map +1 -1
- package/src/utils.d.ts.map +1 -1
- package/src/utils.js.map +1 -1
|
@@ -5,6 +5,10 @@ const i18n_engine_1 = require("../core/i18n-engine");
|
|
|
5
5
|
/**
|
|
6
6
|
* Translatable error class with full i18n 3.0/3.5 feature support.
|
|
7
7
|
*
|
|
8
|
+
* Uses lazy initialization to avoid circular dependencies with core modules.
|
|
9
|
+
* The I18nEngine is only accessed when the error is constructed, not at module load time.
|
|
10
|
+
* If the i18n engine is not initialized, falls back to displaying the raw key.
|
|
11
|
+
*
|
|
8
12
|
* **Supported Features:**
|
|
9
13
|
* - ICU MessageFormat (variables, plural, select, selectordinal)
|
|
10
14
|
* - Pluralization (37 languages, CLDR rules)
|
|
@@ -38,6 +42,7 @@ class TranslatableError extends Error {
|
|
|
38
42
|
variables;
|
|
39
43
|
language;
|
|
40
44
|
constructor(componentId, stringKey, otherVars, language) {
|
|
45
|
+
// Lazy initialization: getInstance() is only called when error is constructed, not at module load
|
|
41
46
|
const engine = i18n_engine_1.I18nEngine.getInstance('default');
|
|
42
47
|
super(engine.safeTranslate(componentId, stringKey, otherVars, language));
|
|
43
48
|
this.name = 'TranslatableError';
|
|
@@ -52,28 +57,28 @@ class TranslatableError extends Error {
|
|
|
52
57
|
* Translation string should use: {count, plural, one {...} other {...}}
|
|
53
58
|
*/
|
|
54
59
|
static withCount(componentId, stringKey, count, otherVars, language) {
|
|
55
|
-
return new TranslatableError(componentId, stringKey, { ...otherVars
|
|
60
|
+
return new TranslatableError(componentId, stringKey, { count, ...otherVars }, language);
|
|
56
61
|
}
|
|
57
62
|
/**
|
|
58
63
|
* Create error with gender context
|
|
59
64
|
* Translation string should use: {gender, select, male {...} female {...} other {...}}
|
|
60
65
|
*/
|
|
61
66
|
static withGender(componentId, stringKey, gender, otherVars, language) {
|
|
62
|
-
return new TranslatableError(componentId, stringKey, { ...otherVars
|
|
67
|
+
return new TranslatableError(componentId, stringKey, { gender, ...otherVars }, language);
|
|
63
68
|
}
|
|
64
69
|
/**
|
|
65
70
|
* Create error with ordinal number
|
|
66
71
|
* Translation string should use: {number, selectordinal, one {#st} two {#nd} few {#rd} other {#th}}
|
|
67
72
|
*/
|
|
68
73
|
static withOrdinal(componentId, stringKey, number, otherVars, language) {
|
|
69
|
-
return new TranslatableError(componentId, stringKey, { ...otherVars
|
|
74
|
+
return new TranslatableError(componentId, stringKey, { number, ...otherVars }, language);
|
|
70
75
|
}
|
|
71
76
|
/**
|
|
72
77
|
* Create error with formatted number
|
|
73
78
|
* Translation string should use: {value, number, integer|currency|percent}
|
|
74
79
|
*/
|
|
75
80
|
static withNumber(componentId, stringKey, value, otherVars, language) {
|
|
76
|
-
return new TranslatableError(componentId, stringKey, { ...otherVars
|
|
81
|
+
return new TranslatableError(componentId, stringKey, { value, ...otherVars }, language);
|
|
77
82
|
}
|
|
78
83
|
}
|
|
79
84
|
exports.TranslatableError = TranslatableError;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translatable.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/errors/translatable.ts"],"names":[],"mappings":";;;AAAA,qDAAiD;
|
|
1
|
+
{"version":3,"file":"translatable.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/errors/translatable.ts"],"names":[],"mappings":";;;AAAA,qDAAiD;AAGjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAa,iBAEX,SAAQ,KAAK;IACY,WAAW,CAAS;IAC7B,SAAS,CAAa;IACtB,SAAS,CAAmC;IAC5C,QAAQ,CAAU;IAElC,YACE,WAAmB,EACnB,SAAqB,EACrB,SAA2C,EAC3C,QAAiB;QAEjB,kGAAkG;QAClG,MAAM,MAAM,GAAG,wBAAU,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;QACjD,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;QACzE,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;QAChC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAC;IAC3D,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,SAAS,CACd,WAAmB,EACnB,SAAqB,EACrB,KAAa,EACb,SAA2C,EAC3C,QAAiB;QAEjB,OAAO,IAAI,iBAAiB,CAC1B,WAAW,EACX,SAAS,EACT,EAAE,KAAK,EAAE,GAAG,SAAS,EAAE,EACvB,QAAQ,CACT,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,UAAU,CACf,WAAmB,EACnB,SAAqB,EACrB,MAAsB,EACtB,SAA2C,EAC3C,QAAiB;QAEjB,OAAO,IAAI,iBAAiB,CAC1B,WAAW,EACX,SAAS,EACT,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,EACxB,QAAQ,CACT,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,WAAW,CAChB,WAAmB,EACnB,SAAqB,EACrB,MAAc,EACd,SAA2C,EAC3C,QAAiB;QAEjB,OAAO,IAAI,iBAAiB,CAC1B,WAAW,EACX,SAAS,EACT,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,EACxB,QAAQ,CACT,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,UAAU,CACf,WAAmB,EACnB,SAAqB,EACrB,KAAa,EACb,SAA2C,EAC3C,QAAiB;QAEjB,OAAO,IAAI,iBAAiB,CAC1B,WAAW,EACX,SAAS,EACT,EAAE,KAAK,EAAE,GAAG,SAAS,EAAE,EACvB,QAAQ,CACT,CAAC;IACJ,CAAC;CACF;AApGD,8CAoGC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { HandleableError } from './handleable';
|
|
2
1
|
import { IHandleable } from '../interfaces/handleable';
|
|
3
2
|
import { HandleableErrorOptions } from '../interfaces/handleable-error-options';
|
|
3
|
+
import { HandleableError } from './handleable';
|
|
4
4
|
import { CompleteReasonMap } from './typed';
|
|
5
5
|
/**
|
|
6
6
|
* TypedHandleableError with full i18n feature support.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typed-handleable.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/errors/typed-handleable.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"typed-handleable.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/errors/typed-handleable.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,qBAAa,oBAAoB,CAC7B,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,UAAU,SAAS,MAAM,CAE3B,SAAQ,eACR,YAAW,WAAW;IAEtB,SAAyB,WAAW,EAAE,MAAM,CAAC;IAC7C,SAAyB,IAAI,EAAE,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC;IAClD,SAAyB,SAAS,EAAE,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IACzE,SAAgB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClC,SAAgB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;gBAG1D,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,KAAK,CAAC,MAAM,KAAK,CAAC,EACxB,SAAS,EAAE,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,EAC/C,MAAM,EAAE,KAAK,EACb,OAAO,CAAC,EAAE,sBAAsB,EAChC,QAAQ,CAAC,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IAsD7B,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAOlD"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TypedHandleableError = void 0;
|
|
4
|
-
const
|
|
4
|
+
const core_component_id_1 = require("../core-component-id");
|
|
5
5
|
const core_string_key_1 = require("../core-string-key");
|
|
6
|
+
const i18n_engine_1 = require("../core/i18n-engine");
|
|
6
7
|
const handleable_1 = require("./handleable");
|
|
7
|
-
const core_1 = require("../core");
|
|
8
8
|
/**
|
|
9
9
|
* TypedHandleableError with full i18n feature support.
|
|
10
10
|
*
|
|
@@ -61,21 +61,23 @@ class TypedHandleableError extends handleable_1.HandleableError {
|
|
|
61
61
|
otherVars;
|
|
62
62
|
constructor(componentId, type, reasonMap, source, options, language, otherVars) {
|
|
63
63
|
const key = reasonMap[type];
|
|
64
|
-
|
|
65
|
-
const coreEngine = core_1.I18nEngine.getInstance();
|
|
66
|
-
throw new Error(coreEngine.translate(core_i18n_1.CoreI18nComponentId, core_string_key_1.CoreStringKey.Error_MissingTranslationKeyTemplate, {
|
|
67
|
-
stringKey: key,
|
|
68
|
-
}));
|
|
69
|
-
}
|
|
64
|
+
// Lazy initialization: getInstance() is only called when error is constructed
|
|
70
65
|
let message = String(type);
|
|
71
66
|
try {
|
|
67
|
+
if (!key) {
|
|
68
|
+
const coreEngine = i18n_engine_1.I18nEngine.getInstance();
|
|
69
|
+
throw new Error(coreEngine.translate(core_component_id_1.CoreI18nComponentId, core_string_key_1.CoreStringKey.Error_MissingTranslationKeyTemplate, {
|
|
70
|
+
stringKey: key,
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
72
73
|
const keyString = key;
|
|
73
|
-
const engine =
|
|
74
|
+
const engine = i18n_engine_1.I18nEngine.getInstance('default');
|
|
74
75
|
const translated = engine.translate(componentId, keyString, otherVars, language);
|
|
75
76
|
message = String(translated || type);
|
|
76
77
|
}
|
|
77
78
|
catch (error) {
|
|
78
|
-
|
|
79
|
+
// Fallback if engine not available
|
|
80
|
+
message = key ? `[${componentId}.${key}]` : String(type);
|
|
79
81
|
}
|
|
80
82
|
// Create a new error with the translated message
|
|
81
83
|
const errorWithMessage = new Error(message);
|
|
@@ -83,7 +85,9 @@ class TypedHandleableError extends handleable_1.HandleableError {
|
|
|
83
85
|
errorWithMessage.stack = source.stack;
|
|
84
86
|
}
|
|
85
87
|
// Pass source as cause if not already specified in options
|
|
86
|
-
const finalOptions = options?.cause
|
|
88
|
+
const finalOptions = options?.cause
|
|
89
|
+
? options
|
|
90
|
+
: { ...options, cause: source };
|
|
87
91
|
super(errorWithMessage, finalOptions);
|
|
88
92
|
this.componentId = componentId;
|
|
89
93
|
this.type = type;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typed-handleable.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/errors/typed-handleable.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"typed-handleable.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/errors/typed-handleable.ts"],"names":[],"mappings":";;;AAAA,4DAA2D;AAC3D,wDAAmD;AACnD,qDAAiD;AAGjD,6CAA+C;AAG/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,MAAa,oBAIX,SAAQ,4BAAe;IAGE,WAAW,CAAS;IACpB,IAAI,CAAqB;IACzB,SAAS,CAAuC;IACzD,QAAQ,CAAU;IAClB,SAAS,CAAmC;IAE5D,YACE,WAAmB,EACnB,IAAwB,EACxB,SAA+C,EAC/C,MAAa,EACb,OAAgC,EAChC,QAAiB,EACjB,SAA2C;QAE3C,MAAM,GAAG,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;QAE5B,8E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I,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;IAEe,MAAM;QACpB,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QAChC,OAAO;YACL,GAAG,QAAQ;YACX,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC;IACJ,CAAC;CACF;AAjFD,oDAiFC"}
|
package/src/errors/typed.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CoreStringKey } from '../core-string-key';
|
|
2
2
|
import { TranslationEngine } from '../translation-engine';
|
|
3
|
+
import { TypedError as SimpleTypedError } from './simple-typed-error';
|
|
3
4
|
export type { TranslationEngine };
|
|
4
5
|
/**
|
|
5
6
|
* Type constraint to ensure reasonMap has entries for all enum values
|
|
@@ -50,7 +51,8 @@ export declare abstract class BaseTypedError<TEnum extends Record<string, string
|
|
|
50
51
|
static createTranslated<TEnum extends Record<string, string>, TStringKey extends string, TError extends BaseTypedError<TEnum>>(this: new (type: TEnum[keyof TEnum], message: string, metadata?: Record<string, any>) => TError, engine: TranslationEngine, componentId: string, type: TEnum[keyof TEnum], reasonMap: CompleteReasonMap<TEnum, TStringKey>, variables?: Record<string, string | number>, language?: string, metadata?: Record<string, any>): TError;
|
|
51
52
|
}
|
|
52
53
|
/**
|
|
53
|
-
*
|
|
54
|
+
* AbstractTypedError with complete enum coverage and full i18n feature support.
|
|
55
|
+
* @deprecated Use SimpleTypedError from './simple-typed-error' for new code
|
|
54
56
|
*
|
|
55
57
|
* **Supported i18n Features** (via translation strings):
|
|
56
58
|
* - ICU MessageFormat: plural, select, selectordinal
|
|
@@ -83,7 +85,7 @@ export declare abstract class BaseTypedError<TEnum extends Record<string, string
|
|
|
83
85
|
* // Result: "3 errors found"
|
|
84
86
|
* ```
|
|
85
87
|
*/
|
|
86
|
-
export declare abstract class
|
|
88
|
+
export declare abstract class AbstractTypedError<TEnum extends Record<string, string>, TStringKey extends string> extends Error {
|
|
87
89
|
readonly componentId: string;
|
|
88
90
|
readonly type: TEnum[keyof TEnum];
|
|
89
91
|
readonly reasonMap: CompleteReasonMap<TEnum, TStringKey>;
|
|
@@ -189,15 +191,15 @@ export declare function createPluginTypedError<TEnum extends Record<string, stri
|
|
|
189
191
|
/**
|
|
190
192
|
* Helper function to create a component-based TypedError with automatic engine detection
|
|
191
193
|
*/
|
|
192
|
-
export declare function createComponentTypedError<TEnum extends Record<string, string>, TStringKey extends string>(componentId: string, type: TEnum[keyof TEnum], reasonMap: CompleteReasonMap<TEnum, TStringKey>, otherVars?: Record<string, string | number>, language?: string, instanceKey?: string):
|
|
194
|
+
export declare function createComponentTypedError<TEnum extends Record<string, string>, TStringKey extends string>(componentId: string, type: TEnum[keyof TEnum], reasonMap: CompleteReasonMap<TEnum, TStringKey>, otherVars?: Record<string, string | number>, language?: string, instanceKey?: string): SimpleTypedError;
|
|
193
195
|
/**
|
|
194
196
|
* Helper function to create a core system TypedError with automatic engine detection
|
|
195
197
|
*/
|
|
196
|
-
export declare function createCoreTypedError<TEnum extends Record<string, string>>(type: TEnum[keyof TEnum], reasonMap: CompleteReasonMap<TEnum, CoreStringKey>, otherVars?: Record<string, string | number>, language?: string, instanceKey?: string):
|
|
198
|
+
export declare function createCoreTypedError<TEnum extends Record<string, string>>(type: TEnum[keyof TEnum], reasonMap: CompleteReasonMap<TEnum, CoreStringKey>, otherVars?: Record<string, string | number>, language?: string, instanceKey?: string): SimpleTypedError;
|
|
197
199
|
/**
|
|
198
200
|
* Create a simple error with translation support (generalized pattern from RegistryError)
|
|
199
201
|
*/
|
|
200
|
-
export declare function createTranslatedError<TEnum extends Record<string, string>, TStringKey extends string>(engine: TranslationEngine, componentId: string, type: TEnum[keyof TEnum], reasonMap: Record<TEnum[keyof TEnum], TStringKey>, variables?: Record<string, string | number>, language?: string, metadata?: Record<string, any>, errorName?: string):
|
|
202
|
+
export declare function createTranslatedError<TEnum extends Record<string, string>, TStringKey extends string>(engine: TranslationEngine, componentId: string, type: TEnum[keyof TEnum], reasonMap: Record<TEnum[keyof TEnum], TStringKey>, variables?: Record<string, string | number>, language?: string, metadata?: Record<string, any>, errorName?: string): SimpleTypedError;
|
|
201
203
|
/**
|
|
202
204
|
* Example usage of the new plugin-based TypedError system
|
|
203
205
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typed.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/errors/typed.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"typed.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/errors/typed.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,UAAU,IAAI,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAEtE,YAAY,EAAE,iBAAiB,EAAE,CAAC;AAElC;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAC3B,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EAC7C,UAAU,SAAS,MAAM,IACvB,MAAM,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,UAAU,CAAC,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,8BAAsB,cAAc,CAClC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CACpC,SAAQ,KAAK;aAEc,IAAI,EAAE,KAAK,CAAC,MAAM,KAAK,CAAC;aAExB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;gBAF9B,IAA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B,CACnC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,UAAU,SAAS,MAAM,EAEzB,MAAM,EAAE,iBAAiB,EACzB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,KAAK,CAAC,MAAM,KAAK,CAAC,EACxB,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,UAAU,CAAC,EACjD,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EAC3C,QAAQ,CAAC,EAAE,MAAM,EACjB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC9B,SAAS,CAAC,EAAE,MAAM,GACjB,gBAAgB,CA6BlB;AAED;;GAEG"}
|
package/src/errors/typed.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CoreTypedError = exports.ComponentTypedError = exports.PluginTypedError = exports.
|
|
3
|
+
exports.CoreTypedError = exports.ComponentTypedError = exports.PluginTypedError = exports.AbstractTypedError = exports.BaseTypedError = void 0;
|
|
4
4
|
exports.createPluginTypedError = createPluginTypedError;
|
|
5
5
|
exports.createComponentTypedError = createComponentTypedError;
|
|
6
6
|
exports.createCoreTypedError = createCoreTypedError;
|
|
7
7
|
exports.createTranslatedError = createTranslatedError;
|
|
8
8
|
// New plugin architecture imports
|
|
9
9
|
// CoreLanguageCode is deprecated - using string for flexibility
|
|
10
|
+
const core_component_id_1 = require("../core-component-id");
|
|
10
11
|
const core_string_key_1 = require("../core-string-key");
|
|
11
|
-
const
|
|
12
|
-
const
|
|
12
|
+
const i18n_engine_1 = require("../core/i18n-engine");
|
|
13
|
+
const simple_typed_error_1 = require("./simple-typed-error");
|
|
13
14
|
/**
|
|
14
15
|
* Base typed error class with full i18n feature support.
|
|
15
16
|
*
|
|
@@ -75,7 +76,8 @@ class BaseTypedError extends Error {
|
|
|
75
76
|
}
|
|
76
77
|
exports.BaseTypedError = BaseTypedError;
|
|
77
78
|
/**
|
|
78
|
-
*
|
|
79
|
+
* AbstractTypedError with complete enum coverage and full i18n feature support.
|
|
80
|
+
* @deprecated Use SimpleTypedError from './simple-typed-error' for new code
|
|
79
81
|
*
|
|
80
82
|
* **Supported i18n Features** (via translation strings):
|
|
81
83
|
* - ICU MessageFormat: plural, select, selectordinal
|
|
@@ -108,7 +110,7 @@ exports.BaseTypedError = BaseTypedError;
|
|
|
108
110
|
* // Result: "3 errors found"
|
|
109
111
|
* ```
|
|
110
112
|
*/
|
|
111
|
-
class
|
|
113
|
+
class AbstractTypedError extends Error {
|
|
112
114
|
componentId;
|
|
113
115
|
type;
|
|
114
116
|
reasonMap;
|
|
@@ -116,9 +118,11 @@ class TypedError extends Error {
|
|
|
116
118
|
otherVars;
|
|
117
119
|
constructor(componentId, type, reasonMap, language, otherVars) {
|
|
118
120
|
const key = reasonMap[type];
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
121
|
+
// Lazy initialization: getInstance() is only called when error is constructed
|
|
122
|
+
const engine = i18n_engine_1.I18nEngine.getInstance('default');
|
|
123
|
+
if (!key) {
|
|
124
|
+
throw new Error(engine.safeTranslate(core_component_id_1.CoreI18nComponentId, core_string_key_1.CoreStringKey.Error_MissingTranslationKeyTemplate, { type }, language));
|
|
125
|
+
}
|
|
122
126
|
// Use translate instead of safeTranslate to get actual translations
|
|
123
127
|
let message;
|
|
124
128
|
try {
|
|
@@ -137,7 +141,7 @@ class TypedError extends Error {
|
|
|
137
141
|
this.name = this.constructor.name;
|
|
138
142
|
}
|
|
139
143
|
}
|
|
140
|
-
exports.
|
|
144
|
+
exports.AbstractTypedError = AbstractTypedError;
|
|
141
145
|
/**
|
|
142
146
|
* Component-based TypedError that works with the component registration system
|
|
143
147
|
* @deprecated Use TypedError instead - PluginTypedError is an alias for backward compatibility
|
|
@@ -150,10 +154,11 @@ class PluginTypedError extends Error {
|
|
|
150
154
|
otherVars;
|
|
151
155
|
constructor(componentId, type, reasonMap, language, otherVars) {
|
|
152
156
|
const key = reasonMap[type];
|
|
153
|
-
|
|
157
|
+
// Lazy initialization: getInstance() is only called when error is constructed
|
|
158
|
+
const engine = i18n_engine_1.I18nEngine.getInstance('default');
|
|
154
159
|
// If key is not found in the reason map, use core error message
|
|
155
160
|
if (!key) {
|
|
156
|
-
const errorMsg = engine.safeTranslate(
|
|
161
|
+
const errorMsg = engine.safeTranslate(core_component_id_1.CoreI18nComponentId, core_string_key_1.CoreStringKey.Error_StringKeyNotFoundTemplate, {
|
|
157
162
|
stringKey: String(type),
|
|
158
163
|
componentId: componentId,
|
|
159
164
|
}, language);
|
|
@@ -214,10 +219,11 @@ class ComponentTypedError extends Error {
|
|
|
214
219
|
otherVars;
|
|
215
220
|
constructor(componentId, type, reasonMap, language, otherVars) {
|
|
216
221
|
const key = reasonMap[type];
|
|
217
|
-
|
|
222
|
+
// Lazy initialization: getInstance() is only called when error is constructed
|
|
223
|
+
const engine = i18n_engine_1.I18nEngine.getInstance('default');
|
|
218
224
|
// If key is not found in the reason map, use core error message
|
|
219
225
|
if (!key) {
|
|
220
|
-
const errorMsg = engine.safeTranslate(
|
|
226
|
+
const errorMsg = engine.safeTranslate(core_component_id_1.CoreI18nComponentId, core_string_key_1.CoreStringKey.Error_StringKeyNotFoundTemplate, {
|
|
221
227
|
stringKey: String(type),
|
|
222
228
|
componentId: componentId,
|
|
223
229
|
}, language);
|
|
@@ -270,17 +276,18 @@ class CoreTypedError extends Error {
|
|
|
270
276
|
otherVars;
|
|
271
277
|
constructor(type, reasonMap, language, otherVars) {
|
|
272
278
|
const key = reasonMap[type];
|
|
273
|
-
|
|
279
|
+
// Lazy initialization: getInstance() is only called when error is constructed
|
|
280
|
+
const engine = i18n_engine_1.I18nEngine.getInstance('default');
|
|
274
281
|
// If key is not found in the reason map, use a fallback error
|
|
275
282
|
if (!key) {
|
|
276
|
-
const errorMsg = engine.safeTranslate(
|
|
283
|
+
const errorMsg = engine.safeTranslate(core_component_id_1.CoreI18nComponentId, core_string_key_1.CoreStringKey.Error_StringKeyNotFoundTemplate, {
|
|
277
284
|
stringKey: String(type),
|
|
278
|
-
componentId:
|
|
285
|
+
componentId: core_component_id_1.CoreI18nComponentId,
|
|
279
286
|
}, language);
|
|
280
287
|
throw new Error(errorMsg);
|
|
281
288
|
}
|
|
282
289
|
// Translate the error message using the core component
|
|
283
|
-
const translatedMessage = engine.safeTranslate(
|
|
290
|
+
const translatedMessage = engine.safeTranslate(core_component_id_1.CoreI18nComponentId, key, otherVars, language);
|
|
284
291
|
super(translatedMessage);
|
|
285
292
|
this.type = type;
|
|
286
293
|
this.reasonMap = reasonMap;
|
|
@@ -301,17 +308,18 @@ function createPluginTypedError(componentId, type, reasonMap, otherVars, languag
|
|
|
301
308
|
* Helper function to create a component-based TypedError with automatic engine detection
|
|
302
309
|
*/
|
|
303
310
|
function createComponentTypedError(componentId, type, reasonMap, otherVars, language, instanceKey) {
|
|
304
|
-
// Get the engine to ensure it exists, but the error class will get it again
|
|
305
|
-
const engine = core_1.I18nEngine.getInstance(instanceKey || 'default');
|
|
306
311
|
const key = reasonMap[type];
|
|
307
312
|
if (!key) {
|
|
308
313
|
throw new Error(`Missing key for type ${type} in reason map`);
|
|
309
314
|
}
|
|
315
|
+
// Lazy initialization: getInstance() is only called when function is executed
|
|
316
|
+
const engine = i18n_engine_1.I18nEngine.getInstance(instanceKey || 'default');
|
|
310
317
|
const message = engine.safeTranslate(componentId, key, otherVars, language);
|
|
311
|
-
const error = new
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
318
|
+
const error = new simple_typed_error_1.TypedError(message, {
|
|
319
|
+
type,
|
|
320
|
+
componentId,
|
|
321
|
+
reasonMap,
|
|
322
|
+
});
|
|
315
323
|
error.name = 'PluginTypedError';
|
|
316
324
|
return error;
|
|
317
325
|
}
|
|
@@ -319,15 +327,18 @@ function createComponentTypedError(componentId, type, reasonMap, otherVars, lang
|
|
|
319
327
|
* Helper function to create a core system TypedError with automatic engine detection
|
|
320
328
|
*/
|
|
321
329
|
function createCoreTypedError(type, reasonMap, otherVars, language, instanceKey) {
|
|
322
|
-
const engine = core_1.I18nEngine.getInstance(instanceKey || 'default');
|
|
323
330
|
const key = reasonMap[type];
|
|
324
331
|
if (!key) {
|
|
325
332
|
throw new Error(`Missing key for type ${type} in reason map`);
|
|
326
333
|
}
|
|
327
|
-
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
error
|
|
334
|
+
// Lazy initialization: getInstance() is only called when function is executed
|
|
335
|
+
const engine = i18n_engine_1.I18nEngine.getInstance(instanceKey || 'default');
|
|
336
|
+
const message = engine.safeTranslate(core_component_id_1.CoreI18nComponentId, key, otherVars, language);
|
|
337
|
+
const error = new simple_typed_error_1.TypedError(message, {
|
|
338
|
+
type,
|
|
339
|
+
componentId: core_component_id_1.CoreI18nComponentId,
|
|
340
|
+
reasonMap,
|
|
341
|
+
});
|
|
331
342
|
error.name = 'CoreTypedError';
|
|
332
343
|
return error;
|
|
333
344
|
}
|
|
@@ -351,10 +362,12 @@ function createTranslatedError(engine, componentId, type, reasonMap, variables,
|
|
|
351
362
|
// Fallback to a basic English message
|
|
352
363
|
message = `Error: ${type}${metadata ? ` - ${JSON.stringify(metadata)}` : ''}`;
|
|
353
364
|
}
|
|
354
|
-
const error = new
|
|
365
|
+
const error = new simple_typed_error_1.TypedError(message, {
|
|
366
|
+
type,
|
|
367
|
+
componentId,
|
|
368
|
+
metadata,
|
|
369
|
+
});
|
|
355
370
|
error.name = errorName || 'TranslatedError';
|
|
356
|
-
error.type = type;
|
|
357
|
-
error.metadata = metadata;
|
|
358
371
|
return error;
|
|
359
372
|
}
|
|
360
373
|
/**
|
package/src/errors/typed.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typed.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/errors/typed.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"typed.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/errors/typed.ts"],"names":[],"mappings":";;;AAwYA,wDAmBC;AAKD,8DA6BC;AAKD,oDA8BC;AAKD,sDAyCC;AA9gBD,kCAAkC;AAClC,gEAAgE;AAChE,4DAA2D;AAC3D,wDAAmD;AACnD,qDAAiD;AAEjD,6DAAsE;AAYtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAsB,cAEpB,SAAQ,KAAK;IAEc;IAEA;IAH3B,YAC2B,IAAwB,EACjD,OAAe,EACU,QAA8B;QAEvD,KAAK,CAAC,OAAO,CAAC,CAAC;QAJU,SAAI,GAAJ,IAAI,CAAoB;QAExB,aAAQ,GAAR,QAAQ,CAAsB;QAGvD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,YAAY,CASjB,IAAwB,EACxB,OAAe,EACf,QAA8B;QAE9B,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,gBAAgB,CAUrB,MAAyB,EACzB,WAAmB,EACnB,IAAwB,EACxB,SAA+C,EAC/C,SAA2C,EAC3C,QAAiB,EACjB,QAA8B;QAE9B,MAAM,GAAG,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;QAC5B,IAAI,OAAe,CAAC;QAEpB,IAAI,GAAG,IAAI,MAAM,EAAE,CAAC;YAClB,sDAAsD;YACtD,OAAO,GAAG,MAAM,CAAC,aAAa,CAAC,WAAW,EAAE,GAAG,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;QACxE,CAAC;aAAM,CAAC;YACN,sCAAsC;YACtC,OAAO,GAAG,UAAU,IAAI,GACtB,QAAQ,CAAC,CAAC,CAAC,MAAM,IAAI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AG,IAAI,MAAM,EAAE,CAAC;QAClB,IAAI,CAAC;YACH,sDAAsD;YACtD,OAAO,GAAG,MAAM,CAAC,aAAa,CAAC,WAAW,EAAE,GAAG,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;QACxE,CAAC;QAAC,OAAO,gBAAgB,EAAE,CAAC;YAC1B,gCAAgC;YAChC,OAAO,GAAG,UAAU,IAAI,GACtB,QAAQ,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,EAChD,EAAE,CAAC;QACL,CAAC;IACH,CAAC;SAAM,CAAC;QACN,sCAAsC;QACtC,OAAO,GAAG,UAAU,IAAI,GACtB,QAAQ,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,EAChD,EAAE,CAAC;IACL,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,+BAAgB,CAAC,OAAO,EAAE;QAC1C,IAAI;QACJ,WAAW;QACX,QAAQ;KACT,CAAC,CAAC;IACH,KAAK,CAAC,IAAI,GAAG,SAAS,IAAI,iBAAiB,CAAC;IAE5C,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AAEH,mDAAmD;AACnD;;;;;;;;;;;;;;;;;;;;;;;;;EAyBE;AAEF,wDAAwD;AACxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+BE;AAEF,+DAA+D;AAC/D;;;;;;;;;;;;;;;;;;;EAmBE;AAEF,4DAA4D"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { IActiveContext } from './active-context';
|
|
1
|
+
import type { IActiveContext } from './interfaces/active-context.interface';
|
|
2
|
+
import type { IGlobalActiveContext } from './interfaces/global-active-context';
|
|
3
|
+
import { LanguageContextSpace } from './types';
|
|
2
4
|
import { CurrencyCode } from './utils/currency';
|
|
3
|
-
import { IGlobalActiveContext } from './interfaces/global-active-context';
|
|
4
5
|
import { Timezone } from './utils/timezone';
|
|
5
|
-
import { LanguageContextSpace } from './types';
|
|
6
6
|
export declare class GlobalActiveContext<TLanguage extends string, TActiveContext extends IActiveContext<TLanguage>> implements IGlobalActiveContext<TLanguage, TActiveContext> {
|
|
7
7
|
protected static _contextMap: Map<string, IActiveContext<any>>;
|
|
8
8
|
static readonly defaultContextKey = "default";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global-active-context.d.ts","sourceRoot":"","sources":["../../../../packages/digitaldefiance-i18n-lib/src/global-active-context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"global-active-context.d.ts","sourceRoot":"","sources":["../../../../packages/digitaldefiance-i18n-lib/src/global-active-context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAGL,oBAAoB,EACrB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,qBAAa,mBAAmB,CAC9B,SAAS,SAAS,MAAM,EACxB,cAAc,SAAS,cAAc,CAAC,SAAS,CAAC,CAChD,YAAW,oBAAoB,CAAC,SAAS,EAAE,cAAc,CAAC;IAE1D,SAAS,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC,CAAa;IAC3E,gBAAuB,iBAAiB,aAAa;IACrD,gBAAuB,eAAe,EAAE,MAAM,CAAW;IAEzD,OAAO,CAAC,MAAM,CAAC,SAAS,CAA4C;IACpE,WAAkB,QAAQ,IAAI,mBAAmB,CAAC,GAAG,EAAE,GAAG,CAAC,CAM1D;WAQa,WAAW,CACvB,SAAS,SAAS,MAAM,EACxB,cAAc,SAAS,cAAc,C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AElC;IAED,IAAW,YAAY,CAAC,EAAE,EAAE,QAAQ,EAEnC;IAEM,gBAAgB,CACrB,EAAE,EAAE,QAAQ,EACZ,GAAG,GAAE,MAA8C,GAClD,IAAI;IAWP,IAAW,aAAa,IAAI,QAAQ,CAEnC;IAED,IAAW,aAAa,CAAC,EAAE,EAAE,QAAQ,EAEpC;IAED;;OAEG;WACW,QAAQ,IAAI,IAAI;CAI/B"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GlobalActiveContext = void 0;
|
|
4
|
-
const context_error_1 = require("./errors/context-error");
|
|
5
4
|
const context_error_type_1 = require("./context-error-type");
|
|
5
|
+
const context_error_1 = require("./errors/context-error");
|
|
6
|
+
const types_1 = require("./types");
|
|
6
7
|
const currency_1 = require("./utils/currency");
|
|
7
8
|
const timezone_1 = require("./utils/timezone");
|
|
8
|
-
const types_1 = require("./types");
|
|
9
9
|
class GlobalActiveContext {
|
|
10
10
|
static _contextMap = new Map();
|
|
11
11
|
static defaultContextKey = 'default';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global-active-context.js","sourceRoot":"","sources":["../../../../packages/digitaldefiance-i18n-lib/src/global-active-context.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"global-active-context.js","sourceRoot":"","sources":["../../../../packages/digitaldefiance-i18n-lib/src/global-active-context.ts"],"names":[],"mappings":";;;AAAA,6DAAwD;AACxD,0DAAsD;AAGtD,mCAIiB;AACjB,+CAAgD;AAChD,+CAA4C;AAE5C,MAAa,mBAAmB;IAKpB,MAAM,CAAC,WAAW,GAAqC,IAAI,GAAG,EAAE,CAAC;IACpE,MAAM,CAAU,iBAAiB,GAAG,SAAS,CAAC;IAC9C,MAAM,CAAU,eAAe,GAAW,OAAO,CAAC;IAEjD,MAAM,CAAC,SAAS,CAA4C;IAC7D,MAAM,KAAK,QAAQ;QACxB,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AC;IAC/D,CAAC;IAED,IAAW,aAAa;QACtB,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;IACpC,CAAC;IAED,IAAW,aAAa,CAAC,EAAY;QACnC,IAAI,CAAC,OAAO,CAAC,aAAa,GAAG,EAAE,CAAC;IAClC,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,QAAQ;QACpB,mBAAmB,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QACxC,mBAAmB,CAAC,SAAS,GAAG,SAAS,CAAC;IAC5C,CAAC;;AA5PH,kDA6PC"}
|
package/src/index.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
export * from './builders';
|
|
2
2
|
export * from './core';
|
|
3
3
|
export * from './errors';
|
|
4
|
+
export * from './gender';
|
|
4
5
|
export * from './interfaces';
|
|
5
|
-
export * from './utils';
|
|
6
|
-
export * from './types';
|
|
7
6
|
export * from './pluralization';
|
|
8
|
-
export * from './
|
|
7
|
+
export * from './types';
|
|
8
|
+
export * from './utils';
|
|
9
9
|
export * from './validation';
|
|
10
|
-
export { Timezone, isValidTimezone } from './utils/timezone';
|
|
11
|
-
export { CurrencyCode, getCurrencyFormat } from './utils/currency';
|
|
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';
|
|
15
10
|
export type { GenderedString } from './gender/gender-categories';
|
|
16
|
-
export {
|
|
11
|
+
export type { PluralString } from './types/plural-types';
|
|
12
|
+
export { CurrencyCode, getCurrencyFormat } from './utils/currency';
|
|
13
|
+
export type { CurrencyData, CurrencyFormat, CurrencyPosition, } from './utils/currency';
|
|
14
|
+
export { createGenderedString, createPluralString, } from './utils/plural-helpers';
|
|
15
|
+
export { isValidTimezone, Timezone } from './utils/timezone';
|
|
17
16
|
export { I18nBuilder as Builder } from './builders/i18n-builder';
|
|
17
|
+
export { I18nEngine as I18n } from './core/i18n-engine';
|
|
18
18
|
export declare function resetAll(): void;
|
|
19
19
|
export * from './active-context';
|
|
20
20
|
export * from './component-definition';
|
|
@@ -39,8 +39,8 @@ export * from './translation-request';
|
|
|
39
39
|
export * from './translation-response';
|
|
40
40
|
export * from './types';
|
|
41
41
|
export * from './validation-config';
|
|
42
|
-
export { createCorePluginI18nEngine as createCoreI18n, createCorePluginI18nEngine as createCoreI18nEngine } from './core-
|
|
43
|
-
export
|
|
42
|
+
export { createCorePluginI18nEngine as createCoreI18n, createCorePluginI18nEngine as createCoreI18nEngine, getCorePluginTranslation as getCoreTranslation, safeCorePluginTranslation as safeCoreTranslation, } from './core-plugin-factory';
|
|
43
|
+
export * from './core-plugin-factory';
|
|
44
44
|
export { PluginI18nEngine as PluginI18n } from './plugin-i18n-engine';
|
|
45
45
|
export declare function resetAllI18nEngines(): void;
|
|
46
46
|
//# sourceMappingURL=index.d.ts.map
|
package/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/digitaldefiance-i18n-lib/src/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/digitaldefiance-i18n-lib/src/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAG7B,YAAY,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OA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