gt-i18n 0.8.13 → 0.9.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.
Files changed (34) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/{TranslationsCache-CCbpu4hE.d.mts → TranslationsCache-DQt4Es4G.d.cts} +35 -21
  3. package/dist/{TranslationsCache-DKwwyNRA.d.cts → TranslationsCache-DdoHhP9C.d.mts} +35 -21
  4. package/dist/fallbacks.d.cts +1 -1
  5. package/dist/fallbacks.d.mts +1 -1
  6. package/dist/{functions-BdYU6e8M.d.mts → functions-DdlVwVU8.d.mts} +9 -4
  7. package/dist/{functions-BqtnSFF4.d.cts → functions-DsYQxTQp.d.cts} +9 -4
  8. package/dist/{index-DJVRTYiP.d.cts → index-XRxZZ8E4.d.mts} +2 -2
  9. package/dist/{index-YDEznmyZ.d.mts → index-v3fx8YUH.d.cts} +2 -2
  10. package/dist/index.cjs +1 -1
  11. package/dist/index.d.cts +2 -2
  12. package/dist/index.d.mts +2 -2
  13. package/dist/index.mjs +1 -1
  14. package/dist/internal-types.d.cts +4 -4
  15. package/dist/internal-types.d.mts +4 -4
  16. package/dist/internal.cjs +75 -11
  17. package/dist/internal.cjs.map +1 -1
  18. package/dist/internal.d.cts +57 -8
  19. package/dist/internal.d.mts +57 -8
  20. package/dist/internal.mjs +76 -12
  21. package/dist/internal.mjs.map +1 -1
  22. package/dist/{localeResolver-CHA4wSwo.d.cts → localeResolver-DPayN_xR.d.mts} +4 -4
  23. package/dist/{localeResolver-Dd-qLfx9.d.mts → localeResolver-DcN9SGPs.d.cts} +4 -4
  24. package/dist/{options-BOz9P0yM.d.cts → options-C1xolwBY.d.cts} +11 -2
  25. package/dist/{options-gL1Zt8jG.d.mts → options-DeF1NEbe.d.mts} +11 -2
  26. package/dist/types.d.cts +4 -4
  27. package/dist/types.d.mts +4 -4
  28. package/dist/{versionId-jccDLifj.mjs → versionId-D0t6HuUM.mjs} +289 -62
  29. package/dist/versionId-D0t6HuUM.mjs.map +1 -0
  30. package/dist/{versionId-4kKcipCU.cjs → versionId-qtCCdgKr.cjs} +306 -61
  31. package/dist/versionId-qtCCdgKr.cjs.map +1 -0
  32. package/package.json +5 -4
  33. package/dist/versionId-4kKcipCU.cjs.map +0 -1
  34. package/dist/versionId-jccDLifj.mjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,41 @@
1
1
  # gt-i18n
2
2
 
3
+ ## 0.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1359](https://github.com/generaltranslation/gt/pull/1359) [`528bb4a`](https://github.com/generaltranslation/gt/commit/528bb4a34b3eeab6f676137ab0f09e85dff213b0) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - Enable dictionary-backed getTranslations with t and t.obj, and expose it from gt-node.
8
+
9
+ ### Patch Changes
10
+
11
+ - [#1354](https://github.com/generaltranslation/gt/pull/1354) [`663af94`](https://github.com/generaltranslation/gt/commit/663af94207bc244de30046d96130e913f48c9add) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - Add dictionary lookup with runtime fallback.
12
+
13
+ - [#1355](https://github.com/generaltranslation/gt/pull/1355) [`a88c86d`](https://github.com/generaltranslation/gt/commit/a88c86df7842299063f1a2f6f7404e021c905016) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - Add dictionary cache object get and set primitives.
14
+
15
+ - [#1358](https://github.com/generaltranslation/gt/pull/1358) [`0f252ff`](https://github.com/generaltranslation/gt/commit/0f252fff408c701811cba61565beaf15bf9cdd95) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - Add dictionary object lookup with runtime fallback.
16
+
17
+ - [#1356](https://github.com/generaltranslation/gt/pull/1356) [`ee3a6ee`](https://github.com/generaltranslation/gt/commit/ee3a6eea113fbc5c2f5f0e8771d878a305f7bc7f) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - Add dictionary object lookup on the i18n manager.
18
+
19
+ - [#1357](https://github.com/generaltranslation/gt/pull/1357) [`375d75f`](https://github.com/generaltranslation/gt/commit/375d75f7a6525d83e19a5cf015a375a0f50537d2) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - Add runtime fallback primitives for dictionary object cache misses.
20
+
21
+ - [#1349](https://github.com/generaltranslation/gt/pull/1349) [`e123485`](https://github.com/generaltranslation/gt/commit/e12348563700ed886f64b2e00d7964355fb4558a) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - Return dictionary metadata from dictionary cache lookups.
22
+
23
+ - [#1351](https://github.com/generaltranslation/gt/pull/1351) [`40e26b9`](https://github.com/generaltranslation/gt/commit/40e26b914295101d1be00f738fc33eb4ba9c495a) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - Add runtime translation fallback for dictionary cache misses.
24
+
25
+ - Updated dependencies [[`9eae4d9`](https://github.com/generaltranslation/gt/commit/9eae4d93476688b621c739683c8bac64cbf50bf0)]:
26
+ - generaltranslation@8.2.12
27
+ - @generaltranslation/supported-locales@2.0.70
28
+
29
+ ## 0.8.14
30
+
31
+ ### Patch Changes
32
+
33
+ - [#1328](https://github.com/generaltranslation/gt/pull/1328) [`cb2e106`](https://github.com/generaltranslation/gt/commit/cb2e1066f975dce8e90b166c51f763a3778c3861) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - Add dictionary lookup.
34
+
35
+ - [#1329](https://github.com/generaltranslation/gt/pull/1329) [`b907d87`](https://github.com/generaltranslation/gt/commit/b907d8799670e9e22355b5664da4c9f6f323b8f4) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - Add dictionary cache lifecycle events.
36
+
37
+ - [#1346](https://github.com/generaltranslation/gt/pull/1346) [`bf0386b`](https://github.com/generaltranslation/gt/commit/bf0386b38b8a9342619eb2f8b4e5f043dcba4d8f) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - Add dictionary metadata entry types without applying metadata at lookup time.
38
+
3
39
  ## 0.8.13
4
40
 
5
41
  ### Patch Changes
@@ -1,5 +1,6 @@
1
- import { RuntimeTranslateManyOptions } from "generaltranslation/internal";
1
+ import { r as DictionaryOptions } from "./options-C1xolwBY.cjs";
2
2
  import { Content } from "generaltranslation/types";
3
+ import { RuntimeTranslateManyOptions } from "generaltranslation/internal";
3
4
 
4
5
  //#region src/i18n-manager/translations-manager/utils/types/translation-data.d.ts
5
6
  /**
@@ -14,28 +15,18 @@ type Translation = Content;
14
15
  */
15
16
  type Locale = string;
16
17
  //#endregion
17
- //#region src/i18n-manager/translations-manager/DictionaryCache.d.ts
18
- /**
19
- * A dictionary is a nested object with strings as leaf values
20
- */
18
+ //#region src/i18n-manager/translations-manager/utils/types/dictionary.d.ts
19
+ type DictionaryLeaf = string | [string] | [string, DictionaryOptions];
21
20
  type Dictionary = {
22
21
  [key: string]: DictionaryValue;
23
22
  };
24
- /**
25
- * Value stored in a dictionary
26
- */
27
- type DictionaryValue = string | Dictionary;
28
- /**
29
- * Value returned from a dictionary lookup
30
- */
31
- type DictionaryEntry = string;
32
- /**
33
- * Just a way to be more explicit about what "dictionary path" is
34
- */
23
+ type DictionaryValue = DictionaryLeaf | Dictionary;
24
+ type DictionaryEntry = {
25
+ entry: string;
26
+ options: DictionaryOptions;
27
+ };
28
+ type DictionaryObject = DictionaryValue;
35
29
  type DictionaryPath = string;
36
- /**
37
- * InputKey type for lookups
38
- */
39
30
  type DictionaryKey = DictionaryPath;
40
31
  //#endregion
41
32
  //#region src/i18n-manager/translations-manager/LocalesDictionaryCache.d.ts
@@ -75,6 +66,29 @@ type LifecycleCallbacks<TranslationValue extends Translation> = {
75
66
  translations: Record<Hash, TranslationValue>; /** @deprecated - use translations instead */
76
67
  value: Record<Hash, TranslationValue>;
77
68
  }) => void;
69
+ onDictionaryCacheHit?: (params: {
70
+ locale: Locale;
71
+ id: DictionaryPath;
72
+ dictionaryEntry: DictionaryEntry;
73
+ }) => void;
74
+ onDictionaryCacheMiss?: (params: {
75
+ locale: Locale;
76
+ id: DictionaryPath;
77
+ dictionaryEntry: DictionaryEntry;
78
+ }) => void;
79
+ onDictionaryObjectCacheHit?: (params: {
80
+ locale: Locale;
81
+ id: DictionaryPath;
82
+ dictionaryValue: DictionaryValue;
83
+ }) => void;
84
+ onLocalesDictionaryCacheHit?: (params: {
85
+ locale: Locale;
86
+ dictionary: Dictionary;
87
+ }) => void;
88
+ onLocalesDictionaryCacheMiss?: (params: {
89
+ locale: Locale;
90
+ dictionary: Dictionary;
91
+ }) => void;
78
92
  };
79
93
  //#endregion
80
94
  //#region src/i18n-manager/translations-manager/TranslationsCache.d.ts
@@ -88,5 +102,5 @@ type TranslationBatchConfig = {
88
102
  */
89
103
  type Hash = string;
90
104
  //#endregion
91
- export { Dictionary as a, DictionaryPath as c, Translation as d, DictionaryLoader as i, DictionaryValue as l, TranslationBatchConfig as n, DictionaryEntry as o, LifecycleCallbacks as r, DictionaryKey as s, Hash as t, Locale as u };
92
- //# sourceMappingURL=TranslationsCache-CCbpu4hE.d.mts.map
105
+ export { Dictionary as a, DictionaryLeaf as c, DictionaryValue as d, Locale as f, DictionaryLoader as i, DictionaryObject as l, TranslationBatchConfig as n, DictionaryEntry as o, Translation as p, LifecycleCallbacks as r, DictionaryKey as s, Hash as t, DictionaryPath as u };
106
+ //# sourceMappingURL=TranslationsCache-DQt4Es4G.d.cts.map
@@ -1,5 +1,6 @@
1
- import { Content } from "generaltranslation/types";
1
+ import { r as DictionaryOptions } from "./options-DeF1NEbe.mjs";
2
2
  import { RuntimeTranslateManyOptions } from "generaltranslation/internal";
3
+ import { Content } from "generaltranslation/types";
3
4
 
4
5
  //#region src/i18n-manager/translations-manager/utils/types/translation-data.d.ts
5
6
  /**
@@ -14,28 +15,18 @@ type Translation = Content;
14
15
  */
15
16
  type Locale = string;
16
17
  //#endregion
17
- //#region src/i18n-manager/translations-manager/DictionaryCache.d.ts
18
- /**
19
- * A dictionary is a nested object with strings as leaf values
20
- */
18
+ //#region src/i18n-manager/translations-manager/utils/types/dictionary.d.ts
19
+ type DictionaryLeaf = string | [string] | [string, DictionaryOptions];
21
20
  type Dictionary = {
22
21
  [key: string]: DictionaryValue;
23
22
  };
24
- /**
25
- * Value stored in a dictionary
26
- */
27
- type DictionaryValue = string | Dictionary;
28
- /**
29
- * Value returned from a dictionary lookup
30
- */
31
- type DictionaryEntry = string;
32
- /**
33
- * Just a way to be more explicit about what "dictionary path" is
34
- */
23
+ type DictionaryValue = DictionaryLeaf | Dictionary;
24
+ type DictionaryEntry = {
25
+ entry: string;
26
+ options: DictionaryOptions;
27
+ };
28
+ type DictionaryObject = DictionaryValue;
35
29
  type DictionaryPath = string;
36
- /**
37
- * InputKey type for lookups
38
- */
39
30
  type DictionaryKey = DictionaryPath;
40
31
  //#endregion
41
32
  //#region src/i18n-manager/translations-manager/LocalesDictionaryCache.d.ts
@@ -75,6 +66,29 @@ type LifecycleCallbacks<TranslationValue extends Translation> = {
75
66
  translations: Record<Hash, TranslationValue>; /** @deprecated - use translations instead */
76
67
  value: Record<Hash, TranslationValue>;
77
68
  }) => void;
69
+ onDictionaryCacheHit?: (params: {
70
+ locale: Locale;
71
+ id: DictionaryPath;
72
+ dictionaryEntry: DictionaryEntry;
73
+ }) => void;
74
+ onDictionaryCacheMiss?: (params: {
75
+ locale: Locale;
76
+ id: DictionaryPath;
77
+ dictionaryEntry: DictionaryEntry;
78
+ }) => void;
79
+ onDictionaryObjectCacheHit?: (params: {
80
+ locale: Locale;
81
+ id: DictionaryPath;
82
+ dictionaryValue: DictionaryValue;
83
+ }) => void;
84
+ onLocalesDictionaryCacheHit?: (params: {
85
+ locale: Locale;
86
+ dictionary: Dictionary;
87
+ }) => void;
88
+ onLocalesDictionaryCacheMiss?: (params: {
89
+ locale: Locale;
90
+ dictionary: Dictionary;
91
+ }) => void;
78
92
  };
79
93
  //#endregion
80
94
  //#region src/i18n-manager/translations-manager/TranslationsCache.d.ts
@@ -88,5 +102,5 @@ type TranslationBatchConfig = {
88
102
  */
89
103
  type Hash = string;
90
104
  //#endregion
91
- export { Dictionary as a, DictionaryPath as c, Translation as d, DictionaryLoader as i, DictionaryValue as l, TranslationBatchConfig as n, DictionaryEntry as o, LifecycleCallbacks as r, DictionaryKey as s, Hash as t, Locale as u };
92
- //# sourceMappingURL=TranslationsCache-DKwwyNRA.d.cts.map
105
+ export { Dictionary as a, DictionaryLeaf as c, DictionaryValue as d, Locale as f, DictionaryLoader as i, DictionaryObject as l, TranslationBatchConfig as n, DictionaryEntry as o, Translation as p, LifecycleCallbacks as r, DictionaryKey as s, Hash as t, DictionaryPath as u };
106
+ //# sourceMappingURL=TranslationsCache-DdoHhP9C.d.mts.map
@@ -1,2 +1,2 @@
1
- import { n as gtFallback, t as mFallback } from "./index-DJVRTYiP.cjs";
1
+ import { n as gtFallback, t as mFallback } from "./index-v3fx8YUH.cjs";
2
2
  export { gtFallback, mFallback };
@@ -1,2 +1,2 @@
1
- import { n as gtFallback, t as mFallback } from "./index-YDEznmyZ.mjs";
1
+ import { n as gtFallback, t as mFallback } from "./index-XRxZZ8E4.mjs";
2
2
  export { gtFallback, mFallback };
@@ -1,7 +1,10 @@
1
- import { a as InlineTranslationOptions, n as DictionaryTranslationOptions, o as JsxTranslationOptions } from "./options-gL1Zt8jG.mjs";
1
+ import { c as JsxTranslationOptions, i as DictionaryTranslationOptions, s as InlineTranslationOptions } from "./options-DeF1NEbe.mjs";
2
2
  import { JsxChildren } from "generaltranslation/types";
3
3
 
4
4
  //#region src/translation-functions/types/functions.d.ts
5
+ type DictionaryObjectTranslation = string | {
6
+ [key: string]: DictionaryObjectTranslation;
7
+ };
5
8
  /**
6
9
  * Synchronous resolution function type
7
10
  * @param {string} message - The message to translate.
@@ -48,7 +51,9 @@ type MFunctionType = <T extends string | null | undefined>(encodedMsg: T, option
48
51
  * @returns {string} The translated message.
49
52
  * TODO: next major version, remove the "...type" suffix, it's redundant
50
53
  */
51
- type TFunctionType = (id: string, options?: DictionaryTranslationOptions) => string;
54
+ type TFunctionType = ((id: string, options?: DictionaryTranslationOptions) => string) & {
55
+ obj: (id: string) => DictionaryObjectTranslation;
56
+ };
52
57
  /**
53
58
  * Type for the resolveJsxTranslation() function
54
59
  * @param {JsxChildren} children - The children to resolve the translation for.
@@ -57,5 +62,5 @@ type TFunctionType = (id: string, options?: DictionaryTranslationOptions) => str
57
62
  */
58
63
  type ResolveJsxTranslationFunction = (locale: string, children: JsxChildren, options?: JsxTranslationOptions) => JsxChildren | undefined;
59
64
  //#endregion
60
- export { SyncResolutionFunctionWithFallback as a, SyncResolutionFunction as i, MFunctionType as n, TFunctionType as o, ResolveJsxTranslationFunction as r, GTFunctionType as t };
61
- //# sourceMappingURL=functions-BdYU6e8M.d.mts.map
65
+ export { SyncResolutionFunction as a, ResolveJsxTranslationFunction as i, GTFunctionType as n, SyncResolutionFunctionWithFallback as o, MFunctionType as r, TFunctionType as s, DictionaryObjectTranslation as t };
66
+ //# sourceMappingURL=functions-DdlVwVU8.d.mts.map
@@ -1,7 +1,10 @@
1
- import { a as InlineTranslationOptions, n as DictionaryTranslationOptions, o as JsxTranslationOptions } from "./options-BOz9P0yM.cjs";
1
+ import { c as JsxTranslationOptions, i as DictionaryTranslationOptions, s as InlineTranslationOptions } from "./options-C1xolwBY.cjs";
2
2
  import { JsxChildren } from "generaltranslation/types";
3
3
 
4
4
  //#region src/translation-functions/types/functions.d.ts
5
+ type DictionaryObjectTranslation = string | {
6
+ [key: string]: DictionaryObjectTranslation;
7
+ };
5
8
  /**
6
9
  * Synchronous resolution function type
7
10
  * @param {string} message - The message to translate.
@@ -48,7 +51,9 @@ type MFunctionType = <T extends string | null | undefined>(encodedMsg: T, option
48
51
  * @returns {string} The translated message.
49
52
  * TODO: next major version, remove the "...type" suffix, it's redundant
50
53
  */
51
- type TFunctionType = (id: string, options?: DictionaryTranslationOptions) => string;
54
+ type TFunctionType = ((id: string, options?: DictionaryTranslationOptions) => string) & {
55
+ obj: (id: string) => DictionaryObjectTranslation;
56
+ };
52
57
  /**
53
58
  * Type for the resolveJsxTranslation() function
54
59
  * @param {JsxChildren} children - The children to resolve the translation for.
@@ -57,5 +62,5 @@ type TFunctionType = (id: string, options?: DictionaryTranslationOptions) => str
57
62
  */
58
63
  type ResolveJsxTranslationFunction = (locale: string, children: JsxChildren, options?: JsxTranslationOptions) => JsxChildren | undefined;
59
64
  //#endregion
60
- export { SyncResolutionFunctionWithFallback as a, SyncResolutionFunction as i, MFunctionType as n, TFunctionType as o, ResolveJsxTranslationFunction as r, GTFunctionType as t };
61
- //# sourceMappingURL=functions-BqtnSFF4.d.cts.map
65
+ export { SyncResolutionFunction as a, ResolveJsxTranslationFunction as i, GTFunctionType as n, SyncResolutionFunctionWithFallback as o, MFunctionType as r, TFunctionType as s, DictionaryObjectTranslation as t };
66
+ //# sourceMappingURL=functions-DsYQxTQp.d.cts.map
@@ -1,4 +1,4 @@
1
- import { n as MFunctionType, t as GTFunctionType } from "./functions-BqtnSFF4.cjs";
1
+ import { n as GTFunctionType, r as MFunctionType } from "./functions-DdlVwVU8.mjs";
2
2
 
3
3
  //#region src/translation-functions/fallbacks/gtFallback.d.ts
4
4
  /**
@@ -57,4 +57,4 @@ declare const gtFallback: GTFunctionType;
57
57
  declare const mFallback: MFunctionType;
58
58
  //#endregion
59
59
  export { gtFallback as n, mFallback as t };
60
- //# sourceMappingURL=index-DJVRTYiP.d.cts.map
60
+ //# sourceMappingURL=index-XRxZZ8E4.d.mts.map
@@ -1,4 +1,4 @@
1
- import { n as MFunctionType, t as GTFunctionType } from "./functions-BdYU6e8M.mjs";
1
+ import { n as GTFunctionType, r as MFunctionType } from "./functions-DsYQxTQp.cjs";
2
2
 
3
3
  //#region src/translation-functions/fallbacks/gtFallback.d.ts
4
4
  /**
@@ -57,4 +57,4 @@ declare const gtFallback: GTFunctionType;
57
57
  declare const mFallback: MFunctionType;
58
58
  //#endregion
59
59
  export { gtFallback as n, mFallback as t };
60
- //# sourceMappingURL=index-YDEznmyZ.d.mts.map
60
+ //# sourceMappingURL=index-v3fx8YUH.d.cts.map
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_isEncodedTranslationOptions = require("./isEncodedTranslationOptions-D7ltjc4f.cjs");
3
- const require_versionId = require("./versionId-4kKcipCU.cjs");
3
+ const require_versionId = require("./versionId-qtCCdgKr.cjs");
4
4
  const require_mFallback = require("./mFallback-CoPRtKyL.cjs");
5
5
  let generaltranslation_internal = require("generaltranslation/internal");
6
6
  let generaltranslation_core = require("generaltranslation/core");
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as InlineTranslationOptions } from "./options-BOz9P0yM.cjs";
2
- import { n as gtFallback, t as mFallback } from "./index-DJVRTYiP.cjs";
1
+ import { s as InlineTranslationOptions } from "./options-C1xolwBY.cjs";
2
+ import { n as gtFallback, t as mFallback } from "./index-v3fx8YUH.cjs";
3
3
  import { t as RegisterableMessages } from "./message-C62MTLwE.cjs";
4
4
  import { a as getLocales, i as getLocaleProperties, n as getDefaultLocale, r as getLocale, t as getVersionId } from "./index-UDlCzB02.cjs";
5
5
  import { declareStatic, declareVar, decodeVars, derive } from "generaltranslation/internal";
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as InlineTranslationOptions } from "./options-gL1Zt8jG.mjs";
2
- import { n as gtFallback, t as mFallback } from "./index-YDEznmyZ.mjs";
1
+ import { s as InlineTranslationOptions } from "./options-DeF1NEbe.mjs";
2
+ import { n as gtFallback, t as mFallback } from "./index-XRxZZ8E4.mjs";
3
3
  import { t as RegisterableMessages } from "./message-BN4DirTg.mjs";
4
4
  import { a as getLocales, i as getLocaleProperties, n as getDefaultLocale, r as getLocale, t as getVersionId } from "./index-Bc5qKE7T.mjs";
5
5
  import { declareStatic, declareVar, decodeVars, derive } from "generaltranslation/internal";
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { a as extractVariables, i as createInterpolationFailureMessage, n as decodeOptions, o as logger_default } from "./isEncodedTranslationOptions-DdHEzDDM.mjs";
2
- import { a as getLocales, d as resolveStringContentWithFallback, i as getLocaleProperties, m as getCurrentLocale, n as getDefaultLocale, r as getLocale, t as getVersionId, y as hashMessage } from "./versionId-jccDLifj.mjs";
2
+ import { S as hashMessage, a as getLocales, d as resolveStringContentWithFallback, i as getLocaleProperties, m as getCurrentLocale, n as getDefaultLocale, r as getLocale, t as getVersionId } from "./versionId-D0t6HuUM.mjs";
3
3
  import { n as gtFallback, r as decodeMsg, t as mFallback } from "./mFallback-BQX_yiE-.mjs";
4
4
  import { VAR_IDENTIFIER, declareStatic, declareVar, decodeVars, derive, encode, libraryDefaultLocale } from "generaltranslation/internal";
5
5
  import { formatMessage } from "generaltranslation/core";
@@ -1,4 +1,4 @@
1
- import { a as InlineTranslationOptions, c as NormalizedLookupOptions, i as InlineResolveOptions, l as ResolutionOptions, n as DictionaryTranslationOptions, o as JsxTranslationOptions, r as EncodedTranslationOptions, s as LookupOptions, t as BaseTranslationOptions, u as RuntimeTranslationOptions } from "./options-BOz9P0yM.cjs";
2
- import { a as ConditionStore, c as I18nManagerConstructorParams, d as TranslationsLoader, f as GTConfig, l as ScopedConditionStore, o as ConditionStoreConfig, p as RenderMethod, s as I18nManagerConfig, t as LocaleCandidates, u as WritableConditionStore } from "./localeResolver-CHA4wSwo.cjs";
3
- import { a as Dictionary, c as DictionaryPath, i as DictionaryLoader, l as DictionaryValue, o as DictionaryEntry, r as LifecycleCallbacks, s as DictionaryKey } from "./TranslationsCache-DKwwyNRA.cjs";
4
- export { BaseTranslationOptions, type ConditionStore, type ConditionStoreConfig, type Dictionary, type DictionaryEntry, type DictionaryKey, type DictionaryLoader, type DictionaryPath, DictionaryTranslationOptions, type DictionaryValue, EncodedTranslationOptions, GTConfig, type I18nManagerConfig, type I18nManagerConstructorParams, InlineResolveOptions, InlineTranslationOptions, JsxTranslationOptions, type LifecycleCallbacks, type LocaleCandidates, LookupOptions, NormalizedLookupOptions, RenderMethod, ResolutionOptions, RuntimeTranslationOptions, type ScopedConditionStore, type TranslationsLoader, type WritableConditionStore };
1
+ import { a as EncodedTranslationOptions, c as JsxTranslationOptions, d as ResolutionOptions, f as RuntimeTranslationOptions, i as DictionaryTranslationOptions, l as LookupOptions, n as DictionaryLookupOptions, o as InlineResolveOptions, r as DictionaryOptions, s as InlineTranslationOptions, t as BaseTranslationOptions, u as NormalizedLookupOptions } from "./options-C1xolwBY.cjs";
2
+ import { a as ConditionStore, c as I18nManagerConfig, d as WritableConditionStore, f as TranslationsLoader, l as I18nManagerConstructorParams, m as RenderMethod, o as ConditionStoreConfig, p as GTConfig, s as DictionaryConfig, t as LocaleCandidates, u as ScopedConditionStore } from "./localeResolver-DcN9SGPs.cjs";
3
+ import { a as Dictionary, c as DictionaryLeaf, d as DictionaryValue, i as DictionaryLoader, l as DictionaryObject, o as DictionaryEntry, r as LifecycleCallbacks, s as DictionaryKey, u as DictionaryPath } from "./TranslationsCache-DQt4Es4G.cjs";
4
+ export { BaseTranslationOptions, type ConditionStore, type ConditionStoreConfig, type Dictionary, type DictionaryConfig, type DictionaryEntry, type DictionaryKey, type DictionaryLeaf, type DictionaryLoader, DictionaryLookupOptions, type DictionaryObject, type DictionaryOptions, type DictionaryPath, DictionaryTranslationOptions, type DictionaryValue, EncodedTranslationOptions, GTConfig, type I18nManagerConfig, type I18nManagerConstructorParams, InlineResolveOptions, InlineTranslationOptions, JsxTranslationOptions, type LifecycleCallbacks, type LocaleCandidates, LookupOptions, NormalizedLookupOptions, RenderMethod, ResolutionOptions, RuntimeTranslationOptions, type ScopedConditionStore, type TranslationsLoader, type WritableConditionStore };
@@ -1,4 +1,4 @@
1
- import { a as InlineTranslationOptions, c as NormalizedLookupOptions, i as InlineResolveOptions, l as ResolutionOptions, n as DictionaryTranslationOptions, o as JsxTranslationOptions, r as EncodedTranslationOptions, s as LookupOptions, t as BaseTranslationOptions, u as RuntimeTranslationOptions } from "./options-gL1Zt8jG.mjs";
2
- import { a as ConditionStore, c as I18nManagerConstructorParams, d as TranslationsLoader, f as GTConfig, l as ScopedConditionStore, o as ConditionStoreConfig, p as RenderMethod, s as I18nManagerConfig, t as LocaleCandidates, u as WritableConditionStore } from "./localeResolver-Dd-qLfx9.mjs";
3
- import { a as Dictionary, c as DictionaryPath, i as DictionaryLoader, l as DictionaryValue, o as DictionaryEntry, r as LifecycleCallbacks, s as DictionaryKey } from "./TranslationsCache-CCbpu4hE.mjs";
4
- export { BaseTranslationOptions, type ConditionStore, type ConditionStoreConfig, type Dictionary, type DictionaryEntry, type DictionaryKey, type DictionaryLoader, type DictionaryPath, DictionaryTranslationOptions, type DictionaryValue, EncodedTranslationOptions, GTConfig, type I18nManagerConfig, type I18nManagerConstructorParams, InlineResolveOptions, InlineTranslationOptions, JsxTranslationOptions, type LifecycleCallbacks, type LocaleCandidates, LookupOptions, NormalizedLookupOptions, RenderMethod, ResolutionOptions, RuntimeTranslationOptions, type ScopedConditionStore, type TranslationsLoader, type WritableConditionStore };
1
+ import { a as EncodedTranslationOptions, c as JsxTranslationOptions, d as ResolutionOptions, f as RuntimeTranslationOptions, i as DictionaryTranslationOptions, l as LookupOptions, n as DictionaryLookupOptions, o as InlineResolveOptions, r as DictionaryOptions, s as InlineTranslationOptions, t as BaseTranslationOptions, u as NormalizedLookupOptions } from "./options-DeF1NEbe.mjs";
2
+ import { a as ConditionStore, c as I18nManagerConfig, d as WritableConditionStore, f as TranslationsLoader, l as I18nManagerConstructorParams, m as RenderMethod, o as ConditionStoreConfig, p as GTConfig, s as DictionaryConfig, t as LocaleCandidates, u as ScopedConditionStore } from "./localeResolver-DPayN_xR.mjs";
3
+ import { a as Dictionary, c as DictionaryLeaf, d as DictionaryValue, i as DictionaryLoader, l as DictionaryObject, o as DictionaryEntry, r as LifecycleCallbacks, s as DictionaryKey, u as DictionaryPath } from "./TranslationsCache-DdoHhP9C.mjs";
4
+ export { BaseTranslationOptions, type ConditionStore, type ConditionStoreConfig, type Dictionary, type DictionaryConfig, type DictionaryEntry, type DictionaryKey, type DictionaryLeaf, type DictionaryLoader, DictionaryLookupOptions, type DictionaryObject, type DictionaryOptions, type DictionaryPath, DictionaryTranslationOptions, type DictionaryValue, EncodedTranslationOptions, GTConfig, type I18nManagerConfig, type I18nManagerConstructorParams, InlineResolveOptions, InlineTranslationOptions, JsxTranslationOptions, type LifecycleCallbacks, type LocaleCandidates, LookupOptions, NormalizedLookupOptions, RenderMethod, ResolutionOptions, RuntimeTranslationOptions, type ScopedConditionStore, type TranslationsLoader, type WritableConditionStore };
package/dist/internal.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_isEncodedTranslationOptions = require("./isEncodedTranslationOptions-D7ltjc4f.cjs");
3
- const require_versionId = require("./versionId-4kKcipCU.cjs");
3
+ const require_versionId = require("./versionId-qtCCdgKr.cjs");
4
4
  let generaltranslation_internal = require("generaltranslation/internal");
5
5
  let generaltranslation_core = require("generaltranslation/core");
6
6
  //#region src/translation-functions/internal/getGT.ts
@@ -91,24 +91,21 @@ async function getMessages() {
91
91
  * @returns A promise of the t function
92
92
  * @important Must be used inside of a request context
93
93
  *
94
- * @deprecated not yet supported
95
- *
96
94
  * @example
97
95
  * const t = await getTranslations();
98
96
  * const title = await t('page.title');
99
97
  */
100
98
  async function getTranslations() {
99
+ const i18nManager = require_versionId.getI18nManager();
100
+ const locale = require_versionId.getCurrentLocale();
101
+ await i18nManager.loadDictionary(locale);
102
+ const sourceLocale = i18nManager.getDefaultLocale();
101
103
  /**
102
104
  * Dictionary resolution
103
105
  * @param {string} id - The id of the translation to translate.
104
- * @param {DictionaryTranslationOptions} options - The options for the translation.
106
+ * @param {DictionaryTranslationOptions} options - The options for interpolation.
105
107
  * @returns {string} The translated message.
106
108
  *
107
- * @deprecated not yet supported
108
- *
109
- * This is a placeholder for the t() function.
110
- * TODO: Implement the t() function.
111
- *
112
109
  * @example
113
110
  * // Simple dictionary lookup without interpolation
114
111
  * const t = await getTranslations();
@@ -119,11 +116,78 @@ async function getTranslations() {
119
116
  * const t = await getTranslations();
120
117
  * const greeting = t('user.greeting', { name: 'Bob' });
121
118
  */
122
- const t = (_id, _options) => {
123
- throw new Error("t() is not implemented");
119
+ const t = ((id, options = {}) => {
120
+ const sourceEntry = i18nManager.lookupDictionary(sourceLocale, id);
121
+ if (sourceEntry === void 0) throw new Error(`Dictionary entry ${id} cannot be found`);
122
+ return renderEntry({
123
+ sourceLocale,
124
+ targetLocale: locale,
125
+ sourceEntry,
126
+ targetEntry: i18nManager.lookupDictionary(locale, id),
127
+ options
128
+ });
129
+ });
130
+ t.obj = (id) => {
131
+ const sourceObject = i18nManager.lookupDictionaryObj(sourceLocale, id);
132
+ if (sourceObject === void 0) throw new Error(`Dictionary entry ${id} cannot be found`);
133
+ return renderObject({
134
+ sourceObject,
135
+ targetObject: i18nManager.lookupDictionaryObj(locale, id)
136
+ });
124
137
  };
125
138
  return t;
126
139
  }
140
+ function renderEntry({ sourceLocale, targetLocale, sourceEntry, targetEntry, options = {} }) {
141
+ const dictionaryOptions = require_versionId.resolveDictionaryLookupOptions(sourceEntry.options);
142
+ const interpolationOptions = require_isEncodedTranslationOptions.extractVariables(options);
143
+ const lookupOptions = require_versionId.createLookupOptions(targetLocale, {
144
+ ...dictionaryOptions,
145
+ ...interpolationOptions
146
+ }, dictionaryOptions.$format ?? "ICU");
147
+ return require_versionId.interpolateMessage({
148
+ source: sourceEntry.entry,
149
+ target: targetEntry?.entry,
150
+ options: lookupOptions,
151
+ sourceLocale
152
+ });
153
+ }
154
+ function renderObject({ sourceObject, targetObject }) {
155
+ const targetEntry = require_versionId.getDictionaryEntry(targetObject);
156
+ if (targetEntry !== void 0) return targetEntry.entry;
157
+ if (require_versionId.isDictionaryValue(targetObject)) {
158
+ if (!require_versionId.isDictionaryValue(sourceObject)) return renderObject({
159
+ sourceObject: targetObject,
160
+ targetObject: void 0
161
+ });
162
+ return renderDictionaryObject({
163
+ sourceObject,
164
+ targetObject
165
+ });
166
+ }
167
+ const sourceEntry = require_versionId.getDictionaryEntry(sourceObject);
168
+ if (sourceEntry !== void 0) return sourceEntry.entry;
169
+ if (require_versionId.isDictionaryValue(sourceObject)) return renderDictionaryObject({
170
+ sourceObject,
171
+ targetObject: void 0
172
+ });
173
+ throw new Error("Dictionary object cannot be rendered");
174
+ }
175
+ function renderDictionaryObject({ sourceObject, targetObject }) {
176
+ if (!require_versionId.isDictionaryValue(sourceObject)) return renderObject({
177
+ sourceObject,
178
+ targetObject
179
+ });
180
+ const result = {};
181
+ const keys = new Set([...Object.keys(sourceObject), ...require_versionId.isDictionaryValue(targetObject) ? Object.keys(targetObject) : []]);
182
+ for (const key of keys) {
183
+ const renderedChild = renderObject({
184
+ sourceObject: sourceObject[key],
185
+ targetObject: require_versionId.isDictionaryValue(targetObject) ? targetObject[key] : void 0
186
+ });
187
+ if (renderedChild !== void 0) result[key] = renderedChild;
188
+ }
189
+ return result;
190
+ }
127
191
  //#endregion
128
192
  //#region src/translation-functions/internal/tx.ts
129
193
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"internal.cjs","names":["getI18nManager","getCurrentLocale","createLookupOptions","interpolateMessage","decodeOptions","isEncodedTranslationOptions","resolveStringContentWithRuntimeFallback","getCurrentLocale","resolveStringContent","resolveStringContentWithFallback","resolveJsx","setConditionStore","libraryDefaultLocale","LocaleConfig"],"sources":["../src/translation-functions/internal/getGT.ts","../src/translation-functions/internal/getMessages.ts","../src/translation-functions/internal/getTranslations.ts","../src/translation-functions/internal/tx.ts","../src/translation-functions/internal/sync-translation-resolution.ts","../src/translation-functions/internal/jsx-resolution.ts","../src/i18n-manager/condition-store/createConditionStoreSingleton.ts","../src/i18n-manager/condition-store/localeResolver.ts"],"sourcesContent":["import {\n getCurrentLocale,\n getI18nManager,\n} from '../../i18n-manager/singleton-operations';\nimport { InlineTranslationOptions } from '../types/options';\nimport { GTFunctionType } from '../types/functions';\nimport { interpolateMessage } from '../utils/interpolation/interpolateMessage';\nimport { createLookupOptions } from './helpers';\nimport type { StringFormat } from 'generaltranslation/types';\n\n/**\n * Returns the gt function that registers a string at build time and resolves its translation at runtime.\n * @returns A promise of the gt function\n *\n * @example\n * const gt = await getGT();\n * const greeting = gt('Hello, world!');\n */\nexport async function getGT(): Promise<GTFunctionType> {\n // Get the translation resolver\n const i18nManager = getI18nManager();\n const locale = getCurrentLocale();\n await i18nManager.loadTranslations(locale);\n const sourceLocale = i18nManager.getDefaultLocale();\n\n /**\n * Registers a message at build time and resolves its translation at runtime.\n * @param {string} message - The message to translate\n * @param {InlineTranslationOptions} options - The options for the translation\n * @returns The translated message\n *\n * @example\n * // Simple translation without interpolation\n * const gt = await getGT();\n * const greeting = gt('Hello, world!');\n *\n * @example\n * // Translation with interpolation\n * const gt = await getGT();\n * const welcome = gt('Hello, {name}!', { name: 'Alice' });\n */\n const gt: GTFunctionType = (\n message: string,\n options: InlineTranslationOptions = {}\n ) => {\n const targetLocale = options.$locale ?? locale;\n const lookupOptions = createLookupOptions<StringFormat>(\n targetLocale,\n options,\n 'ICU'\n );\n\n // Lookup translation\n const translation = i18nManager.lookupTranslation(\n lookupOptions.$locale,\n message,\n lookupOptions\n );\n\n // Format result\n return interpolateMessage({\n source: message,\n target: translation,\n options: lookupOptions,\n sourceLocale,\n });\n };\n\n return gt;\n}\n","import { InlineResolveOptions } from '../types/options';\nimport { decodeOptions } from '../msg/decodeOptions';\nimport { isEncodedTranslationOptions } from '../utils/isEncodedTranslationOptions';\nimport { getGT } from './getGT';\nimport { MFunctionType } from '../types/functions';\n\n/**\n * Returns the m function that resolves a registered message to its translation.\n * @returns A promise of the m function\n *\n * @example\n * // Registration\n * const registeredMessage = msg('Hello, world!');\n *\n * // Resolution\n * const m = await getMessages();\n * const greeting = m(registeredMessage);\n */\nexport async function getMessages(): Promise<MFunctionType> {\n // Get the gt function\n const gt = await getGT();\n\n /**\n * Resolves a registered message to its translation.\n * @param {string | null | undefined} encodedMsg - The encoded message to decode and interpolate.\n * @param {InlineTranslationOptions} options - The options to interpolate.\n * @returns - The decoded and interpolated message.\n *\n * @example\n * // Simple message without interpolation\n * const m = await getMessages();\n * const greeting = m(msg('Hello, world!'));\n *\n * @example\n * // Message with interpolation\n * const m = await getMessages();\n * const welcome = m(msg('Welcome, {user}!'), { user: 'Alice' });\n */\n const m: MFunctionType = <T extends string | null | undefined>(\n encodedMsg: T,\n options: InlineResolveOptions = {}\n ): T extends string ? string : T => {\n // Return if the encoded message is null or undefined\n if (encodedMsg == null) return encodedMsg as T extends string ? string : T;\n\n // Get any encoded options\n const decodedOptions = decodeOptions(encodedMsg) ?? {};\n\n // Return early if string already interpolated eg: mFallback(msg('Hello, {name}!', { name: 'Brian' }))\n if (isEncodedTranslationOptions(decodedOptions)) {\n return gt(decodedOptions.$_source, decodedOptions) as T extends string\n ? string\n : T;\n }\n\n // Use gt to interpolate\n // Separate from decoded options to match behavior in @gt/react-core\n return gt(encodedMsg, options) as T extends string ? string : T;\n };\n\n return m;\n}\n","import { DictionaryTranslationOptions } from '../types/options';\nimport { TFunctionType } from '../types/functions';\n\n/**\n * Returns the t function that translates a dictionary entry based on its id and options.\n * @returns A promise of the t function\n * @important Must be used inside of a request context\n *\n * @deprecated not yet supported\n *\n * @example\n * const t = await getTranslations();\n * const title = await t('page.title');\n */\nexport async function getTranslations(): Promise<TFunctionType> {\n /**\n * Dictionary resolution\n * @param {string} id - The id of the translation to translate.\n * @param {DictionaryTranslationOptions} options - The options for the translation.\n * @returns {string} The translated message.\n *\n * @deprecated not yet supported\n *\n * This is a placeholder for the t() function.\n * TODO: Implement the t() function.\n *\n * @example\n * // Simple dictionary lookup without interpolation\n * const t = await getTranslations();\n * const title = t('page.title');\n *\n * @example\n * // Dictionary lookup with interpolation\n * const t = await getTranslations();\n * const greeting = t('user.greeting', { name: 'Bob' });\n */\n const t: TFunctionType = (\n _id: string,\n _options?: DictionaryTranslationOptions\n ): string => {\n throw new Error('t() is not implemented');\n };\n\n return t;\n}\n","import { RuntimeTranslationOptions } from '../types/options';\nimport type { StringFormat } from 'generaltranslation/types';\nimport { resolveStringContentWithRuntimeFallback } from './helpers';\nimport { getCurrentLocale } from '../../i18n-manager/singleton-operations';\n\ntype RuntimeTranslationOptionsWithFormat = Omit<\n RuntimeTranslationOptions,\n '$format'\n> & {\n $format?: StringFormat;\n};\n\n/**\n * Translates a message at runtime.\n * @param {string} message - The message to translate.\n * @param {RuntimeTranslationOptions} options - The options for the translation.\n * @returns {Promise<string>} The translated message.\n *\n * @example\n * // Simple runtime translation without interpolation\n * const status = await tx('Processing complete', { $locale: 'es-MX' });\n *\n * @example\n * // Runtime translation with interpolation\n * const progress = await tx(`Processing ${status}`, { $locale: 'es-MX' });\n */\nexport async function tx(\n content: string,\n options: RuntimeTranslationOptionsWithFormat = {}\n): Promise<string> {\n const locale = options.$locale ?? getCurrentLocale();\n return resolveStringContentWithRuntimeFallback(locale, content, {\n $format: 'STRING',\n ...options,\n });\n}\n","import { InlineTranslationOptions } from '../types/options';\nimport {\n resolveStringContent,\n resolveStringContentWithFallback,\n} from './helpers';\n\n/**\n * Synchronously resolve a translation for a given message and options\n * @param {string} message - The message to translate.\n * @param {InlineTranslationOptions} [options] - The options for the translation.\n * @returns {string | undefined} The translated message or undefined if the message is not found.\n * @deprecated use resolveTranslation instead\n */\nexport function resolveTranslationSync(\n locale: string,\n message: string,\n options: InlineTranslationOptions = {}\n) {\n return resolveStringContent(locale, message, { $format: 'ICU', ...options });\n}\n\n/**\n * Translate a message\n * @param {string} message - The message to translate.\n * @param {InlineTranslationOptions} [options] - The options for the translation.\n * @returns {string} The translated message or the original message interpolated if the translation is not found.\n * @deprecated use resolveTranslationWithFallback instead\n */\nexport function resolveTranslationSyncWithFallback(\n locale: string,\n message: string,\n options: InlineTranslationOptions = {}\n) {\n return resolveStringContentWithFallback(locale, message, {\n $format: 'ICU',\n ...options,\n });\n}\n","import { JsxChildren } from 'generaltranslation/types';\nimport { JsxTranslationOptions } from '../types/options';\nimport { resolveJsx } from './helpers';\n\n/**\n * Given a JsxChildren and any associated metadata needed for a hash calculation, resolve the associated translation.\n * @deprecated use resolveJsx instead\n */\nexport function resolveJsxTranslation(\n locale: string,\n children: JsxChildren,\n options: JsxTranslationOptions = {}\n) {\n return resolveJsx(locale, children, options);\n}\n","import type { ConditionStore } from '../types';\nimport { setConditionStore as setCurrentConditionStore } from '../singleton-operations';\n\nexport function createConditionStoreSingleton<T extends ConditionStore>(\n notInitializedMessage: string\n) {\n let conditionStore: T | undefined;\n\n function getConditionStore(): T {\n if (!conditionStore) {\n throw new Error(notInitializedMessage);\n }\n return conditionStore;\n }\n\n function setConditionStore(nextConditionStore: T): void {\n conditionStore = nextConditionStore;\n setCurrentConditionStore(nextConditionStore);\n }\n\n return {\n getConditionStore,\n setConditionStore,\n };\n}\n","import { LocaleConfig } from 'generaltranslation/core';\nimport { libraryDefaultLocale } from 'generaltranslation/internal';\nimport type { ConditionStoreConfig } from '../types';\n\nexport type LocaleCandidates = string | string[] | undefined;\n\nfunction normalizeConditionStoreConfig({\n defaultLocale,\n locales,\n customMapping,\n}: ConditionStoreConfig = {}) {\n const fallbackLocale = defaultLocale || libraryDefaultLocale;\n return {\n defaultLocale: fallbackLocale,\n locales: locales?.length ? locales : [fallbackLocale],\n customMapping,\n };\n}\n\ntype NormalizedConditionStoreConfig = ReturnType<\n typeof normalizeConditionStoreConfig\n>;\n\n/**\n * Return the best supported locale for the candidates, or undefined when none match.\n */\nexport function determineSupportedLocale(\n candidates: LocaleCandidates,\n config: ConditionStoreConfig = {}\n): string | undefined {\n return determineSupportedLocaleWithConfig(\n candidates,\n normalizeConditionStoreConfig(config)\n );\n}\n\nfunction determineSupportedLocaleWithConfig(\n candidates: LocaleCandidates,\n config: NormalizedConditionStoreConfig\n): string | undefined {\n if (\n candidates == null ||\n (Array.isArray(candidates) && candidates.length === 0)\n ) {\n return undefined;\n }\n\n const localeConfig = new LocaleConfig(config);\n return localeConfig.determineLocale(candidates) || undefined;\n}\n\n/**\n * Return the best supported locale for the candidates, falling back to the default locale.\n */\nexport function resolveSupportedLocale(\n candidates: LocaleCandidates,\n config: ConditionStoreConfig = {}\n): string {\n const normalizedConfig = normalizeConditionStoreConfig(config);\n return (\n determineSupportedLocaleWithConfig(candidates, normalizedConfig) ||\n normalizedConfig.defaultLocale\n );\n}\n\nexport function createLocaleResolver(config: ConditionStoreConfig = {}) {\n const normalizedConfig = normalizeConditionStoreConfig(config);\n return (candidates?: LocaleCandidates): string =>\n determineSupportedLocaleWithConfig(candidates, normalizedConfig) ||\n normalizedConfig.defaultLocale;\n}\n"],"mappings":";;;;;;;;;;;;;;AAkBA,eAAsB,QAAiC;CAErD,MAAM,cAAcA,kBAAAA,gBAAgB;CACpC,MAAM,SAASC,kBAAAA,kBAAkB;AACjC,OAAM,YAAY,iBAAiB,OAAO;CAC1C,MAAM,eAAe,YAAY,kBAAkB;;;;;;;;;;;;;;;;;CAkBnD,MAAM,MACJ,SACA,UAAoC,EAAE,KACnC;EAEH,MAAM,gBAAgBC,kBAAAA,oBADD,QAAQ,WAAW,QAGtC,SACA,MACD;AAUD,SAAOC,kBAAAA,mBAAmB;GACxB,QAAQ;GACR,QATkB,YAAY,kBAC9B,cAAc,SACd,SACA,cAMmB;GACnB,SAAS;GACT;GACD,CAAC;;AAGJ,QAAO;;;;;;;;;;;;;;;;AClDT,eAAsB,cAAsC;CAE1D,MAAM,KAAK,MAAM,OAAO;;;;;;;;;;;;;;;;;CAkBxB,MAAM,KACJ,YACA,UAAgC,EAAE,KACA;AAElC,MAAI,cAAc,KAAM,QAAO;EAG/B,MAAM,iBAAiBC,oCAAAA,cAAc,WAAW,IAAI,EAAE;AAGtD,MAAIC,oCAAAA,4BAA4B,eAAe,CAC7C,QAAO,GAAG,eAAe,UAAU,eAAe;AAOpD,SAAO,GAAG,YAAY,QAAQ;;AAGhC,QAAO;;;;;;;;;;;;;;;AC9CT,eAAsB,kBAA0C;;;;;;;;;;;;;;;;;;;;;;CAsB9D,MAAM,KACJ,KACA,aACW;AACX,QAAM,IAAI,MAAM,yBAAyB;;AAG3C,QAAO;;;;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,SAAgB,uBACd,YACA,SAA+B,EAAE,EACzB;CACR,MAAM,mBAAmB,8BAA8B,OAAO;AAC9D,QACE,mCAAmC,YAAY,iBAAiB,IAChE,iBAAiB;;AAIrB,SAAgB,qBAAqB,SAA+B,EAAE,EAAE;CACtE,MAAM,mBAAmB,8BAA8B,OAAO;AAC9D,SAAQ,eACN,mCAAmC,YAAY,iBAAiB,IAChE,iBAAiB"}
1
+ {"version":3,"file":"internal.cjs","names":["getI18nManager","getCurrentLocale","createLookupOptions","interpolateMessage","decodeOptions","isEncodedTranslationOptions","getI18nManager","getCurrentLocale","resolveDictionaryLookupOptions","extractVariables","createLookupOptions","interpolateMessage","getDictionaryEntry","isDictionaryValue","resolveStringContentWithRuntimeFallback","getCurrentLocale","resolveStringContent","resolveStringContentWithFallback","resolveJsx","setConditionStore","libraryDefaultLocale","LocaleConfig"],"sources":["../src/translation-functions/internal/getGT.ts","../src/translation-functions/internal/getMessages.ts","../src/translation-functions/internal/getTranslations.ts","../src/translation-functions/internal/tx.ts","../src/translation-functions/internal/sync-translation-resolution.ts","../src/translation-functions/internal/jsx-resolution.ts","../src/i18n-manager/condition-store/createConditionStoreSingleton.ts","../src/i18n-manager/condition-store/localeResolver.ts"],"sourcesContent":["import {\n getCurrentLocale,\n getI18nManager,\n} from '../../i18n-manager/singleton-operations';\nimport { InlineTranslationOptions } from '../types/options';\nimport { GTFunctionType } from '../types/functions';\nimport { interpolateMessage } from '../utils/interpolation/interpolateMessage';\nimport { createLookupOptions } from './helpers';\nimport type { StringFormat } from 'generaltranslation/types';\n\n/**\n * Returns the gt function that registers a string at build time and resolves its translation at runtime.\n * @returns A promise of the gt function\n *\n * @example\n * const gt = await getGT();\n * const greeting = gt('Hello, world!');\n */\nexport async function getGT(): Promise<GTFunctionType> {\n // Get the translation resolver\n const i18nManager = getI18nManager();\n const locale = getCurrentLocale();\n await i18nManager.loadTranslations(locale);\n const sourceLocale = i18nManager.getDefaultLocale();\n\n /**\n * Registers a message at build time and resolves its translation at runtime.\n * @param {string} message - The message to translate\n * @param {InlineTranslationOptions} options - The options for the translation\n * @returns The translated message\n *\n * @example\n * // Simple translation without interpolation\n * const gt = await getGT();\n * const greeting = gt('Hello, world!');\n *\n * @example\n * // Translation with interpolation\n * const gt = await getGT();\n * const welcome = gt('Hello, {name}!', { name: 'Alice' });\n */\n const gt: GTFunctionType = (\n message: string,\n options: InlineTranslationOptions = {}\n ) => {\n const targetLocale = options.$locale ?? locale;\n const lookupOptions = createLookupOptions<StringFormat>(\n targetLocale,\n options,\n 'ICU'\n );\n\n // Lookup translation\n const translation = i18nManager.lookupTranslation(\n lookupOptions.$locale,\n message,\n lookupOptions\n );\n\n // Format result\n return interpolateMessage({\n source: message,\n target: translation,\n options: lookupOptions,\n sourceLocale,\n });\n };\n\n return gt;\n}\n","import { InlineResolveOptions } from '../types/options';\nimport { decodeOptions } from '../msg/decodeOptions';\nimport { isEncodedTranslationOptions } from '../utils/isEncodedTranslationOptions';\nimport { getGT } from './getGT';\nimport { MFunctionType } from '../types/functions';\n\n/**\n * Returns the m function that resolves a registered message to its translation.\n * @returns A promise of the m function\n *\n * @example\n * // Registration\n * const registeredMessage = msg('Hello, world!');\n *\n * // Resolution\n * const m = await getMessages();\n * const greeting = m(registeredMessage);\n */\nexport async function getMessages(): Promise<MFunctionType> {\n // Get the gt function\n const gt = await getGT();\n\n /**\n * Resolves a registered message to its translation.\n * @param {string | null | undefined} encodedMsg - The encoded message to decode and interpolate.\n * @param {InlineTranslationOptions} options - The options to interpolate.\n * @returns - The decoded and interpolated message.\n *\n * @example\n * // Simple message without interpolation\n * const m = await getMessages();\n * const greeting = m(msg('Hello, world!'));\n *\n * @example\n * // Message with interpolation\n * const m = await getMessages();\n * const welcome = m(msg('Welcome, {user}!'), { user: 'Alice' });\n */\n const m: MFunctionType = <T extends string | null | undefined>(\n encodedMsg: T,\n options: InlineResolveOptions = {}\n ): T extends string ? string : T => {\n // Return if the encoded message is null or undefined\n if (encodedMsg == null) return encodedMsg as T extends string ? string : T;\n\n // Get any encoded options\n const decodedOptions = decodeOptions(encodedMsg) ?? {};\n\n // Return early if string already interpolated eg: mFallback(msg('Hello, {name}!', { name: 'Brian' }))\n if (isEncodedTranslationOptions(decodedOptions)) {\n return gt(decodedOptions.$_source, decodedOptions) as T extends string\n ? string\n : T;\n }\n\n // Use gt to interpolate\n // Separate from decoded options to match behavior in @gt/react-core\n return gt(encodedMsg, options) as T extends string ? string : T;\n };\n\n return m;\n}\n","import {\n getCurrentLocale,\n getI18nManager,\n} from '../../i18n-manager/singleton-operations';\nimport { DictionaryTranslationOptions } from '../types/options';\nimport { TFunctionType } from '../types/functions';\nimport { interpolateMessage } from '../utils/interpolation/interpolateMessage';\nimport { createLookupOptions } from './helpers';\nimport { extractVariables } from '../../utils/extractVariables';\nimport type { StringFormat } from 'generaltranslation/types';\nimport type {\n DictionaryEntry,\n DictionaryValue,\n} from '../../i18n-manager/translations-manager/DictionaryCache';\nimport {\n getDictionaryEntry,\n isDictionaryValue,\n resolveDictionaryLookupOptions,\n} from '../../i18n-manager/translations-manager/utils/dictionary-helpers';\nimport type { DictionaryObjectTranslation } from '../types/functions';\n\n/**\n * Returns the t function that translates a dictionary entry based on its id and options.\n * @returns A promise of the t function\n * @important Must be used inside of a request context\n *\n * @example\n * const t = await getTranslations();\n * const title = await t('page.title');\n */\nexport async function getTranslations(): Promise<TFunctionType> {\n const i18nManager = getI18nManager();\n const locale = getCurrentLocale();\n await i18nManager.loadDictionary(locale);\n const sourceLocale = i18nManager.getDefaultLocale();\n\n /**\n * Dictionary resolution\n * @param {string} id - The id of the translation to translate.\n * @param {DictionaryTranslationOptions} options - The options for interpolation.\n * @returns {string} The translated message.\n *\n * @example\n * // Simple dictionary lookup without interpolation\n * const t = await getTranslations();\n * const title = t('page.title');\n *\n * @example\n * // Dictionary lookup with interpolation\n * const t = await getTranslations();\n * const greeting = t('user.greeting', { name: 'Bob' });\n */\n const t = ((\n id: string,\n options: DictionaryTranslationOptions = {}\n ): string => {\n const sourceEntry = i18nManager.lookupDictionary(sourceLocale, id);\n if (sourceEntry === undefined) {\n throw new Error(`Dictionary entry ${id} cannot be found`);\n }\n const targetEntry = i18nManager.lookupDictionary(locale, id);\n return renderEntry({\n sourceLocale,\n targetLocale: locale,\n sourceEntry,\n targetEntry,\n options,\n });\n }) as TFunctionType;\n\n t.obj = (id: string): DictionaryObjectTranslation => {\n const sourceObject = i18nManager.lookupDictionaryObj(sourceLocale, id);\n if (sourceObject === undefined) {\n throw new Error(`Dictionary entry ${id} cannot be found`);\n }\n const targetObject = i18nManager.lookupDictionaryObj(locale, id);\n return renderObject({ sourceObject, targetObject });\n };\n\n return t;\n}\n\nfunction renderEntry({\n sourceLocale,\n targetLocale,\n sourceEntry,\n targetEntry,\n options = {},\n}: {\n sourceLocale: string;\n targetLocale: string;\n sourceEntry: DictionaryEntry;\n targetEntry: DictionaryEntry | undefined;\n options?: DictionaryTranslationOptions;\n}): string {\n const dictionaryOptions = resolveDictionaryLookupOptions(sourceEntry.options);\n const interpolationOptions = extractVariables(options);\n const lookupOptions = createLookupOptions<StringFormat>(\n targetLocale,\n {\n ...dictionaryOptions,\n ...interpolationOptions,\n },\n dictionaryOptions.$format ?? 'ICU'\n );\n\n return interpolateMessage({\n source: sourceEntry.entry,\n target: targetEntry?.entry,\n options: lookupOptions,\n sourceLocale,\n });\n}\n\nfunction renderObject({\n sourceObject,\n targetObject,\n}: {\n sourceObject: DictionaryValue | undefined;\n targetObject: DictionaryValue | undefined;\n}): DictionaryObjectTranslation {\n const targetEntry = getDictionaryEntry(targetObject);\n if (targetEntry !== undefined) {\n return targetEntry.entry;\n }\n\n if (isDictionaryValue(targetObject)) {\n if (!isDictionaryValue(sourceObject)) {\n return renderObject({\n sourceObject: targetObject,\n targetObject: undefined,\n });\n }\n\n return renderDictionaryObject({\n sourceObject,\n targetObject,\n });\n }\n\n const sourceEntry = getDictionaryEntry(sourceObject);\n if (sourceEntry !== undefined) {\n return sourceEntry.entry;\n }\n\n if (isDictionaryValue(sourceObject)) {\n return renderDictionaryObject({\n sourceObject,\n targetObject: undefined,\n });\n }\n\n throw new Error('Dictionary object cannot be rendered');\n}\n\nfunction renderDictionaryObject({\n sourceObject,\n targetObject,\n}: {\n sourceObject: DictionaryValue;\n targetObject: DictionaryValue | undefined;\n}): DictionaryObjectTranslation {\n if (!isDictionaryValue(sourceObject)) {\n return renderObject({ sourceObject, targetObject });\n }\n const result: Record<string, DictionaryObjectTranslation> = {};\n const keys = new Set([\n ...Object.keys(sourceObject),\n ...(isDictionaryValue(targetObject) ? Object.keys(targetObject) : []),\n ]);\n\n for (const key of keys) {\n const renderedChild = renderObject({\n sourceObject: sourceObject[key],\n targetObject: isDictionaryValue(targetObject)\n ? targetObject[key]\n : undefined,\n });\n if (renderedChild !== undefined) {\n result[key] = renderedChild;\n }\n }\n\n return result;\n}\n","import { RuntimeTranslationOptions } from '../types/options';\nimport type { StringFormat } from 'generaltranslation/types';\nimport { resolveStringContentWithRuntimeFallback } from './helpers';\nimport { getCurrentLocale } from '../../i18n-manager/singleton-operations';\n\ntype RuntimeTranslationOptionsWithFormat = Omit<\n RuntimeTranslationOptions,\n '$format'\n> & {\n $format?: StringFormat;\n};\n\n/**\n * Translates a message at runtime.\n * @param {string} message - The message to translate.\n * @param {RuntimeTranslationOptions} options - The options for the translation.\n * @returns {Promise<string>} The translated message.\n *\n * @example\n * // Simple runtime translation without interpolation\n * const status = await tx('Processing complete', { $locale: 'es-MX' });\n *\n * @example\n * // Runtime translation with interpolation\n * const progress = await tx(`Processing ${status}`, { $locale: 'es-MX' });\n */\nexport async function tx(\n content: string,\n options: RuntimeTranslationOptionsWithFormat = {}\n): Promise<string> {\n const locale = options.$locale ?? getCurrentLocale();\n return resolveStringContentWithRuntimeFallback(locale, content, {\n $format: 'STRING',\n ...options,\n });\n}\n","import { InlineTranslationOptions } from '../types/options';\nimport {\n resolveStringContent,\n resolveStringContentWithFallback,\n} from './helpers';\n\n/**\n * Synchronously resolve a translation for a given message and options\n * @param {string} message - The message to translate.\n * @param {InlineTranslationOptions} [options] - The options for the translation.\n * @returns {string | undefined} The translated message or undefined if the message is not found.\n * @deprecated use resolveTranslation instead\n */\nexport function resolveTranslationSync(\n locale: string,\n message: string,\n options: InlineTranslationOptions = {}\n) {\n return resolveStringContent(locale, message, { $format: 'ICU', ...options });\n}\n\n/**\n * Translate a message\n * @param {string} message - The message to translate.\n * @param {InlineTranslationOptions} [options] - The options for the translation.\n * @returns {string} The translated message or the original message interpolated if the translation is not found.\n * @deprecated use resolveTranslationWithFallback instead\n */\nexport function resolveTranslationSyncWithFallback(\n locale: string,\n message: string,\n options: InlineTranslationOptions = {}\n) {\n return resolveStringContentWithFallback(locale, message, {\n $format: 'ICU',\n ...options,\n });\n}\n","import { JsxChildren } from 'generaltranslation/types';\nimport { JsxTranslationOptions } from '../types/options';\nimport { resolveJsx } from './helpers';\n\n/**\n * Given a JsxChildren and any associated metadata needed for a hash calculation, resolve the associated translation.\n * @deprecated use resolveJsx instead\n */\nexport function resolveJsxTranslation(\n locale: string,\n children: JsxChildren,\n options: JsxTranslationOptions = {}\n) {\n return resolveJsx(locale, children, options);\n}\n","import type { ConditionStore } from '../types';\nimport { setConditionStore as setCurrentConditionStore } from '../singleton-operations';\n\nexport function createConditionStoreSingleton<T extends ConditionStore>(\n notInitializedMessage: string\n) {\n let conditionStore: T | undefined;\n\n function getConditionStore(): T {\n if (!conditionStore) {\n throw new Error(notInitializedMessage);\n }\n return conditionStore;\n }\n\n function setConditionStore(nextConditionStore: T): void {\n conditionStore = nextConditionStore;\n setCurrentConditionStore(nextConditionStore);\n }\n\n return {\n getConditionStore,\n setConditionStore,\n };\n}\n","import { LocaleConfig } from 'generaltranslation/core';\nimport { libraryDefaultLocale } from 'generaltranslation/internal';\nimport type { ConditionStoreConfig } from '../types';\n\nexport type LocaleCandidates = string | string[] | undefined;\n\nfunction normalizeConditionStoreConfig({\n defaultLocale,\n locales,\n customMapping,\n}: ConditionStoreConfig = {}) {\n const fallbackLocale = defaultLocale || libraryDefaultLocale;\n return {\n defaultLocale: fallbackLocale,\n locales: locales?.length ? locales : [fallbackLocale],\n customMapping,\n };\n}\n\ntype NormalizedConditionStoreConfig = ReturnType<\n typeof normalizeConditionStoreConfig\n>;\n\n/**\n * Return the best supported locale for the candidates, or undefined when none match.\n */\nexport function determineSupportedLocale(\n candidates: LocaleCandidates,\n config: ConditionStoreConfig = {}\n): string | undefined {\n return determineSupportedLocaleWithConfig(\n candidates,\n normalizeConditionStoreConfig(config)\n );\n}\n\nfunction determineSupportedLocaleWithConfig(\n candidates: LocaleCandidates,\n config: NormalizedConditionStoreConfig\n): string | undefined {\n if (\n candidates == null ||\n (Array.isArray(candidates) && candidates.length === 0)\n ) {\n return undefined;\n }\n\n const localeConfig = new LocaleConfig(config);\n return localeConfig.determineLocale(candidates) || undefined;\n}\n\n/**\n * Return the best supported locale for the candidates, falling back to the default locale.\n */\nexport function resolveSupportedLocale(\n candidates: LocaleCandidates,\n config: ConditionStoreConfig = {}\n): string {\n const normalizedConfig = normalizeConditionStoreConfig(config);\n return (\n determineSupportedLocaleWithConfig(candidates, normalizedConfig) ||\n normalizedConfig.defaultLocale\n );\n}\n\nexport function createLocaleResolver(config: ConditionStoreConfig = {}) {\n const normalizedConfig = normalizeConditionStoreConfig(config);\n return (candidates?: LocaleCandidates): string =>\n determineSupportedLocaleWithConfig(candidates, normalizedConfig) ||\n normalizedConfig.defaultLocale;\n}\n"],"mappings":";;;;;;;;;;;;;;AAkBA,eAAsB,QAAiC;CAErD,MAAM,cAAcA,kBAAAA,gBAAgB;CACpC,MAAM,SAASC,kBAAAA,kBAAkB;AACjC,OAAM,YAAY,iBAAiB,OAAO;CAC1C,MAAM,eAAe,YAAY,kBAAkB;;;;;;;;;;;;;;;;;CAkBnD,MAAM,MACJ,SACA,UAAoC,EAAE,KACnC;EAEH,MAAM,gBAAgBC,kBAAAA,oBADD,QAAQ,WAAW,QAGtC,SACA,MACD;AAUD,SAAOC,k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