@generaltranslation/react-core 12.0.0-samsara.10 → 12.0.0-samsara.11

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 (144) hide show
  1. package/CHANGELOG.md +116 -0
  2. package/dist/compat/useTranslations.cjs +1 -1
  3. package/dist/compat/useTranslations.cjs.map +1 -1
  4. package/dist/compat/useTranslations.mjs +1 -1
  5. package/dist/compat/useTranslations.mjs.map +1 -1
  6. package/dist/components/branches/Plural.shared.cjs +1 -1
  7. package/dist/components/branches/Plural.shared.cjs.map +1 -1
  8. package/dist/components/branches/Plural.shared.d.ts.map +1 -1
  9. package/dist/components/branches/Plural.shared.mjs +1 -1
  10. package/dist/components/branches/Plural.shared.mjs.map +1 -1
  11. package/dist/components/variables/N.cjs +2 -0
  12. package/dist/components/variables/N.cjs.map +1 -0
  13. package/dist/components/variables/N.d.ts +16 -0
  14. package/dist/components/variables/N.d.ts.map +1 -0
  15. package/dist/components/variables/N.mjs +2 -0
  16. package/dist/components/variables/N.mjs.map +1 -0
  17. package/dist/components/variables/N.rsc.cjs +2 -0
  18. package/dist/components/variables/N.rsc.cjs.map +1 -0
  19. package/dist/components/variables/N.rsc.d.ts +13 -0
  20. package/dist/components/variables/N.rsc.d.ts.map +1 -0
  21. package/dist/components/variables/N.rsc.mjs +2 -0
  22. package/dist/components/variables/N.rsc.mjs.map +1 -0
  23. package/dist/components/variables/N.shared.d.ts +11 -0
  24. package/dist/components/variables/N.shared.d.ts.map +1 -0
  25. package/dist/components-rsc.cjs +1 -1
  26. package/dist/components-rsc.d.ts +3 -1
  27. package/dist/components-rsc.mjs +1 -1
  28. package/dist/components.cjs +1 -1
  29. package/dist/components.d.ts +2 -1
  30. package/dist/components.mjs +1 -1
  31. package/dist/functions/helpers/getTranslationsSnapshot.cjs +1 -1
  32. package/dist/functions/helpers/getTranslationsSnapshot.cjs.map +1 -1
  33. package/dist/functions/helpers/getTranslationsSnapshot.d.ts +7 -1
  34. package/dist/functions/helpers/getTranslationsSnapshot.d.ts.map +1 -1
  35. package/dist/functions/helpers/getTranslationsSnapshot.mjs +1 -1
  36. package/dist/functions/helpers/getTranslationsSnapshot.mjs.map +1 -1
  37. package/dist/functions/translation/m.cjs +2 -0
  38. package/dist/functions/translation/m.cjs.map +1 -0
  39. package/dist/{unstable → functions/translation}/m.d.ts +2 -2
  40. package/dist/functions/translation/m.d.ts.map +1 -0
  41. package/dist/functions/translation/m.mjs +2 -0
  42. package/dist/functions/translation/m.mjs.map +1 -0
  43. package/dist/functions/translation/spaOnly.cjs +2 -0
  44. package/dist/functions/translation/spaOnly.cjs.map +1 -0
  45. package/dist/functions/translation/spaOnly.mjs +2 -0
  46. package/dist/functions/translation/spaOnly.mjs.map +1 -0
  47. package/dist/functions/translation/t.cjs +1 -1
  48. package/dist/functions/translation/t.cjs.map +1 -1
  49. package/dist/functions/translation/t.d.ts +7 -30
  50. package/dist/functions/translation/t.d.ts.map +1 -1
  51. package/dist/functions/translation/t.mjs +1 -1
  52. package/dist/functions/translation/t.mjs.map +1 -1
  53. package/dist/hooks/external-store/useTrackedTranslationResolver.cjs +1 -1
  54. package/dist/hooks/external-store/useTrackedTranslationResolver.cjs.map +1 -1
  55. package/dist/hooks/external-store/useTrackedTranslationResolver.mjs +1 -1
  56. package/dist/hooks/external-store/useTrackedTranslationResolver.mjs.map +1 -1
  57. package/dist/hooks/useGT.cjs +1 -1
  58. package/dist/hooks/useGT.cjs.map +1 -1
  59. package/dist/hooks/useGT.d.ts +12 -2
  60. package/dist/hooks/useGT.d.ts.map +1 -1
  61. package/dist/hooks/useGT.mjs +1 -1
  62. package/dist/hooks/useGT.mjs.map +1 -1
  63. package/dist/hooks/useMessages.cjs +1 -1
  64. package/dist/hooks/useMessages.cjs.map +1 -1
  65. package/dist/hooks/useMessages.d.ts +11 -2
  66. package/dist/hooks/useMessages.d.ts.map +1 -1
  67. package/dist/hooks/useMessages.mjs +1 -1
  68. package/dist/hooks/useMessages.mjs.map +1 -1
  69. package/dist/hooks/utils/missing-translation.cjs +1 -1
  70. package/dist/hooks/utils/missing-translation.mjs +1 -1
  71. package/dist/pure.cjs +1 -1
  72. package/dist/pure.d.ts +3 -2
  73. package/dist/pure.mjs +1 -1
  74. package/dist/utils/internal/addGTIdentifier.cjs +1 -1
  75. package/dist/utils/internal/addGTIdentifier.cjs.map +1 -1
  76. package/dist/utils/internal/addGTIdentifier.mjs +1 -1
  77. package/dist/utils/internal/addGTIdentifier.mjs.map +1 -1
  78. package/dist/utils/internal/removeInjectedT.cjs +1 -1
  79. package/dist/utils/internal/removeInjectedT.mjs +1 -1
  80. package/dist/utils/plurals/fillCount.cjs +2 -0
  81. package/dist/utils/plurals/fillCount.cjs.map +1 -0
  82. package/dist/utils/plurals/fillCount.mjs +2 -0
  83. package/dist/utils/plurals/fillCount.mjs.map +1 -0
  84. package/dist/utils/plurals/getPluralBranch.cjs +1 -1
  85. package/dist/utils/plurals/getPluralBranch.cjs.map +1 -1
  86. package/dist/utils/plurals/getPluralBranch.mjs +1 -1
  87. package/dist/utils/plurals/getPluralBranch.mjs.map +1 -1
  88. package/dist/utils/rendering/createRenderVariable.cjs +1 -1
  89. package/dist/utils/rendering/createRenderVariable.cjs.map +1 -1
  90. package/dist/utils/rendering/createRenderVariable.d.ts.map +1 -1
  91. package/dist/utils/rendering/createRenderVariable.mjs +1 -1
  92. package/dist/utils/rendering/createRenderVariable.mjs.map +1 -1
  93. package/dist/utils/rendering/renderTranslatedChildren.shared.cjs +1 -1
  94. package/dist/utils/rendering/renderTranslatedChildren.shared.cjs.map +1 -1
  95. package/dist/utils/rendering/renderTranslatedChildren.shared.d.ts +2 -1
  96. package/dist/utils/rendering/renderTranslatedChildren.shared.d.ts.map +1 -1
  97. package/dist/utils/rendering/renderTranslatedChildren.shared.mjs +1 -1
  98. package/dist/utils/rendering/renderTranslatedChildren.shared.mjs.map +1 -1
  99. package/dist/utils/translation/prepareT.shared.cjs +1 -1
  100. package/dist/utils/translation/prepareT.shared.cjs.map +1 -1
  101. package/dist/utils/translation/prepareT.shared.d.ts +4 -2
  102. package/dist/utils/translation/prepareT.shared.d.ts.map +1 -1
  103. package/dist/utils/translation/prepareT.shared.mjs +1 -1
  104. package/dist/utils/translation/prepareT.shared.mjs.map +1 -1
  105. package/dist/utils/translation/usePrepareT.cjs +1 -1
  106. package/dist/utils/translation/usePrepareT.cjs.map +1 -1
  107. package/dist/utils/translation/usePrepareT.mjs +1 -1
  108. package/dist/utils/translation/usePrepareT.mjs.map +1 -1
  109. package/dist/utils/variables/_getVariableProps.cjs +1 -1
  110. package/dist/utils/variables/_getVariableProps.cjs.map +1 -1
  111. package/dist/utils/variables/_getVariableProps.mjs +1 -1
  112. package/dist/utils/variables/_getVariableProps.mjs.map +1 -1
  113. package/package.json +4 -14
  114. package/dist/unstable/m.cjs +0 -2
  115. package/dist/unstable/m.cjs.map +0 -1
  116. package/dist/unstable/m.d.ts.map +0 -1
  117. package/dist/unstable/m.mjs +0 -2
  118. package/dist/unstable/m.mjs.map +0 -1
  119. package/dist/unstable/spaOnly.cjs +0 -2
  120. package/dist/unstable/spaOnly.cjs.map +0 -1
  121. package/dist/unstable/spaOnly.mjs +0 -2
  122. package/dist/unstable/spaOnly.mjs.map +0 -1
  123. package/dist/unstable/t.cjs +0 -2
  124. package/dist/unstable/t.cjs.map +0 -1
  125. package/dist/unstable/t.d.ts +0 -16
  126. package/dist/unstable/t.d.ts.map +0 -1
  127. package/dist/unstable/t.mjs +0 -2
  128. package/dist/unstable/t.mjs.map +0 -1
  129. package/dist/unstable/useGT.cjs +0 -2
  130. package/dist/unstable/useGT.cjs.map +0 -1
  131. package/dist/unstable/useGT.d.ts +0 -17
  132. package/dist/unstable/useGT.d.ts.map +0 -1
  133. package/dist/unstable/useGT.mjs +0 -2
  134. package/dist/unstable/useGT.mjs.map +0 -1
  135. package/dist/unstable/useMessages.cjs +0 -2
  136. package/dist/unstable/useMessages.cjs.map +0 -1
  137. package/dist/unstable/useMessages.d.ts +0 -16
  138. package/dist/unstable/useMessages.d.ts.map +0 -1
  139. package/dist/unstable/useMessages.mjs +0 -2
  140. package/dist/unstable/useMessages.mjs.map +0 -1
  141. package/dist/unstable.cjs +0 -1
  142. package/dist/unstable.d.mts +0 -1
  143. package/dist/unstable.d.ts +0 -5
  144. package/dist/unstable.mjs +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,114 @@
1
1
  # @generaltranslation/react-core
2
2
 
3
+ ## 12.0.0-samsara.11
4
+
5
+ ### Major Changes
6
+
7
+ - c8e2b0b: **Breaking:** the tagged-template API is now the message API of the main entries, and the string functions it replaces are removed. `t`, `msg`, `tx`, and the functions that `useGT()`, `getGT()`, `useMessages()` and `getMessages()` return no longer take an ICU string. `<T>` and the other components, the dictionary API under `/compat`, gt-svelte and gt-vue are unchanged.
8
+
9
+ ```diff
10
+ const t = useGT(); // or await getGT(), or the t that gt-react exports
11
+ - t('Hello, {name}!', { name });
12
+ + t`Hello, ${{ name }}!`;
13
+ - t('Save', { $context: 'button', $maxChars: 10 });
14
+ + t({ context: 'button', maxChars: 10 })`Save`;
15
+ - t('{count, plural, one {# item} other {# items}}', { count });
16
+ + t`${plural({ count }, { one: part`${n} item`, other: part`${n} items` })}`;
17
+
18
+ - const greeting = msg('Hello, {name}!', { name });
19
+ + const greeting = msg`Hello, ${{ name }}!`;
20
+ m(greeting); // m from useMessages() or getMessages()
21
+
22
+ - await tx('Hello, {name}!', { name, $context: 'greeting' });
23
+ + await tx({ context: 'greeting' })`Hello, ${{ name }}!`;
24
+ - await tx(userText);
25
+ + await tx`${dyn(userText)}`;
26
+ ```
27
+
28
+ A tagged template is stored as a message tree, not as an ICU string, and its hash is not the hash of the string it replaces, so every migrated message is translated again. That includes `msg('Save')`, which reads the same as before. Run `gt translate` after migrating.
29
+
30
+ **The functions that keep their name**, on `gt-i18n`, `gt-react`, `gt-react-native`, `gt-next`, `gt-next/server`, `gt-tanstack-start` and `gt-node`, wherever each was exported:
31
+ - `t` and the function from `useGT()` or `getGT()`: `t('Hello, {name}!', { name })` → `` t`Hello, ${{ name }}!` ``. Template text is literal, so `{`, `#` and `'` need no escaping.
32
+ - Options: `$context`, `$maxChars` and `$requiresReview` → `t({ context, maxChars, requiresReview })` before the template. `$id`, `$format`, `$locale` and `$_hash` have no replacement.
33
+ - ICU `plural`, `selectordinal` and `select` arguments → `plural()`, `selectordinal()` and `select()`, with `` part`...` `` for a branch that holds values and `n` for the count. ICU number, date and time arguments → `number()`, `date()` and `time()`. The main entries now export these helpers.
34
+ - `useGT(messages)`, `useMessages(messages)` and `getGT(messages)` → `useGT()`, `useMessages()` and `getGT()`: they take no argument.
35
+ - `msg('Hello, {name}!', { name })` → `` msg`Hello, ${{ name }}!` ``, and `msg('Save', { $context: 'button' })` → `` msg({ context: 'button' })`Save` ``. `msg('Save')` still works. `msg(['Save', 'Cancel'])` → one `msg()` call for each message.
36
+ - `m(message, options)` from `useMessages()` or `getMessages()`, and `mFallback(message, options)` → `m(message, values)` and `mFallback(message, values)`: the second argument holds values only, and a string is rendered as literal text.
37
+ - `tx('Hello', { $context })` from `gt-next/server` or `gt-node` → `` await tx({ context })`Hello` ``. `tx(text)` for text known only at runtime → `` tx`${dyn(text)}` ``, with `dyn` from the same entry. `tx` has no `$locale` option: it translates into the request locale in gt-next, and into the `withGT()` locale in gt-node.
38
+ - `derive` is the tagged-template helper, as in `` t`Welcome ${derive(status)}!` ``: its argument is typed as a string literal or a union of them, and it returns a placeholder, not its argument. It is the only `derive`: `generaltranslation` no longer exports one.
39
+ - `<T context={derive(getFormality())}>` works with it: `<T>` and `<Tx>` read the placeholder as their context, and the CLI extracts one entry for each value, which it finds by following the argument through the code (a call to a function that returns string literals, a `const`, or a conditional of them). TypeScript also checks the argument against `derive`'s type, so a function annotated `: string` needs a narrower return type.
40
+ - `derive()` must be the whole context. `<T context={'tone: ' + derive(getFormality())}>`, a template literal around `derive()`, and `derive()` in one branch of a conditional → `<T context={derive(getTone())}>`, with `getTone()` returning the full text, as in ``return `tone: ${getFormality()}` as const``. The CLI and the compiler report the old forms as errors.
41
+ - `t` and the new `m` from `gt-react` are still exported only under the `browser` condition, for client-rendered (SPA) apps. `gt-next`, `gt-tanstack-start`, `gt-react-native` and `gt-node` export neither.
42
+
43
+ **Removed and moved exports:**
44
+ - `decodeMsg` and `decodeOptions` from `gt-i18n`, `gt-react`, `gt-react-native`, `gt-next`, `gt-tanstack-start` and `gt-node`, and `gtFallback` from all of them but `gt-node`: no replacement. `msg('Save')` returns its text, and any other message from `msg` is a plain object that `m()` or `mFallback()` renders.
45
+ - `declareVar` and `decodeVars` from the same entries and from `generaltranslation`: no replacement. A value in a tagged template is `${value}` or `${{ name }}`, and a `derive()` context has no values: every context is a string the CLI can read.
46
+ - `derive` from `generaltranslation` → `derive` from `gt-i18n`, `gt-react`, `gt-react-native`, `gt-next`, `gt-tanstack-start` or `gt-node`, in a tagged template or as a `<T>` context.
47
+ - The type `StringFormat` from `gt-next` → import it from `generaltranslation`.
48
+ - Types `GTTranslationOptions` and `RuntimeTranslationOptions` from `gt-i18n`, `gt-react`, `gt-react-native`, `gt-next` and `gt-node` → `GTOptions`. Types `GTFunctionType` and `MFunctionType` from `gt-i18n` and `gt-node` → `GT` and `M`.
49
+ - `gt-i18n` also drops the types `TemplateSyncResolutionFunction`, `SyncResolutionFunction`, `SyncResolutionFunctionWithFallback`, `RegisteredMessage` and `LookupOptionsFor`, with no replacement. `TranslationVariables` and `JsxTranslationOptions` → import them from `gt-i18n/internal`.
50
+ - The string `msg`, `decodeOptions` and the types `GTFunctionType`, `MFunctionType`, `GTTranslationOptions`, `EncodedTranslationOptions` and `RegisterableMessages` leave the `gt-i18n` root for `gt-i18n/internal/string`, which still serves gt-svelte, gt-vue and the dictionary API.
51
+ - `gt-i18n/internal`: `getGT()`, `getMessages()` and `tx` are the tagged ones, so `getGT()` → `getGT({ locale, enableI18n })`, and the same for `getMessages`. `getGTInternal`, `getMessagesInternal`, `txInternal`, `GtInternalRuntimeTranslateString` and `extractVariables` are removed. `interpolateMessage` → import it from `gt-i18n/internal/string`.
52
+ - `gt-react` no longer exports `GtInternalRuntimeTranslateString`, which the compiler no longer injects.
53
+ - `@generaltranslation/react-core`: `t` from `/pure`, and `useGT` and `useMessages` from `/hooks`, are the tagged ones. `/pure` adds `m`.
54
+ - `generaltranslation/internal` no longer exports `extractVars` and `condenseVars`.
55
+
56
+ **`gt` (CLI):** `gt translate`, `gt validate` and the other commands that read source extract `t`, `msg` and the functions from `useGT()` and `getGT()` as message trees when they are imported by name from a main entry. They no longer extract a string call such as `t('Hello')` or `msg('Hello, {name}!', { name })`, nor a `t` that is not imported, such as a global. A string call left in the code gets a warning that names it as one. `msg('Save')` is still extracted, as a message tree. In a `<T>` context, the CLI no longer reads `declareVar()`, and it reports a `derive()` it cannot resolve as an error: it used to upload the source text of the expression as the context. The CLI now warns when a main entry is loaded through `require()`, `import()`, a namespace import or a re-export that could carry one of these functions, since it follows only named imports. It no longer warns about `useGT()` in an async function or `getGT()` in a synchronous one. In a gt-svelte project, string calls in JavaScript and TypeScript modules are now extracted by the same rules as in `.svelte` files: an alias of `t` such as `const translate = t`, a `t` passed to a function in another file, and a literal `m('...')` call are no longer followed.
57
+
58
+ **`@generaltranslation/compiler`:**
59
+ - The `enableMacroTransform` and `stringTranslationMacro` options are removed, with no replacement: the compiler no longer rewrites `` t`...` `` into a string call, and no longer adds an import for a `t` that has none. Import `t` from `gt-react`.
60
+ - It no longer hashes string calls, passes the collected messages to `useGT()` and `getGT()`, or translates strings in dev hot reload. With `compileTimeHash`, it injects `$_hash` into the tagged templates of `t`, `msg`, `useGT()` and `getGT()` imported from a main entry.
61
+ - `autoderive` and `devHotReload` apply to JSX only: `autoderive` is a boolean and `devHotReload` is `{ jsx: true }`, in the plugin options and in `gt.config.json` (below).
62
+ - The `context` of a `<T>` is a string literal or one `derive()` call with one argument. The argument no longer has to be a call: `derive(tone)` and `derive(formal ? 'formal' : 'casual')` are accepted.
63
+ - gt-next's SWC plugin (`experimentalCompilerOptions.type: 'swc'`) handles `<T>` only. It leaves tagged templates as they are, and the runtime hashes them.
64
+
65
+ **`gt.config.json`:** `files.gt.parsingFlags.autoderive` takes `true` or `false`, and `files.gt.parsingFlags.devHotReload` takes `{ "jsx": true }` or `{ "jsx": false }`. The forms that only configured string messages are removed, and a config that uses one is invalid: the CLI and gt-next stop with a message such as `files.gt.parsingFlags.devHotReload.strings: Invalid key`, and the compiler warns and builds without the file.
66
+ - `"autoderive": { "jsx": true }` or `{ "jsx": true, "strings": true }` → `"autoderive": true`. `{ "strings": true }` alone → remove the flag.
67
+ - `"devHotReload": { "jsx": true, "strings": true }` → `"devHotReload": { "jsx": true }`.
68
+ - `"devHotReload": true` or `{ "strings": true }` → remove the flag. It only translated new string messages during development, which tagged templates now do at runtime without it.
69
+ - `resolveAutoderive` from `generaltranslation/config-schema` is removed: read `parsingFlags.autoderive`, a boolean.
70
+
71
+ **`@generaltranslation/react-core-linter`:** `static-string` now checks only `msg()`, whose argument must be a single string literal, as in `msg('Save')`. It no longer checks the string passed to the function from `useGT()` or `getGT()`, no longer validates ICU syntax, and has no autofix.
72
+
73
+ **If you used a `samsara` prerelease,** the experimental `/unstable` entries are removed. Everything they exported is on the main entry:
74
+ - `gt-i18n/unstable` → `gt-i18n`, and `gt-i18n/unstable/internal` → `gt-i18n/internal`, without its `tx`: build one with `createTx`.
75
+ - `gt-react/unstable` → `gt-react`. `t` and `m` are exported only under the `browser` condition; `gt-react/unstable` also exported them to Node and worker builds.
76
+ - `gt-react-native/unstable` → `gt-react-native`.
77
+ - `gt-next/unstable` → `gt-next`, and `gt-next/unstable/server` → `gt-next/server`.
78
+ - `gt-tanstack-start/unstable` → `gt-tanstack-start`.
79
+ - `gt-node/unstable` → `gt-node`.
80
+ - `@generaltranslation/react-core/unstable` → `t` and `m` from `@generaltranslation/react-core/pure`, and `useGT` and `useMessages` from `@generaltranslation/react-core/hooks`.
81
+ - `generaltranslation/internal`: `isUnstableGTImportSource` → `isGTMessageImportSource`, `isUnstableGTHelperName` → `isGTMessageHelperName`, `UNSTABLE_GT_HELPER_NAMES` → `GT_MESSAGE_HELPER_NAMES`, and the type `UnstableGTHelperName` → `GTMessageHelperName`.
82
+ - The lint rule `@generaltranslation/react-core-linter/unstable-static-branch` → `@generaltranslation/react-core-linter/static-branch`.
83
+
84
+ ### Minor Changes
85
+
86
+ - 7d841de: `<N />` is the count of the `<Plural>` it is in, formatted as a number, as `#` is in ICU.
87
+
88
+ ```tsx
89
+ <Plural n={count} one='One file'>
90
+ <N /> files
91
+ </Plural>
92
+ ```
93
+
94
+ Use it instead of `<Num>{count}</Num>` for the count. A translation can then show the count in any branch: English `one` only covers 1, so "One file" has none, but Russian uses `one` for 21 and 31 too and renders "21 файл". `<N />` takes no props. With no `<Plural>` to give it a count, it is an error in development and renders nothing in production.
95
+
96
+ It is stored as a variable of the new type `#`, which the runtime fills from the plural's `n` wherever a translation puts it.
97
+
98
+ ### Patch Changes
99
+
100
+ - fcc6f14: The exported `t`, and the one `useGT()` and `getGT()` return, render the precomputed messages `@generaltranslation/compiler` now emits for static templates.
101
+ - e70da5f: The exported `t` renders a precomputed message in the default locale without a cache lookup, reads the locale and the enabled flag once per call, and in the browser matches the locale once per task. `initializeGTSPA()` waits for the locale's translations without copying them out of the cache.
102
+ - Updated dependencies [622199e]
103
+ - Updated dependencies [fcc6f14]
104
+ - Updated dependencies [3bedb87]
105
+ - Updated dependencies [7d841de]
106
+ - Updated dependencies [c8e2b0b]
107
+ - Updated dependencies [e70da5f]
108
+ - @generaltranslation/format@1.0.0-samsara.11
109
+ - gt-i18n@2.0.0-samsara.11
110
+ - generaltranslation@10.0.0-samsara.11
111
+
3
112
  ## 12.0.0-samsara.10
4
113
 
5
114
  ### Major Changes
@@ -323,6 +432,13 @@
323
432
  - @generaltranslation/format@1.0.0-samsara.1
324
433
  - gt-i18n@2.0.0-samsara.0
325
434
 
435
+ ## 11.4.23
436
+
437
+ ### Patch Changes
438
+
439
+ - Updated dependencies [[`25a88c9`](https://github.com/generaltranslation/gt/commit/25a88c9ffd6c8b6c68adc871e8b572ce590c0d9c)]:
440
+ - gt-i18n@1.0.44
441
+
326
442
  ## 11.4.22
327
443
 
328
444
  ### Patch Changes
@@ -1,2 +1,2 @@
1
- require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../hooks/condition-store.cjs`),t=require(`../hooks/i18n-config.cjs`),n=require(`../hooks/utils.cjs`),r=require(`../hooks/useGT.cjs`),i=require(`./useTrackedDictionaryResolver.cjs`),a=require(`./useTrackedDictionaryObjResolver.cjs`);let o=require(`gt-i18n/internal`),s=require(`react`),c=require(`gt-i18n/internal/compat`);function l(a){let l=e.useLocale(),f=t.useDefaultLocale(),p=n.useShouldTranslate(),m=r.useGT(),h=i.useTrackedDictionaryResolver(),g=u(a),_=(0,s.useCallback)((e,t={})=>{let n=d(a,e),r=h({locale:f,id:n});if(r===void 0)throw Error(`Dictionary entry ${n} cannot be found`);let i=(0,c.resolveDictionaryLookupOptions)(r.options);if(!p)return m(r.entry,{...i,...(0,o.extractVariables)(t),$locale:f});let s=h({locale:l,id:n});return s?.entry==null?m(r.entry,{...i,...(0,o.extractVariables)(t),$locale:l}):(0,c.renderDictionaryEntry)({sourceLocale:f,targetLocale:l,sourceEntry:r,target:s.entry,dictionaryOptions:i,options:t})},[f,m,a,l,h,p]);return(0,s.useMemo)(()=>Object.assign((e,t)=>_(e,t),{obj:g}),[_,g])}function u(i){let o=e.useLocale(),l=t.useDefaultLocale(),u=n.useShouldTranslate(),f=r.useGT(),p=a.useTrackedDictionaryObjResolver();return(0,s.useCallback)(e=>{let t=d(i,e),n=p({locale:l,id:t});if(n===void 0)throw Error(`Dictionary entry ${t} cannot be found`);let r;return u&&(r=p({locale:o,id:t})),(0,c.renderDictionaryObject)({sourceObject:n,targetObject:r,translate:(e,t)=>f(e.entry,{...t,$locale:u?o:l})})},[l,i,o,p,u,f])}function d(e,t){return e?`${e}.${t}`:t}exports.useTranslations=l;
1
+ require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../hooks/condition-store.cjs`),t=require(`../hooks/i18n-config.cjs`),n=require(`../hooks/utils.cjs`),r=require(`../hooks/external-store/useTrackedTranslationResolver.cjs`),i=require(`./useTrackedDictionaryResolver.cjs`),a=require(`./useTrackedDictionaryObjResolver.cjs`);let o=require(`react`),s=require(`gt-i18n/internal/compat`);function c(r){let a=e.useLocale(),c=t.useDefaultLocale(),f=n.useShouldTranslate(),p=u(),m=i.useTrackedDictionaryResolver(),h=l(r),g=(0,o.useCallback)((e,t={})=>{let n=d(r,e),i=m({locale:c,id:n});if(i===void 0)throw Error(`Dictionary entry ${n} cannot be found`);let o=f?m({locale:a,id:n})?.entry:void 0;return p(i,(0,s.resolveDictionaryLookupOptions)(i.options),o,t)},[c,p,r,a,m,f]);return(0,o.useMemo)(()=>Object.assign((e,t)=>g(e,t),{obj:h}),[g,h])}function l(r){let i=e.useLocale(),c=t.useDefaultLocale(),l=n.useShouldTranslate(),f=u(),p=a.useTrackedDictionaryObjResolver();return(0,o.useCallback)(e=>{let t=d(r,e),n=p({locale:c,id:t});if(n===void 0)throw Error(`Dictionary entry ${t} cannot be found`);let a;return l&&(a=p({locale:i,id:t})),(0,s.renderDictionaryObject)({sourceObject:n,targetObject:a,translate:(e,t)=>f(e,t)})},[c,r,i,p,l,f])}function u(){let i=e.useLocale(),a=t.useDefaultLocale(),c=n.useShouldTranslate(),l=r.useTrackedTranslationResolver(c);return(0,o.useCallback)((e,t,n,r)=>(0,s.renderDictionaryEntry)({sourceLocale:a,targetLocale:c?i:a,sourceEntry:e,target:c?n??l({locale:i,content:e.entry,options:{...t,$locale:i}}):void 0,dictionaryOptions:t,options:r}),[a,i,c,l])}function d(e,t){return e?`${e}.${t}`:t}exports.useTranslations=c;
2
2
  //# sourceMappingURL=useTranslations.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useTranslations.cjs","names":["useLocale","useDefaultLocale","useShouldTranslate","useGT","useTrackedDictionaryResolver","useTrackedDictionaryObjResolver"],"sources":["../../src/compat/useTranslations.ts"],"sourcesContent":["import { useCallback, useMemo } from 'react';\nimport { extractVariables } from 'gt-i18n/internal';\nimport {\n renderDictionaryEntry,\n renderDictionaryObject,\n resolveDictionaryLookupOptions,\n type DictionaryObjectTranslation,\n type TFunctionType,\n} from 'gt-i18n/internal/compat';\nimport { useLocale } from '../hooks/condition-store';\nimport { useGT } from '../hooks/useGT';\nimport type { TranslationVariables } from 'gt-i18n';\nimport { useDefaultLocale } from '../hooks/i18n-config';\nimport { useShouldTranslate } from '../hooks/utils';\nimport { useTrackedDictionaryResolver } from './useTrackedDictionaryResolver';\nimport { useTrackedDictionaryObjResolver } from './useTrackedDictionaryObjResolver';\n\n// ===== Hook ===== //\n\nexport function useTranslations(rootId?: string): TFunctionType {\n const locale = useLocale();\n const defaultLocale = useDefaultLocale();\n const shouldTranslate = useShouldTranslate();\n const t = useGT();\n const resolveDictionaryEntry = useTrackedDictionaryResolver();\n const translateObject = useTranslationsObj(rootId);\n\n const translateEntry = useCallback(\n (suffix: string, options: TranslationVariables = {}) => {\n const id = getId(rootId, suffix);\n\n const sourceEntry = resolveDictionaryEntry({\n locale: defaultLocale,\n id,\n });\n if (sourceEntry === undefined) {\n throw new Error(`Dictionary entry ${id} cannot be found`);\n }\n const sourceOptions = resolveDictionaryLookupOptions(sourceEntry.options);\n if (!shouldTranslate) {\n return t(sourceEntry.entry, {\n ...sourceOptions,\n ...extractVariables(options),\n $locale: defaultLocale,\n });\n }\n\n const targetEntry = resolveDictionaryEntry({ locale, id });\n if (targetEntry?.entry != null) {\n return renderDictionaryEntry({\n sourceLocale: defaultLocale,\n targetLocale: locale,\n sourceEntry,\n target: targetEntry.entry,\n dictionaryOptions: sourceOptions,\n options,\n });\n }\n\n return t(sourceEntry.entry, {\n ...sourceOptions,\n ...extractVariables(options),\n $locale: locale,\n });\n },\n [defaultLocale, t, rootId, locale, resolveDictionaryEntry, shouldTranslate]\n );\n\n // Wrap instead of mutating translateEntry, so the returned function changes\n // identity when either translateEntry or translateObject changes\n return useMemo(\n () =>\n Object.assign(\n (suffix: string, options?: TranslationVariables) =>\n translateEntry(suffix, options),\n { obj: translateObject }\n ),\n [translateEntry, translateObject]\n );\n}\n\nfunction useTranslationsObj(rootId?: string): UseTranslationsObjFunction {\n const locale = useLocale();\n const defaultLocale = useDefaultLocale();\n const shouldTranslate = useShouldTranslate();\n const t = useGT();\n const resolveDictionaryObject = useTrackedDictionaryObjResolver();\n\n return useCallback(\n (suffix: string) => {\n const entryId = getId(rootId, suffix);\n const sourceObject = resolveDictionaryObject({\n locale: defaultLocale,\n id: entryId,\n });\n if (sourceObject === undefined) {\n throw new Error(`Dictionary entry ${entryId} cannot be found`);\n }\n\n let targetObject = undefined;\n if (shouldTranslate) {\n const targetLookup = { locale, id: entryId };\n targetObject = resolveDictionaryObject(targetLookup);\n }\n\n return renderDictionaryObject({\n sourceObject,\n targetObject,\n translate: (sourceEntry, dictionaryOptions) =>\n t(sourceEntry.entry, {\n ...dictionaryOptions,\n $locale: shouldTranslate ? locale : defaultLocale,\n }),\n });\n },\n [defaultLocale, rootId, locale, resolveDictionaryObject, shouldTranslate, t]\n );\n}\n\n// ===== Lookup Helpers ===== //\n\nfunction getId(prefix: string | undefined, suffix: string): string {\n return prefix ? `${prefix}.${suffix}` : suffix;\n}\n\n// ===== Types ===== //\n\ntype UseTranslationsObjFunction = (id: string) => DictionaryObjectTranslation;\n"],"mappings":"gYAmBA,SAAgB,EAAgB,EAAgC,CAC9D,IAAM,EAASA,EAAAA,WAAW,CACpB,EAAgBC,EAAAA,kBAAkB,CAClC,EAAkBC,EAAAA,oBAAoB,CACtC,EAAIC,EAAAA,OAAO,CACX,EAAyBC,EAAAA,8BAA8B,CACvD,EAAkB,EAAmB,EAAO,CAE5C,GAAA,EAAA,EAAA,cACH,EAAgB,EAAgC,EAAE,GAAK,CACtD,IAAM,EAAK,EAAM,EAAQ,EAAO,CAE1B,EAAc,EAAuB,CACzC,OAAQ,EACR,KACD,CAAC,CACF,GAAI,IAAgB,IAAA,GAClB,MAAU,MAAM,oBAAoB,EAAG,kBAAkB,CAE3D,IAAM,GAAA,EAAA,EAAA,gCAA+C,EAAY,QAAQ,CACzE,GAAI,CAAC,EACH,OAAO,EAAE,EAAY,MAAO,CAC1B,GAAG,EACH,IAAA,EAAA,EAAA,kBAAoB,EAAQ,CAC5B,QAAS,EACV,CAAC,CAGJ,IAAM,EAAc,EAAuB,CAAE,SAAQ,KAAI,CAAC,CAY1D,OAXI,GAAa,OAAS,KAWnB,EAAE,EAAY,MAAO,CAC1B,GAAG,EACH,IAAA,EAAA,EAAA,kBAAoB,EAAQ,CAC5B,QAAS,EACV,CAAC,EAdA,EAAA,EAAA,uBAA6B,CAC3B,aAAc,EACd,aAAc,EACd,cACA,OAAQ,EAAY,MACpB,kBAAmB,EACnB,UACD,CAAC,EASN,CAAC,EAAe,EAAG,EAAQ,EAAQ,EAAwB,EAAgB,CAC5E,CAID,OAAA,EAAA,EAAA,aAEI,OAAO,QACJ,EAAgB,IACf,EAAe,EAAQ,EAAQ,CACjC,CAAE,IAAK,EAAiB,CACzB,CACH,CAAC,EAAgB,EAAgB,CAClC,CAGH,SAAS,EAAmB,EAA6C,CACvE,IAAM,EAASJ,EAAAA,WAAW,CACpB,EAAgBC,EAAAA,kBAAkB,CAClC,EAAkBC,EAAAA,oBAAoB,CACtC,EAAIC,EAAAA,OAAO,CACX,EAA0BE,EAAAA,iCAAiC,CAEjE,OAAA,EAAA,EAAA,aACG,GAAmB,CAClB,IAAM,EAAU,EAAM,EAAQ,EAAO,CAC/B,EAAe,EAAwB,CAC3C,OAAQ,EACR,GAAI,EACL,CAAC,CACF,GAAI,IAAiB,IAAA,GACnB,MAAU,MAAM,oBAAoB,EAAQ,kBAAkB,CAGhE,IAAI,EAMJ,OALI,IAEF,EAAe,EAAwB,CADhB,SAAQ,GAAI,EACgB,CAAC,GAGtD,EAAA,EAAA,wBAA8B,CAC5B,eACA,eACA,WAAY,EAAa,IACvB,EAAE,EAAY,MAAO,CACnB,GAAG,EACH,QAAS,EAAkB,EAAS,EACrC,CAAC,CACL,CAAC,EAEJ,CAAC,EAAe,EAAQ,EAAQ,EAAyB,EAAiB,EAAE,CAC7E,CAKH,SAAS,EAAM,EAA4B,EAAwB,CACjE,OAAO,EAAS,GAAG,EAAO,GAAG,IAAW"}
1
+ {"version":3,"file":"useTranslations.cjs","names":["useLocale","useDefaultLocale","useShouldTranslate","useTrackedDictionaryResolver","useTrackedDictionaryObjResolver","useTrackedTranslationResolver"],"sources":["../../src/compat/useTranslations.ts"],"sourcesContent":["import { useCallback, useMemo } from 'react';\nimport type { TranslationVariables } from 'gt-i18n/internal';\nimport {\n renderDictionaryEntry,\n renderDictionaryObject,\n resolveDictionaryLookupOptions,\n type DictionaryEntry,\n type DictionaryObjectTranslation,\n type TFunctionType,\n} from 'gt-i18n/internal/compat';\nimport { useLocale } from '../hooks/condition-store';\nimport { useDefaultLocale } from '../hooks/i18n-config';\nimport { useShouldTranslate } from '../hooks/utils';\nimport { useTrackedTranslationResolver } from '../hooks/external-store/useTrackedTranslationResolver';\nimport { useTrackedDictionaryResolver } from './useTrackedDictionaryResolver';\nimport { useTrackedDictionaryObjResolver } from './useTrackedDictionaryObjResolver';\n\n// ===== Hook ===== //\n\nexport function useTranslations(rootId?: string): TFunctionType {\n const locale = useLocale();\n const defaultLocale = useDefaultLocale();\n const shouldTranslate = useShouldTranslate();\n const renderEntry = useRenderDictionaryEntry();\n const resolveDictionaryEntry = useTrackedDictionaryResolver();\n const translateObject = useTranslationsObj(rootId);\n\n const translateEntry = useCallback(\n (suffix: string, options: TranslationVariables = {}) => {\n const id = getId(rootId, suffix);\n\n const sourceEntry = resolveDictionaryEntry({\n locale: defaultLocale,\n id,\n });\n if (sourceEntry === undefined) {\n throw new Error(`Dictionary entry ${id} cannot be found`);\n }\n const target = shouldTranslate\n ? resolveDictionaryEntry({ locale, id })?.entry\n : undefined;\n return renderEntry(\n sourceEntry,\n resolveDictionaryLookupOptions(sourceEntry.options),\n target,\n options\n );\n },\n [\n defaultLocale,\n renderEntry,\n rootId,\n locale,\n resolveDictionaryEntry,\n shouldTranslate,\n ]\n );\n\n // Wrap instead of mutating translateEntry, so the returned function changes\n // identity when either translateEntry or translateObject changes\n return useMemo(\n () =>\n Object.assign(\n (suffix: string, options?: TranslationVariables) =>\n translateEntry(suffix, options),\n { obj: translateObject }\n ),\n [translateEntry, translateObject]\n );\n}\n\nfunction useTranslationsObj(rootId?: string): UseTranslationsObjFunction {\n const locale = useLocale();\n const defaultLocale = useDefaultLocale();\n const shouldTranslate = useShouldTranslate();\n const renderEntry = useRenderDictionaryEntry();\n const resolveDictionaryObject = useTrackedDictionaryObjResolver();\n\n return useCallback(\n (suffix: string) => {\n const entryId = getId(rootId, suffix);\n const sourceObject = resolveDictionaryObject({\n locale: defaultLocale,\n id: entryId,\n });\n if (sourceObject === undefined) {\n throw new Error(`Dictionary entry ${entryId} cannot be found`);\n }\n\n let targetObject = undefined;\n if (shouldTranslate) {\n const targetLookup = { locale, id: entryId };\n targetObject = resolveDictionaryObject(targetLookup);\n }\n\n return renderDictionaryObject({\n sourceObject,\n targetObject,\n translate: (sourceEntry, dictionaryOptions) =>\n renderEntry(sourceEntry, dictionaryOptions),\n });\n },\n [\n defaultLocale,\n rootId,\n locale,\n resolveDictionaryObject,\n shouldTranslate,\n renderEntry,\n ]\n );\n}\n\n/**\n * Renders a source entry in the render locale: with `target` when the target\n * dictionary has the entry, else with the entry's translation from the\n * translations snapshot or cache, else from the source.\n */\nfunction useRenderDictionaryEntry() {\n const locale = useLocale();\n const defaultLocale = useDefaultLocale();\n const shouldTranslate = useShouldTranslate();\n const resolveTranslation = useTrackedTranslationResolver(shouldTranslate);\n\n return useCallback(\n (\n sourceEntry: DictionaryEntry,\n dictionaryOptions: ReturnType<typeof resolveDictionaryLookupOptions>,\n target?: string,\n options?: TranslationVariables\n ): string =>\n renderDictionaryEntry({\n sourceLocale: defaultLocale,\n targetLocale: shouldTranslate ? locale : defaultLocale,\n sourceEntry,\n target: shouldTranslate\n ? (target ??\n resolveTranslation({\n locale,\n content: sourceEntry.entry,\n options: { ...dictionaryOptions, $locale: locale },\n }))\n : undefined,\n dictionaryOptions,\n options,\n }),\n [defaultLocale, locale, shouldTranslate, resolveTranslation]\n );\n}\n\n// ===== Lookup Helpers ===== //\n\nfunction getId(prefix: string | undefined, suffix: string): string {\n return prefix ? `${prefix}.${suffix}` : suffix;\n}\n\n// ===== Types ===== //\n\ntype UseTranslationsObjFunction = (id: string) => DictionaryObjectTranslation;\n"],"mappings":"yYAmBA,SAAgB,EAAgB,EAAgC,CAC9D,IAAM,EAASA,EAAAA,WAAW,CACpB,EAAgBC,EAAAA,kBAAkB,CAClC,EAAkBC,EAAAA,oBAAoB,CACtC,EAAc,GAA0B,CACxC,EAAyBC,EAAAA,8BAA8B,CACvD,EAAkB,EAAmB,EAAO,CAE5C,GAAA,EAAA,EAAA,cACH,EAAgB,EAAgC,EAAE,GAAK,CACtD,IAAM,EAAK,EAAM,EAAQ,EAAO,CAE1B,EAAc,EAAuB,CACzC,OAAQ,EACR,KACD,CAAC,CACF,GAAI,IAAgB,IAAA,GAClB,MAAU,MAAM,oBAAoB,EAAG,kBAAkB,CAE3D,IAAM,EAAS,EACX,EAAuB,CAAE,SAAQ,KAAI,CAAC,EAAE,MACxC,IAAA,GACJ,OAAO,EACL,GAAA,EAAA,EAAA,gCAC+B,EAAY,QAAQ,CACnD,EACA,EACD,EAEH,CACE,EACA,EACA,EACA,EACA,EACA,EACD,CACF,CAID,OAAA,EAAA,EAAA,aAEI,OAAO,QACJ,EAAgB,IACf,EAAe,EAAQ,EAAQ,CACjC,CAAE,IAAK,EAAiB,CACzB,CACH,CAAC,EAAgB,EAAgB,CAClC,CAGH,SAAS,EAAmB,EAA6C,CACvE,IAAM,EAASH,EAAAA,WAAW,CACpB,EAAgBC,EAAAA,kBAAkB,CAClC,EAAkBC,EAAAA,oBAAoB,CACtC,EAAc,GAA0B,CACxC,EAA0BE,EAAAA,iCAAiC,CAEjE,OAAA,EAAA,EAAA,aACG,GAAmB,CAClB,IAAM,EAAU,EAAM,EAAQ,EAAO,CAC/B,EAAe,EAAwB,CAC3C,OAAQ,EACR,GAAI,EACL,CAAC,CACF,GAAI,IAAiB,IAAA,GACnB,MAAU,MAAM,oBAAoB,EAAQ,kBAAkB,CAGhE,IAAI,EAMJ,OALI,IAEF,EAAe,EAAwB,CADhB,SAAQ,GAAI,EACgB,CAAC,GAGtD,EAAA,EAAA,wBAA8B,CAC5B,eACA,eACA,WAAY,EAAa,IACvB,EAAY,EAAa,EAAkB,CAC9C,CAAC,EAEJ,CACE,EACA,EACA,EACA,EACA,EACA,EACD,CACF,CAQH,SAAS,GAA2B,CAClC,IAAM,EAASJ,EAAAA,WAAW,CACpB,EAAgBC,EAAAA,kBAAkB,CAClC,EAAkBC,EAAAA,oBAAoB,CACtC,EAAqBG,EAAAA,8BAA8B,EAAgB,CAEzE,OAAA,EAAA,EAAA,cAEI,EACA,EACA,EACA,KAAA,EAAA,EAAA,uBAEsB,CACpB,aAAc,EACd,aAAc,EAAkB,EAAS,EACzC,cACA,OAAQ,EACH,GACD,EAAmB,CACjB,SACA,QAAS,EAAY,MACrB,QAAS,CAAE,GAAG,EAAmB,QAAS,EAAQ,CACnD,CAAC,CACF,IAAA,GACJ,oBACA,UACD,CAAC,CACJ,CAAC,EAAe,EAAQ,EAAiB,EAAmB,CAC7D,CAKH,SAAS,EAAM,EAA4B,EAAwB,CACjE,OAAO,EAAS,GAAG,EAAO,GAAG,IAAW"}
@@ -1,2 +1,2 @@
1
- import{useLocale as e}from"../hooks/condition-store.mjs";import{useDefaultLocale as t}from"../hooks/i18n-config.mjs";import{useShouldTranslate as n}from"../hooks/utils.mjs";import{useGT as r}from"../hooks/useGT.mjs";import{useTrackedDictionaryResolver as i}from"./useTrackedDictionaryResolver.mjs";import{useTrackedDictionaryObjResolver as a}from"./useTrackedDictionaryObjResolver.mjs";import{extractVariables as o}from"gt-i18n/internal";import{useCallback as s,useMemo as c}from"react";import{renderDictionaryEntry as l,renderDictionaryObject as u,resolveDictionaryLookupOptions as d}from"gt-i18n/internal/compat";function f(a){let u=e(),f=t(),h=n(),g=r(),_=i(),v=p(a),y=s((e,t={})=>{let n=m(a,e),r=_({locale:f,id:n});if(r===void 0)throw Error(`Dictionary entry ${n} cannot be found`);let i=d(r.options);if(!h)return g(r.entry,{...i,...o(t),$locale:f});let s=_({locale:u,id:n});return s?.entry==null?g(r.entry,{...i,...o(t),$locale:u}):l({sourceLocale:f,targetLocale:u,sourceEntry:r,target:s.entry,dictionaryOptions:i,options:t})},[f,g,a,u,_,h]);return c(()=>Object.assign((e,t)=>y(e,t),{obj:v}),[y,v])}function p(i){let o=e(),c=t(),l=n(),d=r(),f=a();return s(e=>{let t=m(i,e),n=f({locale:c,id:t});if(n===void 0)throw Error(`Dictionary entry ${t} cannot be found`);let r;return l&&(r=f({locale:o,id:t})),u({sourceObject:n,targetObject:r,translate:(e,t)=>d(e.entry,{...t,$locale:l?o:c})})},[c,i,o,f,l,d])}function m(e,t){return e?`${e}.${t}`:t}export{f as useTranslations};
1
+ import{useLocale as e}from"../hooks/condition-store.mjs";import{useDefaultLocale as t}from"../hooks/i18n-config.mjs";import{useShouldTranslate as n}from"../hooks/utils.mjs";import{useTrackedTranslationResolver as r}from"../hooks/external-store/useTrackedTranslationResolver.mjs";import{useTrackedDictionaryResolver as i}from"./useTrackedDictionaryResolver.mjs";import{useTrackedDictionaryObjResolver as a}from"./useTrackedDictionaryObjResolver.mjs";import{useCallback as o,useMemo as s}from"react";import{renderDictionaryEntry as c,renderDictionaryObject as l,resolveDictionaryLookupOptions as u}from"gt-i18n/internal/compat";function d(r){let a=e(),c=t(),l=n(),d=p(),h=i(),g=f(r),_=o((e,t={})=>{let n=m(r,e),i=h({locale:c,id:n});if(i===void 0)throw Error(`Dictionary entry ${n} cannot be found`);let o=l?h({locale:a,id:n})?.entry:void 0;return d(i,u(i.options),o,t)},[c,d,r,a,h,l]);return s(()=>Object.assign((e,t)=>_(e,t),{obj:g}),[_,g])}function f(r){let i=e(),s=t(),c=n(),u=p(),d=a();return o(e=>{let t=m(r,e),n=d({locale:s,id:t});if(n===void 0)throw Error(`Dictionary entry ${t} cannot be found`);let a;return c&&(a=d({locale:i,id:t})),l({sourceObject:n,targetObject:a,translate:(e,t)=>u(e,t)})},[s,r,i,d,c,u])}function p(){let i=e(),a=t(),s=n(),l=r(s);return o((e,t,n,r)=>c({sourceLocale:a,targetLocale:s?i:a,sourceEntry:e,target:s?n??l({locale:i,content:e.entry,options:{...t,$locale:i}}):void 0,dictionaryOptions:t,options:r}),[a,i,s,l])}function m(e,t){return e?`${e}.${t}`:t}export{d as useTranslations};
2
2
  //# sourceMappingURL=useTranslations.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useTranslations.mjs","names":[],"sources":["../../src/compat/useTranslations.ts"],"sourcesContent":["import { useCallback, useMemo } from 'react';\nimport { extractVariables } from 'gt-i18n/internal';\nimport {\n renderDictionaryEntry,\n renderDictionaryObject,\n resolveDictionaryLookupOptions,\n type DictionaryObjectTranslation,\n type TFunctionType,\n} from 'gt-i18n/internal/compat';\nimport { useLocale } from '../hooks/condition-store';\nimport { useGT } from '../hooks/useGT';\nimport type { TranslationVariables } from 'gt-i18n';\nimport { useDefaultLocale } from '../hooks/i18n-config';\nimport { useShouldTranslate } from '../hooks/utils';\nimport { useTrackedDictionaryResolver } from './useTrackedDictionaryResolver';\nimport { useTrackedDictionaryObjResolver } from './useTrackedDictionaryObjResolver';\n\n// ===== Hook ===== //\n\nexport function useTranslations(rootId?: string): TFunctionType {\n const locale = useLocale();\n const defaultLocale = useDefaultLocale();\n const shouldTranslate = useShouldTranslate();\n const t = useGT();\n const resolveDictionaryEntry = useTrackedDictionaryResolver();\n const translateObject = useTranslationsObj(rootId);\n\n const translateEntry = useCallback(\n (suffix: string, options: TranslationVariables = {}) => {\n const id = getId(rootId, suffix);\n\n const sourceEntry = resolveDictionaryEntry({\n locale: defaultLocale,\n id,\n });\n if (sourceEntry === undefined) {\n throw new Error(`Dictionary entry ${id} cannot be found`);\n }\n const sourceOptions = resolveDictionaryLookupOptions(sourceEntry.options);\n if (!shouldTranslate) {\n return t(sourceEntry.entry, {\n ...sourceOptions,\n ...extractVariables(options),\n $locale: defaultLocale,\n });\n }\n\n const targetEntry = resolveDictionaryEntry({ locale, id });\n if (targetEntry?.entry != null) {\n return renderDictionaryEntry({\n sourceLocale: defaultLocale,\n targetLocale: locale,\n sourceEntry,\n target: targetEntry.entry,\n dictionaryOptions: sourceOptions,\n options,\n });\n }\n\n return t(sourceEntry.entry, {\n ...sourceOptions,\n ...extractVariables(options),\n $locale: locale,\n });\n },\n [defaultLocale, t, rootId, locale, resolveDictionaryEntry, shouldTranslate]\n );\n\n // Wrap instead of mutating translateEntry, so the returned function changes\n // identity when either translateEntry or translateObject changes\n return useMemo(\n () =>\n Object.assign(\n (suffix: string, options?: TranslationVariables) =>\n translateEntry(suffix, options),\n { obj: translateObject }\n ),\n [translateEntry, translateObject]\n );\n}\n\nfunction useTranslationsObj(rootId?: string): UseTranslationsObjFunction {\n const locale = useLocale();\n const defaultLocale = useDefaultLocale();\n const shouldTranslate = useShouldTranslate();\n const t = useGT();\n const resolveDictionaryObject = useTrackedDictionaryObjResolver();\n\n return useCallback(\n (suffix: string) => {\n const entryId = getId(rootId, suffix);\n const sourceObject = resolveDictionaryObject({\n locale: defaultLocale,\n id: entryId,\n });\n if (sourceObject === undefined) {\n throw new Error(`Dictionary entry ${entryId} cannot be found`);\n }\n\n let targetObject = undefined;\n if (shouldTranslate) {\n const targetLookup = { locale, id: entryId };\n targetObject = resolveDictionaryObject(targetLookup);\n }\n\n return renderDictionaryObject({\n sourceObject,\n targetObject,\n translate: (sourceEntry, dictionaryOptions) =>\n t(sourceEntry.entry, {\n ...dictionaryOptions,\n $locale: shouldTranslate ? locale : defaultLocale,\n }),\n });\n },\n [defaultLocale, rootId, locale, resolveDictionaryObject, shouldTranslate, t]\n );\n}\n\n// ===== Lookup Helpers ===== //\n\nfunction getId(prefix: string | undefined, suffix: string): string {\n return prefix ? `${prefix}.${suffix}` : suffix;\n}\n\n// ===== Types ===== //\n\ntype UseTranslationsObjFunction = (id: string) => DictionaryObjectTranslation;\n"],"mappings":"umBAmBA,SAAgB,EAAgB,EAAgC,CAC9D,IAAM,EAAS,GAAW,CACpB,EAAgB,GAAkB,CAClC,EAAkB,GAAoB,CACtC,EAAI,GAAO,CACX,EAAyB,GAA8B,CACvD,EAAkB,EAAmB,EAAO,CAE5C,EAAiB,GACpB,EAAgB,EAAgC,EAAE,GAAK,CACtD,IAAM,EAAK,EAAM,EAAQ,EAAO,CAE1B,EAAc,EAAuB,CACzC,OAAQ,EACR,KACD,CAAC,CACF,GAAI,IAAgB,IAAA,GAClB,MAAU,MAAM,oBAAoB,EAAG,kBAAkB,CAE3D,IAAM,EAAgB,EAA+B,EAAY,QAAQ,CACzE,GAAI,CAAC,EACH,OAAO,EAAE,EAAY,MAAO,CAC1B,GAAG,EACH,GAAG,EAAiB,EAAQ,CAC5B,QAAS,EACV,CAAC,CAGJ,IAAM,EAAc,EAAuB,CAAE,SAAQ,KAAI,CAAC,CAY1D,OAXI,GAAa,OAAS,KAWnB,EAAE,EAAY,MAAO,CAC1B,GAAG,EACH,GAAG,EAAiB,EAAQ,CAC5B,QAAS,EACV,CAAC,CAdO,EAAsB,CAC3B,aAAc,EACd,aAAc,EACd,cACA,OAAQ,EAAY,MACpB,kBAAmB,EACnB,UACD,CAAC,EASN,CAAC,EAAe,EAAG,EAAQ,EAAQ,EAAwB,EAAgB,CAC5E,CAID,OAAO,MAEH,OAAO,QACJ,EAAgB,IACf,EAAe,EAAQ,EAAQ,CACjC,CAAE,IAAK,EAAiB,CACzB,CACH,CAAC,EAAgB,EAAgB,CAClC,CAGH,SAAS,EAAmB,EAA6C,CACvE,IAAM,EAAS,GAAW,CACpB,EAAgB,GAAkB,CAClC,EAAkB,GAAoB,CACtC,EAAI,GAAO,CACX,EAA0B,GAAiC,CAEjE,OAAO,EACJ,GAAmB,CAClB,IAAM,EAAU,EAAM,EAAQ,EAAO,CAC/B,EAAe,EAAwB,CAC3C,OAAQ,EACR,GAAI,EACL,CAAC,CACF,GAAI,IAAiB,IAAA,GACnB,MAAU,MAAM,oBAAoB,EAAQ,kBAAkB,CAGhE,IAAI,EAMJ,OALI,IAEF,EAAe,EAAwB,CADhB,SAAQ,GAAI,EACgB,CAAC,EAG/C,EAAuB,CAC5B,eACA,eACA,WAAY,EAAa,IACvB,EAAE,EAAY,MAAO,CACnB,GAAG,EACH,QAAS,EAAkB,EAAS,EACrC,CAAC,CACL,CAAC,EAEJ,CAAC,EAAe,EAAQ,EAAQ,EAAyB,EAAiB,EAAE,CAC7E,CAKH,SAAS,EAAM,EAA4B,EAAwB,CACjE,OAAO,EAAS,GAAG,EAAO,GAAG,IAAW"}
1
+ {"version":3,"file":"useTranslations.mjs","names":[],"sources":["../../src/compat/useTranslations.ts"],"sourcesContent":["import { useCallback, useMemo } from 'react';\nimport type { TranslationVariables } from 'gt-i18n/internal';\nimport {\n renderDictionaryEntry,\n renderDictionaryObject,\n resolveDictionaryLookupOptions,\n type DictionaryEntry,\n type DictionaryObjectTranslation,\n type TFunctionType,\n} from 'gt-i18n/internal/compat';\nimport { useLocale } from '../hooks/condition-store';\nimport { useDefaultLocale } from '../hooks/i18n-config';\nimport { useShouldTranslate } from '../hooks/utils';\nimport { useTrackedTranslationResolver } from '../hooks/external-store/useTrackedTranslationResolver';\nimport { useTrackedDictionaryResolver } from './useTrackedDictionaryResolver';\nimport { useTrackedDictionaryObjResolver } from './useTrackedDictionaryObjResolver';\n\n// ===== Hook ===== //\n\nexport function useTranslations(rootId?: string): TFunctionType {\n const locale = useLocale();\n const defaultLocale = useDefaultLocale();\n const shouldTranslate = useShouldTranslate();\n const renderEntry = useRenderDictionaryEntry();\n const resolveDictionaryEntry = useTrackedDictionaryResolver();\n const translateObject = useTranslationsObj(rootId);\n\n const translateEntry = useCallback(\n (suffix: string, options: TranslationVariables = {}) => {\n const id = getId(rootId, suffix);\n\n const sourceEntry = resolveDictionaryEntry({\n locale: defaultLocale,\n id,\n });\n if (sourceEntry === undefined) {\n throw new Error(`Dictionary entry ${id} cannot be found`);\n }\n const target = shouldTranslate\n ? resolveDictionaryEntry({ locale, id })?.entry\n : undefined;\n return renderEntry(\n sourceEntry,\n resolveDictionaryLookupOptions(sourceEntry.options),\n target,\n options\n );\n },\n [\n defaultLocale,\n renderEntry,\n rootId,\n locale,\n resolveDictionaryEntry,\n shouldTranslate,\n ]\n );\n\n // Wrap instead of mutating translateEntry, so the returned function changes\n // identity when either translateEntry or translateObject changes\n return useMemo(\n () =>\n Object.assign(\n (suffix: string, options?: TranslationVariables) =>\n translateEntry(suffix, options),\n { obj: translateObject }\n ),\n [translateEntry, translateObject]\n );\n}\n\nfunction useTranslationsObj(rootId?: string): UseTranslationsObjFunction {\n const locale = useLocale();\n const defaultLocale = useDefaultLocale();\n const shouldTranslate = useShouldTranslate();\n const renderEntry = useRenderDictionaryEntry();\n const resolveDictionaryObject = useTrackedDictionaryObjResolver();\n\n return useCallback(\n (suffix: string) => {\n const entryId = getId(rootId, suffix);\n const sourceObject = resolveDictionaryObject({\n locale: defaultLocale,\n id: entryId,\n });\n if (sourceObject === undefined) {\n throw new Error(`Dictionary entry ${entryId} cannot be found`);\n }\n\n let targetObject = undefined;\n if (shouldTranslate) {\n const targetLookup = { locale, id: entryId };\n targetObject = resolveDictionaryObject(targetLookup);\n }\n\n return renderDictionaryObject({\n sourceObject,\n targetObject,\n translate: (sourceEntry, dictionaryOptions) =>\n renderEntry(sourceEntry, dictionaryOptions),\n });\n },\n [\n defaultLocale,\n rootId,\n locale,\n resolveDictionaryObject,\n shouldTranslate,\n renderEntry,\n ]\n );\n}\n\n/**\n * Renders a source entry in the render locale: with `target` when the target\n * dictionary has the entry, else with the entry's translation from the\n * translations snapshot or cache, else from the source.\n */\nfunction useRenderDictionaryEntry() {\n const locale = useLocale();\n const defaultLocale = useDefaultLocale();\n const shouldTranslate = useShouldTranslate();\n const resolveTranslation = useTrackedTranslationResolver(shouldTranslate);\n\n return useCallback(\n (\n sourceEntry: DictionaryEntry,\n dictionaryOptions: ReturnType<typeof resolveDictionaryLookupOptions>,\n target?: string,\n options?: TranslationVariables\n ): string =>\n renderDictionaryEntry({\n sourceLocale: defaultLocale,\n targetLocale: shouldTranslate ? locale : defaultLocale,\n sourceEntry,\n target: shouldTranslate\n ? (target ??\n resolveTranslation({\n locale,\n content: sourceEntry.entry,\n options: { ...dictionaryOptions, $locale: locale },\n }))\n : undefined,\n dictionaryOptions,\n options,\n }),\n [defaultLocale, locale, shouldTranslate, resolveTranslation]\n );\n}\n\n// ===== Lookup Helpers ===== //\n\nfunction getId(prefix: string | undefined, suffix: string): string {\n return prefix ? `${prefix}.${suffix}` : suffix;\n}\n\n// ===== Types ===== //\n\ntype UseTranslationsObjFunction = (id: string) => DictionaryObjectTranslation;\n"],"mappings":"knBAmBA,SAAgB,EAAgB,EAAgC,CAC9D,IAAM,EAAS,GAAW,CACpB,EAAgB,GAAkB,CAClC,EAAkB,GAAoB,CACtC,EAAc,GAA0B,CACxC,EAAyB,GAA8B,CACvD,EAAkB,EAAmB,EAAO,CAE5C,EAAiB,GACpB,EAAgB,EAAgC,EAAE,GAAK,CACtD,IAAM,EAAK,EAAM,EAAQ,EAAO,CAE1B,EAAc,EAAuB,CACzC,OAAQ,EACR,KACD,CAAC,CACF,GAAI,IAAgB,IAAA,GAClB,MAAU,MAAM,oBAAoB,EAAG,kBAAkB,CAE3D,IAAM,EAAS,EACX,EAAuB,CAAE,SAAQ,KAAI,CAAC,EAAE,MACxC,IAAA,GACJ,OAAO,EACL,EACA,EAA+B,EAAY,QAAQ,CACnD,EACA,EACD,EAEH,CACE,EACA,EACA,EACA,EACA,EACA,EACD,CACF,CAID,OAAO,MAEH,OAAO,QACJ,EAAgB,IACf,EAAe,EAAQ,EAAQ,CACjC,CAAE,IAAK,EAAiB,CACzB,CACH,CAAC,EAAgB,EAAgB,CAClC,CAGH,SAAS,EAAmB,EAA6C,CACvE,IAAM,EAAS,GAAW,CACpB,EAAgB,GAAkB,CAClC,EAAkB,GAAoB,CACtC,EAAc,GAA0B,CACxC,EAA0B,GAAiC,CAEjE,OAAO,EACJ,GAAmB,CAClB,IAAM,EAAU,EAAM,EAAQ,EAAO,CAC/B,EAAe,EAAwB,CAC3C,OAAQ,EACR,GAAI,EACL,CAAC,CACF,GAAI,IAAiB,IAAA,GACnB,MAAU,MAAM,oBAAoB,EAAQ,kBAAkB,CAGhE,IAAI,EAMJ,OALI,IAEF,EAAe,EAAwB,CADhB,SAAQ,GAAI,EACgB,CAAC,EAG/C,EAAuB,CAC5B,eACA,eACA,WAAY,EAAa,IACvB,EAAY,EAAa,EAAkB,CAC9C,CAAC,EAEJ,CACE,EACA,EACA,EACA,EACA,EACA,EACD,CACF,CAQH,SAAS,GAA2B,CAClC,IAAM,EAAS,GAAW,CACpB,EAAgB,GAAkB,CAClC,EAAkB,GAAoB,CACtC,EAAqB,EAA8B,EAAgB,CAEzE,OAAO,GAEH,EACA,EACA,EACA,IAEA,EAAsB,CACpB,aAAc,EACd,aAAc,EAAkB,EAAS,EACzC,cACA,OAAQ,EACH,GACD,EAAmB,CACjB,SACA,QAAS,EAAY,MACrB,QAAS,CAAE,GAAG,EAAmB,QAAS,EAAQ,CACnD,CAAC,CACF,IAAA,GACJ,oBACA,UACD,CAAC,CACJ,CAAC,EAAe,EAAQ,EAAiB,EAAmB,CAC7D,CAKH,SAAS,EAAM,EAA4B,EAAwB,CACjE,OAAO,EAAS,GAAG,EAAO,GAAG,IAAW"}
@@ -1,2 +1,2 @@
1
- require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../hooks/utils/getFormatLocales.cjs`),t=require(`../../utils/plurals/getPluralBranch.cjs`);let n=require(`generaltranslation/internal`);function r({_enableI18n:r,_locale:i,n:a,children:o,...s}){return t.getPluralBranch(a,e.getFormatLocales({locale:i,enableI18n:r}),Object.fromEntries([...Object.entries(s).filter(([e])=>(0,n.isAcceptedPluralForm)(e)).map(([e,t])=>[(0,n.getPluralBranchKey)(e),t]),[`other`,o]]))}exports.renderPlural=r;
1
+ require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../hooks/utils/getFormatLocales.cjs`),t=require(`../../utils/plurals/getPluralBranch.cjs`),n=require(`../../utils/plurals/fillCount.cjs`);let r=require(`generaltranslation/internal`);function i({_enableI18n:i,_locale:a,n:o,children:s,...c}){let l=t.getPluralBranch(o,e.getFormatLocales({locale:a,enableI18n:i}),Object.fromEntries([...Object.entries(c).filter(([e])=>(0,r.isAcceptedPluralForm)(e)).map(([e,t])=>[(0,r.getPluralBranchKey)(e),t]),[`other`,s]]));return t.isCount(o)?n.fillCount(l,o):l}exports.renderPlural=i;
2
2
  //# sourceMappingURL=Plural.shared.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Plural.shared.cjs","names":["getPluralBranch","getFormatLocales"],"sources":["../../../src/components/branches/Plural.shared.ts"],"sourcesContent":["import {\n getPluralBranchKey,\n isAcceptedPluralForm,\n} from 'generaltranslation/internal';\nimport { getPluralBranch } from '../../utils/plurals/getPluralBranch';\nimport type { ReactNode } from 'react';\nimport { getFormatLocales } from '../../hooks/utils/getFormatLocales';\n\n// Pure render logic shared by the hook-based and RSC implementations. This\n// module must stay free of hook/context imports so it can be reached from the\n// components-rsc entrypoint.\n\ntype PluralProps = {\n n: number | bigint;\n /** The fallback, as `other` is in `plural()`. */\n children: ReactNode;\n} & Partial<\n // `_0` is the exact number 0: ICU's `=0`, which JSX cannot spell.\n Record<Exclude<Intl.LDMLPluralRule, 'other'> | `_${number}`, ReactNode>\n>;\n\ntype PluralConditions = {\n _locale: string;\n _enableI18n: boolean;\n};\n\ntype ResolvedPluralProps = PluralProps & PluralConditions;\n\nfunction renderPlural({\n _enableI18n,\n _locale,\n n,\n children,\n ...props\n}: ResolvedPluralProps): ReactNode {\n const locales = getFormatLocales({\n locale: _locale,\n enableI18n: _enableI18n,\n });\n const branches = Object.fromEntries([\n ...Object.entries(props)\n .filter(([prop]) => isAcceptedPluralForm(prop))\n .map(([prop, branch]) => [getPluralBranchKey(prop), branch]),\n ['other', children],\n ]);\n return getPluralBranch(n, locales, branches);\n}\n\nexport { renderPlural };\nexport type { PluralProps, ResolvedPluralProps };\n"],"mappings":"4MA4BA,SAAS,EAAa,CACpB,cACA,UACA,IACA,WACA,GAAG,GAC8B,CAWjC,OAAOA,EAAAA,gBAAgB,EAVPC,EAAAA,iBAAiB,CAC/B,OAAQ,EACR,WAAY,EACb,CAOgC,CANhB,OAAO,YAAY,CAClC,GAAG,OAAO,QAAQ,EAAM,CACrB,QAAQ,CAAC,MAAA,EAAA,EAAA,sBAA+B,EAAK,CAAC,CAC9C,KAAK,CAAC,EAAM,KAAY,EAAA,EAAA,EAAA,oBAAoB,EAAK,CAAE,EAAO,CAAC,CAC9D,CAAC,QAAS,EAAS,CACpB,CAC0C,CAAC"}
1
+ {"version":3,"file":"Plural.shared.cjs","names":["getPluralBranch","getFormatLocales","isCount","fillCount"],"sources":["../../../src/components/branches/Plural.shared.ts"],"sourcesContent":["import {\n getPluralBranchKey,\n isAcceptedPluralForm,\n} from 'generaltranslation/internal';\nimport { getPluralBranch, isCount } from '../../utils/plurals/getPluralBranch';\nimport { fillCount } from '../../utils/plurals/fillCount';\nimport type { ReactNode } from 'react';\nimport { getFormatLocales } from '../../hooks/utils/getFormatLocales';\n\n// Pure render logic shared by the hook-based and RSC implementations. This\n// module must stay free of hook/context imports so it can be reached from the\n// components-rsc entrypoint.\n\ntype PluralProps = {\n n: number | bigint;\n /** The fallback, as `other` is in `plural()`. */\n children: ReactNode;\n} & Partial<\n // `_0` is the exact number 0: ICU's `=0`, which JSX cannot spell.\n Record<Exclude<Intl.LDMLPluralRule, 'other'> | `_${number}`, ReactNode>\n>;\n\ntype PluralConditions = {\n _locale: string;\n _enableI18n: boolean;\n};\n\ntype ResolvedPluralProps = PluralProps & PluralConditions;\n\nfunction renderPlural({\n _enableI18n,\n _locale,\n n,\n children,\n ...props\n}: ResolvedPluralProps): ReactNode {\n const locales = getFormatLocales({\n locale: _locale,\n enableI18n: _enableI18n,\n });\n const branches = Object.fromEntries([\n ...Object.entries(props)\n .filter(([prop]) => isAcceptedPluralForm(prop))\n .map(([prop, branch]) => [getPluralBranchKey(prop), branch]),\n ['other', children],\n ]);\n const branch: ReactNode = getPluralBranch(n, locales, branches);\n // An `n` that is no number is reported where the branch is picked.\n return isCount(n) ? fillCount(branch, n) : branch;\n}\n\nexport { renderPlural };\nexport type { PluralProps, ResolvedPluralProps };\n"],"mappings":"2PA6BA,SAAS,EAAa,CACpB,cACA,UACA,IACA,WACA,GAAG,GAC8B,CAWjC,IAAM,EAAoBA,EAAAA,gBAAgB,EAV1BC,EAAAA,iBAAiB,CAC/B,OAAQ,EACR,WAAY,EACb,CAOmD,CANnC,OAAO,YAAY,CAClC,GAAG,OAAO,QAAQ,EAAM,CACrB,QAAQ,CAAC,MAAA,EAAA,EAAA,sBAA+B,EAAK,CAAC,CAC9C,KAAK,CAAC,EAAM,KAAY,EAAA,EAAA,EAAA,oBAAoB,EAAK,CAAE,EAAO,CAAC,CAC9D,CAAC,QAAS,EAAS,CACpB,CAC6D,CAAC,CAE/D,OAAOC,EAAAA,QAAQ,EAAE,CAAGC,EAAAA,UAAU,EAAQ,EAAE,CAAG"}
@@ -1 +1 @@
1
- {"version":3,"file":"Plural.shared.d.ts","names":[],"sources":["../../../src/components/branches/Plural.shared.ts"],"mappings":";;;KAYK,WAAA;EACH,CAAA,mBADG;EAGH,QAAA,EAAU,SAAA;AAAA,IACR,OAAA,CAEF,MAAA,CAAO,OAAA,CAAQ,IAAA,CAAK,cAAA,2BAAyC,SAAA;AAAA,KAG1D,gBAAA;EACH,OAAA;EACA,WAAA;AAAA;AAAA,KAGG,mBAAA,GAAsB,WAAA,GAAc,gBAAA"}
1
+ {"version":3,"file":"Plural.shared.d.ts","names":[],"sources":["../../../src/components/branches/Plural.shared.ts"],"mappings":";;;KAaK,WAAA;EACH,CAAA,mBADG;EAGH,QAAA,EAAU,SAAA;AAAA,IACR,OAAA,CAEF,MAAA,CAAO,OAAA,CAAQ,IAAA,CAAK,cAAA,2BAAyC,SAAA;AAAA,KAG1D,gBAAA;EACH,OAAA;EACA,WAAA;AAAA;AAAA,KAGG,mBAAA,GAAsB,WAAA,GAAc,gBAAA"}
@@ -1,2 +1,2 @@
1
- import{getFormatLocales as e}from"../../hooks/utils/getFormatLocales.mjs";import{getPluralBranch as t}from"../../utils/plurals/getPluralBranch.mjs";import{getPluralBranchKey as n,isAcceptedPluralForm as r}from"generaltranslation/internal";function i({_enableI18n:i,_locale:a,n:o,children:s,...c}){return t(o,e({locale:a,enableI18n:i}),Object.fromEntries([...Object.entries(c).filter(([e])=>r(e)).map(([e,t])=>[n(e),t]),[`other`,s]]))}export{i as renderPlural};
1
+ import{getFormatLocales as e}from"../../hooks/utils/getFormatLocales.mjs";import{getPluralBranch as t,isCount as n}from"../../utils/plurals/getPluralBranch.mjs";import{fillCount as r}from"../../utils/plurals/fillCount.mjs";import{getPluralBranchKey as i,isAcceptedPluralForm as a}from"generaltranslation/internal";function o({_enableI18n:o,_locale:s,n:c,children:l,...u}){let d=t(c,e({locale:s,enableI18n:o}),Object.fromEntries([...Object.entries(u).filter(([e])=>a(e)).map(([e,t])=>[i(e),t]),[`other`,l]]));return n(c)?r(d,c):d}export{o as renderPlural};
2
2
  //# sourceMappingURL=Plural.shared.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Plural.shared.mjs","names":[],"sources":["../../../src/components/branches/Plural.shared.ts"],"sourcesContent":["import {\n getPluralBranchKey,\n isAcceptedPluralForm,\n} from 'generaltranslation/internal';\nimport { getPluralBranch } from '../../utils/plurals/getPluralBranch';\nimport type { ReactNode } from 'react';\nimport { getFormatLocales } from '../../hooks/utils/getFormatLocales';\n\n// Pure render logic shared by the hook-based and RSC implementations. This\n// module must stay free of hook/context imports so it can be reached from the\n// components-rsc entrypoint.\n\ntype PluralProps = {\n n: number | bigint;\n /** The fallback, as `other` is in `plural()`. */\n children: ReactNode;\n} & Partial<\n // `_0` is the exact number 0: ICU's `=0`, which JSX cannot spell.\n Record<Exclude<Intl.LDMLPluralRule, 'other'> | `_${number}`, ReactNode>\n>;\n\ntype PluralConditions = {\n _locale: string;\n _enableI18n: boolean;\n};\n\ntype ResolvedPluralProps = PluralProps & PluralConditions;\n\nfunction renderPlural({\n _enableI18n,\n _locale,\n n,\n children,\n ...props\n}: ResolvedPluralProps): ReactNode {\n const locales = getFormatLocales({\n locale: _locale,\n enableI18n: _enableI18n,\n });\n const branches = Object.fromEntries([\n ...Object.entries(props)\n .filter(([prop]) => isAcceptedPluralForm(prop))\n .map(([prop, branch]) => [getPluralBranchKey(prop), branch]),\n ['other', children],\n ]);\n return getPluralBranch(n, locales, branches);\n}\n\nexport { renderPlural };\nexport type { PluralProps, ResolvedPluralProps };\n"],"mappings":"+OA4BA,SAAS,EAAa,CACpB,cACA,UACA,IACA,WACA,GAAG,GAC8B,CAWjC,OAAO,EAAgB,EAVP,EAAiB,CAC/B,OAAQ,EACR,WAAY,EACb,CAOgC,CANhB,OAAO,YAAY,CAClC,GAAG,OAAO,QAAQ,EAAM,CACrB,QAAQ,CAAC,KAAU,EAAqB,EAAK,CAAC,CAC9C,KAAK,CAAC,EAAM,KAAY,CAAC,EAAmB,EAAK,CAAE,EAAO,CAAC,CAC9D,CAAC,QAAS,EAAS,CACpB,CAC0C,CAAC"}
1
+ {"version":3,"file":"Plural.shared.mjs","names":[],"sources":["../../../src/components/branches/Plural.shared.ts"],"sourcesContent":["import {\n getPluralBranchKey,\n isAcceptedPluralForm,\n} from 'generaltranslation/internal';\nimport { getPluralBranch, isCount } from '../../utils/plurals/getPluralBranch';\nimport { fillCount } from '../../utils/plurals/fillCount';\nimport type { ReactNode } from 'react';\nimport { getFormatLocales } from '../../hooks/utils/getFormatLocales';\n\n// Pure render logic shared by the hook-based and RSC implementations. This\n// module must stay free of hook/context imports so it can be reached from the\n// components-rsc entrypoint.\n\ntype PluralProps = {\n n: number | bigint;\n /** The fallback, as `other` is in `plural()`. */\n children: ReactNode;\n} & Partial<\n // `_0` is the exact number 0: ICU's `=0`, which JSX cannot spell.\n Record<Exclude<Intl.LDMLPluralRule, 'other'> | `_${number}`, ReactNode>\n>;\n\ntype PluralConditions = {\n _locale: string;\n _enableI18n: boolean;\n};\n\ntype ResolvedPluralProps = PluralProps & PluralConditions;\n\nfunction renderPlural({\n _enableI18n,\n _locale,\n n,\n children,\n ...props\n}: ResolvedPluralProps): ReactNode {\n const locales = getFormatLocales({\n locale: _locale,\n enableI18n: _enableI18n,\n });\n const branches = Object.fromEntries([\n ...Object.entries(props)\n .filter(([prop]) => isAcceptedPluralForm(prop))\n .map(([prop, branch]) => [getPluralBranchKey(prop), branch]),\n ['other', children],\n ]);\n const branch: ReactNode = getPluralBranch(n, locales, branches);\n // An `n` that is no number is reported where the branch is picked.\n return isCount(n) ? fillCount(branch, n) : branch;\n}\n\nexport { renderPlural };\nexport type { PluralProps, ResolvedPluralProps };\n"],"mappings":"0TA6BA,SAAS,EAAa,CACpB,cACA,UACA,IACA,WACA,GAAG,GAC8B,CAWjC,IAAM,EAAoB,EAAgB,EAV1B,EAAiB,CAC/B,OAAQ,EACR,WAAY,EACb,CAOmD,CANnC,OAAO,YAAY,CAClC,GAAG,OAAO,QAAQ,EAAM,CACrB,QAAQ,CAAC,KAAU,EAAqB,EAAK,CAAC,CAC9C,KAAK,CAAC,EAAM,KAAY,CAAC,EAAmB,EAAK,CAAE,EAAO,CAAC,CAC9D,CAAC,QAAS,EAAS,CACpB,CAC6D,CAAC,CAE/D,OAAO,EAAQ,EAAE,CAAG,EAAU,EAAQ,EAAE,CAAG"}
@@ -0,0 +1,2 @@
1
+ require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../utils/plurals/getPluralBranch.cjs`),t=require(`./Num.cjs`);let n=require(`react/jsx-runtime`);function r({_count:r}){return r===void 0&&e.reportMissingCount(),(0,n.jsx)(t.GtInternalNum,{children:r})}r._gtt=`variable-count`,exports.N=r;
2
+ //# sourceMappingURL=N.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"N.cjs","names":["GtInternalNum"],"sources":["../../../src/components/variables/N.tsx"],"sourcesContent":["import { reportMissingCount } from '../../utils/plurals/getPluralBranch';\nimport { GtInternalNum } from './Num';\nimport type { NProps } from './N.shared';\n\n// ===== Component ===== //\n\n/**\n * The count of the `<Plural>` it is in, formatted as a number, as `#` is in\n * ICU. A translation can show it in any branch of that plural.\n */\nfunction N({ _count }: NProps): React.JSX.Element {\n if (_count === undefined) reportMissingCount();\n return <GtInternalNum>{_count}</GtInternalNum>;\n}\n\n/** @internal _gtt - The GT transformation for the component. */\nN._gtt = 'variable-count';\n\n// ===== Exports ===== //\n\nexport { N };\n"],"mappings":"qKAUA,SAAS,EAAE,CAAE,UAAqC,CAEhD,OADI,IAAW,IAAA,IAAW,EAAA,oBAAoB,EACvC,EAAA,EAAA,KAACA,EAAAA,cAAD,CAAA,SAAgB,EAAuB,CAAA,CAIhD,EAAE,KAAO"}
@@ -0,0 +1,16 @@
1
+ import { NProps } from "./N.shared.js";
2
+
3
+ //#region src/components/variables/N.d.ts
4
+ /**
5
+ * The count of the `<Plural>` it is in, formatted as a number, as `#` is in
6
+ * ICU. A translation can show it in any branch of that plural.
7
+ */
8
+ declare function N({
9
+ _count
10
+ }: NProps): React.JSX.Element;
11
+ declare namespace N {
12
+ var _gtt: string;
13
+ }
14
+ //#endregion
15
+ export { N };
16
+ //# sourceMappingURL=N.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"N.d.ts","names":[],"sources":["../../../src/components/variables/N.tsx"],"mappings":";;;;;AAEyC;;iBAQhC,CAAA,CAAA;EAAI;AAAA,GAAU,MAAA,GAAS,KAAA,CAAM,GAAA,CAAI,OAAA;AAAA,kBAAjC,CAAA;EAAA,IAAC,IAAA;AAAA"}
@@ -0,0 +1,2 @@
1
+ import{reportMissingCount as e}from"../../utils/plurals/getPluralBranch.mjs";import{GtInternalNum as t}from"./Num.mjs";import{jsx as n}from"react/jsx-runtime";function r({_count:r}){return r===void 0&&e(),n(t,{children:r})}r._gtt=`variable-count`;export{r as N};
2
+ //# sourceMappingURL=N.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"N.mjs","names":[],"sources":["../../../src/components/variables/N.tsx"],"sourcesContent":["import { reportMissingCount } from '../../utils/plurals/getPluralBranch';\nimport { GtInternalNum } from './Num';\nimport type { NProps } from './N.shared';\n\n// ===== Component ===== //\n\n/**\n * The count of the `<Plural>` it is in, formatted as a number, as `#` is in\n * ICU. A translation can show it in any branch of that plural.\n */\nfunction N({ _count }: NProps): React.JSX.Element {\n if (_count === undefined) reportMissingCount();\n return <GtInternalNum>{_count}</GtInternalNum>;\n}\n\n/** @internal _gtt - The GT transformation for the component. */\nN._gtt = 'variable-count';\n\n// ===== Exports ===== //\n\nexport { N };\n"],"mappings":"+JAUA,SAAS,EAAE,CAAE,UAAqC,CAEhD,OADI,IAAW,IAAA,IAAW,GAAoB,CACvC,EAAC,EAAD,CAAA,SAAgB,EAAuB,CAAA,CAIhD,EAAE,KAAO"}
@@ -0,0 +1,2 @@
1
+ require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../utils/plurals/getPluralBranch.cjs`),t=require(`./Num.rsc.cjs`);let n=require(`react/jsx-runtime`);function r({_count:r,...i}){return r===void 0&&e.reportMissingCount(),(0,n.jsx)(t.RscGtInternalNum,{...i,children:r})}r._gtt=`variable-count`,exports.RscN=r;
2
+ //# sourceMappingURL=N.rsc.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"N.rsc.cjs","names":["RscGtInternalNum"],"sources":["../../../src/components/variables/N.rsc.tsx"],"sourcesContent":["import { reportMissingCount } from '../../utils/plurals/getPluralBranch';\nimport { RscGtInternalNum } from './Num.rsc';\nimport type { ResolvedNProps } from './N.shared';\n\n// RSC implementation: request conditions are passed explicitly instead of\n// being read from hooks. This module must stay free of hook/context imports\n// so it can be exported from the components-rsc entrypoint.\n\nfunction RscN({ _count, ...conditions }: ResolvedNProps): React.JSX.Element {\n if (_count === undefined) reportMissingCount();\n return <RscGtInternalNum {...conditions}>{_count}</RscGtInternalNum>;\n}\n\n/** @internal _gtt - The GT transformation for the component. */\nRscN._gtt = 'variable-count';\n\n// ===== Exports ===== //\n\nexport { RscN };\n"],"mappings":"yKAQA,SAAS,EAAK,CAAE,SAAQ,GAAG,GAAiD,CAE1E,OADI,IAAW,IAAA,IAAW,EAAA,oBAAoB,EACvC,EAAA,EAAA,KAACA,EAAAA,iBAAD,CAAkB,GAAI,WAAa,EAA0B,CAAA,CAItE,EAAK,KAAO"}
@@ -0,0 +1,13 @@
1
+ import { ResolvedNProps } from "./N.shared.js";
2
+
3
+ //#region src/components/variables/N.rsc.d.ts
4
+ declare function RscN({
5
+ _count,
6
+ ...conditions
7
+ }: ResolvedNProps): React.JSX.Element;
8
+ declare namespace RscN {
9
+ var _gtt: string;
10
+ }
11
+ //#endregion
12
+ export { RscN };
13
+ //# sourceMappingURL=N.rsc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"N.rsc.d.ts","names":[],"sources":["../../../src/components/variables/N.rsc.tsx"],"mappings":";;;iBAQS,IAAA,CAAA;EAAO,MAAA;EAAA,GAAW;AAAA,GAAc,cAAA,GAAiB,KAAA,CAAM,GAAA,CAAI,OAAA;AAAA,kBAA3D,IAAA;EAAA,IAAI,IAAA;AAAA"}
@@ -0,0 +1,2 @@
1
+ import{reportMissingCount as e}from"../../utils/plurals/getPluralBranch.mjs";import{RscGtInternalNum as t}from"./Num.rsc.mjs";import{jsx as n}from"react/jsx-runtime";function r({_count:r,...i}){return r===void 0&&e(),n(t,{...i,children:r})}r._gtt=`variable-count`;export{r as RscN};
2
+ //# sourceMappingURL=N.rsc.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"N.rsc.mjs","names":[],"sources":["../../../src/components/variables/N.rsc.tsx"],"sourcesContent":["import { reportMissingCount } from '../../utils/plurals/getPluralBranch';\nimport { RscGtInternalNum } from './Num.rsc';\nimport type { ResolvedNProps } from './N.shared';\n\n// RSC implementation: request conditions are passed explicitly instead of\n// being read from hooks. This module must stay free of hook/context imports\n// so it can be exported from the components-rsc entrypoint.\n\nfunction RscN({ _count, ...conditions }: ResolvedNProps): React.JSX.Element {\n if (_count === undefined) reportMissingCount();\n return <RscGtInternalNum {...conditions}>{_count}</RscGtInternalNum>;\n}\n\n/** @internal _gtt - The GT transformation for the component. */\nRscN._gtt = 'variable-count';\n\n// ===== Exports ===== //\n\nexport { RscN };\n"],"mappings":"sKAQA,SAAS,EAAK,CAAE,SAAQ,GAAG,GAAiD,CAE1E,OADI,IAAW,IAAA,IAAW,GAAoB,CACvC,EAAC,EAAD,CAAkB,GAAI,WAAa,EAA0B,CAAA,CAItE,EAAK,KAAO"}
@@ -0,0 +1,11 @@
1
+ //#region src/components/variables/N.shared.d.ts
2
+ type NProps = {
3
+ /** @internal The count, which the `<Plural>` it is in gives it. */_count?: number | bigint;
4
+ };
5
+ type ResolvedNProps = NProps & {
6
+ _locale: string;
7
+ _enableI18n: boolean;
8
+ };
9
+ //#endregion
10
+ export { type NProps, type ResolvedNProps };
11
+ //# sourceMappingURL=N.shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"N.shared.d.ts","names":[],"sources":["../../../src/components/variables/N.shared.ts"],"mappings":";KACK,MAAA;EAAA,mEAEH,MAAA;AAAA;AAAA,KAGG,cAAA,GAAiB,MAAA;EACpB,OAAA;EACA,WAAA;AAAA"}
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./hooks/utils/getShouldTranslate.cjs`),t=require(`./utils/rendering/createRenderVariable.cjs`),n=require(`./utils/plurals/getPluralBranch.cjs`),r=require(`./components/branches/Branch.cjs`),i=require(`./components/derivation/Derive.cjs`),a=require(`./components/variables/Currency.rsc.cjs`),o=require(`./components/variables/DateTime.rsc.cjs`),s=require(`./components/variables/Num.rsc.cjs`),c=require(`./components/variables/RelativeTime.rsc.cjs`),l=require(`./components/variables/Var.cjs`),u=require(`./utils/rendering/renderPipeline.rsc.cjs`),d=require(`./utils/translation/prepareT.shared.cjs`),f=require(`./components/branches/Plural.rsc.cjs`),p=require(`./components/translation/T.rsc.cjs`),m=require(`./components/translation/Tx.rsc.cjs`);exports.Branch=r.Branch,exports.Currency=a.RscCurrency,exports.DateTime=o.RscDateTime,exports.Derive=i.Derive,exports.GtInternalBranch=r.GtInternalBranch,exports.GtInternalCurrency=a.RscGtInternalCurrency,exports.GtInternalDateTime=o.RscGtInternalDateTime,exports.GtInternalDerive=i.GtInternalDerive,exports.GtInternalNum=s.RscGtInternalNum,exports.GtInternalPlural=f.RscGtInternalPlural,exports.GtInternalRelativeTime=c.RscGtInternalRelativeTime,exports.GtInternalVar=l.GtInternalVar,exports.Num=s.RscNum,exports.Plural=f.RscPlural,exports.RelativeTime=c.RscRelativeTime,exports.T=p.RscT,exports.Tx=m.RscTx,exports.Var=l.Var,exports.createRenderVariable=t.createRenderVariable,exports.getPluralBranch=n.getPluralBranch,exports.getShouldTranslate=e.getShouldTranslate,exports.prepareT=d.prepareT,exports.renderDefaultChildren=u.renderDefaultChildren,exports.renderPreparedT=u.renderPreparedT,exports.renderTranslatedChildren=u.renderTranslatedChildren,exports.renderVariable=u.renderVariable;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./utils/rendering/createRenderVariable.cjs`),t=require(`./utils/plurals/getPluralBranch.cjs`),n=require(`./components/branches/Branch.cjs`),r=require(`./components/derivation/Derive.cjs`),i=require(`./components/variables/Currency.rsc.cjs`),a=require(`./components/variables/DateTime.rsc.cjs`),o=require(`./components/variables/Num.rsc.cjs`),s=require(`./components/variables/RelativeTime.rsc.cjs`),c=require(`./components/variables/Var.cjs`),l=require(`./utils/rendering/renderPipeline.rsc.cjs`),u=require(`./utils/translation/prepareT.shared.cjs`),d=require(`./components/branches/Plural.rsc.cjs`),f=require(`./components/variables/N.rsc.cjs`),p=require(`./components/translation/T.rsc.cjs`),m=require(`./components/translation/Tx.rsc.cjs`),h=require(`./hooks/utils/getShouldTranslate.cjs`);exports.Branch=n.Branch,exports.Currency=i.RscCurrency,exports.DateTime=a.RscDateTime,exports.Derive=r.Derive,exports.GtInternalBranch=n.GtInternalBranch,exports.GtInternalCurrency=i.RscGtInternalCurrency,exports.GtInternalDateTime=a.RscGtInternalDateTime,exports.GtInternalDerive=r.GtInternalDerive,exports.GtInternalNum=o.RscGtInternalNum,exports.GtInternalPlural=d.RscGtInternalPlural,exports.GtInternalRelativeTime=s.RscGtInternalRelativeTime,exports.GtInternalVar=c.GtInternalVar,exports.N=f.RscN,exports.Num=o.RscNum,exports.Plural=d.RscPlural,exports.RelativeTime=s.RscRelativeTime,exports.T=p.RscT,exports.Tx=m.RscTx,exports.Var=c.Var,exports.createRenderVariable=e.createRenderVariable,exports.getPluralBranch=t.getPluralBranch,exports.getShouldTranslate=h.getShouldTranslate,exports.prepareT=u.prepareT,exports.renderDefaultChildren=l.renderDefaultChildren,exports.renderPreparedT=l.renderPreparedT,exports.renderTranslatedChildren=l.renderTranslatedChildren,exports.renderVariable=l.renderVariable;
@@ -7,6 +7,8 @@ import { CurrencyProps, ResolvedCurrencyProps } from "./components/variables/Cur
7
7
  import { RscCurrency, RscGtInternalCurrency } from "./components/variables/Currency.rsc.js";
8
8
  import { DateTimeProps, ResolvedDateTimeProps } from "./components/variables/DateTime.shared.js";
9
9
  import { RscDateTime, RscGtInternalDateTime } from "./components/variables/DateTime.rsc.js";
10
+ import { NProps, ResolvedNProps } from "./components/variables/N.shared.js";
11
+ import { RscN } from "./components/variables/N.rsc.js";
10
12
  import { NumProps, ResolvedNumProps } from "./components/variables/Num.shared.js";
11
13
  import { RscGtInternalNum, RscNum } from "./components/variables/Num.rsc.js";
12
14
  import { RelativeTimeProps, ResolvedRelativeTimeProps } from "./components/variables/RelativeTime.shared.js";
@@ -18,4 +20,4 @@ import { getPluralBranch } from "./utils/plurals/getPluralBranch.js";
18
20
  import { getShouldTranslate } from "./hooks/utils/getShouldTranslate.js";
19
21
  import { createRenderVariable } from "./utils/rendering/createRenderVariable.js";
20
22
  import { renderDefaultChildren, renderPreparedT, renderTranslatedChildren, renderVariable } from "./utils/rendering/renderPipeline.rsc.js";
21
- export { Branch, type BranchProps, RscCurrency as Currency, type CurrencyProps, RscDateTime as DateTime, type DateTimeProps, Derive, GtInternalBranch, RscGtInternalCurrency as GtInternalCurrency, RscGtInternalDateTime as GtInternalDateTime, GtInternalDerive, RscGtInternalNum as GtInternalNum, RscGtInternalPlural as GtInternalPlural, RscGtInternalRelativeTime as GtInternalRelativeTime, GtInternalVar, type JsxTranslationOptions, RscNum as Num, type NumProps, RscPlural as Plural, type PluralProps, type PreparedT, RscRelativeTime as RelativeTime, type RelativeTimeProps, type ResolvedCurrencyProps, type ResolvedDateTimeProps, type ResolvedNumProps, type ResolvedPluralProps, type ResolvedRelativeTimeProps, RscT as T, type TProps, RscTx as Tx, Var, createRenderVariable, getPluralBranch, getShouldTranslate, prepareT, renderDefaultChildren, renderPreparedT, renderTranslatedChildren, renderVariable };
23
+ export { Branch, type BranchProps, RscCurrency as Currency, type CurrencyProps, RscDateTime as DateTime, type DateTimeProps, Derive, GtInternalBranch, RscGtInternalCurrency as GtInternalCurrency, RscGtInternalDateTime as GtInternalDateTime, GtInternalDerive, RscGtInternalNum as GtInternalNum, RscGtInternalPlural as GtInternalPlural, RscGtInternalRelativeTime as GtInternalRelativeTime, GtInternalVar, type JsxTranslationOptions, RscN as N, type NProps, RscNum as Num, type NumProps, RscPlural as Plural, type PluralProps, type PreparedT, RscRelativeTime as RelativeTime, type RelativeTimeProps, type ResolvedCurrencyProps, type ResolvedDateTimeProps, type ResolvedNProps, type ResolvedNumProps, type ResolvedPluralProps, type ResolvedRelativeTimeProps, RscT as T, type TProps, RscTx as Tx, Var, createRenderVariable, getPluralBranch, getShouldTranslate, prepareT, renderDefaultChildren, renderPreparedT, renderTranslatedChildren, renderVariable };
@@ -1 +1 @@
1
- import{getShouldTranslate as e}from"./hooks/utils/getShouldTranslate.mjs";import{createRenderVariable as t}from"./utils/rendering/createRenderVariable.mjs";import{getPluralBranch as n}from"./utils/plurals/getPluralBranch.mjs";import{Branch as r,GtInternalBranch as i}from"./components/branches/Branch.mjs";import{Derive as a,GtInternalDerive as o}from"./components/derivation/Derive.mjs";import{RscCurrency as s,RscGtInternalCurrency as c}from"./components/variables/Currency.rsc.mjs";import{RscDateTime as l,RscGtInternalDateTime as u}from"./components/variables/DateTime.rsc.mjs";import{RscGtInternalNum as d,RscNum as f}from"./components/variables/Num.rsc.mjs";import{RscGtInternalRelativeTime as p,RscRelativeTime as m}from"./components/variables/RelativeTime.rsc.mjs";import{GtInternalVar as h,Var as g}from"./components/variables/Var.mjs";import{renderDefaultChildren as _,renderPreparedT as v,renderTranslatedChildren as y,renderVariable as b}from"./utils/rendering/renderPipeline.rsc.mjs";import{prepareT as x}from"./utils/translation/prepareT.shared.mjs";import{RscGtInternalPlural as S,RscPlural as C}from"./components/branches/Plural.rsc.mjs";import{RscT as w}from"./components/translation/T.rsc.mjs";import{RscTx as T}from"./components/translation/Tx.rsc.mjs";export{r as Branch,s as Currency,l as DateTime,a as Derive,i as GtInternalBranch,c as GtInternalCurrency,u as GtInternalDateTime,o as GtInternalDerive,d as GtInternalNum,S as GtInternalPlural,p as GtInternalRelativeTime,h as GtInternalVar,f as Num,C as Plural,m as RelativeTime,w as T,T as Tx,g as Var,t as createRenderVariable,n as getPluralBranch,e as getShouldTranslate,x as prepareT,_ as renderDefaultChildren,v as renderPreparedT,y as renderTranslatedChildren,b as renderVariable};
1
+ import{createRenderVariable as e}from"./utils/rendering/createRenderVariable.mjs";import{getPluralBranch as t}from"./utils/plurals/getPluralBranch.mjs";import{Branch as n,GtInternalBranch as r}from"./components/branches/Branch.mjs";import{Derive as i,GtInternalDerive as a}from"./components/derivation/Derive.mjs";import{RscCurrency as o,RscGtInternalCurrency as s}from"./components/variables/Currency.rsc.mjs";import{RscDateTime as c,RscGtInternalDateTime as l}from"./components/variables/DateTime.rsc.mjs";import{RscGtInternalNum as u,RscNum as d}from"./components/variables/Num.rsc.mjs";import{RscGtInternalRelativeTime as f,RscRelativeTime as p}from"./components/variables/RelativeTime.rsc.mjs";import{GtInternalVar as m,Var as h}from"./components/variables/Var.mjs";import{renderDefaultChildren as g,renderPreparedT as _,renderTranslatedChildren as v,renderVariable as y}from"./utils/rendering/renderPipeline.rsc.mjs";import{prepareT as b}from"./utils/translation/prepareT.shared.mjs";import{RscGtInternalPlural as x,RscPlural as S}from"./components/branches/Plural.rsc.mjs";import{RscN as C}from"./components/variables/N.rsc.mjs";import{RscT as w}from"./components/translation/T.rsc.mjs";import{RscTx as T}from"./components/translation/Tx.rsc.mjs";import{getShouldTranslate as E}from"./hooks/utils/getShouldTranslate.mjs";export{n as Branch,o as Currency,c as DateTime,i as Derive,r as GtInternalBranch,s as GtInternalCurrency,l as GtInternalDateTime,a as GtInternalDerive,u as GtInternalNum,x as GtInternalPlural,f as GtInternalRelativeTime,m as GtInternalVar,C as N,d as Num,S as Plural,p as RelativeTime,w as T,T as Tx,h as Var,e as createRenderVariable,t as getPluralBranch,E as getShouldTranslate,b as prepareT,g as renderDefaultChildren,_ as renderPreparedT,v as renderTranslatedChildren,y as renderVariable};
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./components/branches/Branch.cjs`),t=require(`./components/branches/Plural.cjs`),n=require(`./components/derivation/Derive.cjs`),r=require(`./components/variables/Var.cjs`),i=require(`./components/translation/T.cjs`),a=require(`./components/variables/Currency.cjs`),o=require(`./components/variables/DateTime.cjs`),s=require(`./components/variables/Num.cjs`),c=require(`./components/variables/RelativeTime.cjs`),l=require(`./components/helpers/InternalLocaleSelector.cjs`),u=require(`./components/helpers/InternalRegionSelector.cjs`),d=require(`./context/InternalGTProvider.cjs`);exports.Branch=e.Branch,exports.Currency=a.Currency,exports.DateTime=o.DateTime,exports.Derive=n.Derive,exports.GtInternalBranch=e.GtInternalBranch,exports.GtInternalCurrency=a.GtInternalCurrency,exports.GtInternalDateTime=o.GtInternalDateTime,exports.GtInternalDerive=n.GtInternalDerive,exports.GtInternalNum=s.GtInternalNum,exports.GtInternalPlural=t.GtInternalPlural,exports.GtInternalRelativeTime=c.GtInternalRelativeTime,exports.GtInternalTranslateJsx=i.GtInternalTranslateJsx,exports.GtInternalVar=r.GtInternalVar,exports.InternalGTProvider=d.InternalGTProvider,exports.InternalLocaleSelector=l.InternalLocaleSelector,exports.InternalRegionSelector=u.InternalRegionSelector,exports.Num=s.Num,exports.Plural=t.Plural,exports.RelativeTime=c.RelativeTime,exports.T=i.T,exports.Var=r.Var;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./components/branches/Branch.cjs`),t=require(`./components/branches/Plural.cjs`),n=require(`./components/derivation/Derive.cjs`),r=require(`./components/variables/Var.cjs`),i=require(`./components/translation/T.cjs`),a=require(`./components/variables/Currency.cjs`),o=require(`./components/variables/DateTime.cjs`),s=require(`./components/variables/Num.cjs`),c=require(`./components/variables/N.cjs`),l=require(`./components/variables/RelativeTime.cjs`),u=require(`./components/helpers/InternalLocaleSelector.cjs`),d=require(`./components/helpers/InternalRegionSelector.cjs`),f=require(`./context/InternalGTProvider.cjs`);exports.Branch=e.Branch,exports.Currency=a.Currency,exports.DateTime=o.DateTime,exports.Derive=n.Derive,exports.GtInternalBranch=e.GtInternalBranch,exports.GtInternalCurrency=a.GtInternalCurrency,exports.GtInternalDateTime=o.GtInternalDateTime,exports.GtInternalDerive=n.GtInternalDerive,exports.GtInternalNum=s.GtInternalNum,exports.GtInternalPlural=t.GtInternalPlural,exports.GtInternalRelativeTime=l.GtInternalRelativeTime,exports.GtInternalTranslateJsx=i.GtInternalTranslateJsx,exports.GtInternalVar=r.GtInternalVar,exports.InternalGTProvider=f.InternalGTProvider,exports.InternalLocaleSelector=u.InternalLocaleSelector,exports.InternalRegionSelector=d.InternalRegionSelector,exports.N=c.N,exports.Num=s.Num,exports.Plural=t.Plural,exports.RelativeTime=l.RelativeTime,exports.T=i.T,exports.Var=r.Var;
@@ -5,9 +5,10 @@ import { GtInternalPlural, Plural } from "./components/branches/Plural.js";
5
5
  import { GtInternalTranslateJsx, T } from "./components/translation/T.js";
6
6
  import { Currency, GtInternalCurrency } from "./components/variables/Currency.js";
7
7
  import { DateTime, GtInternalDateTime } from "./components/variables/DateTime.js";
8
+ import { N } from "./components/variables/N.js";
8
9
  import { GtInternalNum, Num } from "./components/variables/Num.js";
9
10
  import { GtInternalRelativeTime, RelativeTime } from "./components/variables/RelativeTime.js";
10
11
  import { InternalLocaleSelector } from "./components/helpers/InternalLocaleSelector.js";
11
12
  import { InternalRegionSelector } from "./components/helpers/InternalRegionSelector.js";
12
13
  import { InternalGTProvider, InternalGTProviderProps } from "./context/InternalGTProvider.js";
13
- export { Branch, Currency, DateTime, Derive, GtInternalBranch, GtInternalCurrency, GtInternalDateTime, GtInternalDerive, GtInternalNum, GtInternalPlural, GtInternalRelativeTime, GtInternalTranslateJsx, GtInternalVar, InternalGTProvider, type InternalGTProviderProps, InternalLocaleSelector, InternalRegionSelector, Num, Plural, RelativeTime, T, Var };
14
+ export { Branch, Currency, DateTime, Derive, GtInternalBranch, GtInternalCurrency, GtInternalDateTime, GtInternalDerive, GtInternalNum, GtInternalPlural, GtInternalRelativeTime, GtInternalTranslateJsx, GtInternalVar, InternalGTProvider, type InternalGTProviderProps, InternalLocaleSelector, InternalRegionSelector, N, Num, Plural, RelativeTime, T, Var };
@@ -1 +1 @@
1
- import{Branch as e,GtInternalBranch as t}from"./components/branches/Branch.mjs";import{GtInternalPlural as n,Plural as r}from"./components/branches/Plural.mjs";import{Derive as i,GtInternalDerive as a}from"./components/derivation/Derive.mjs";import{GtInternalVar as o,Var as s}from"./components/variables/Var.mjs";import{GtInternalTranslateJsx as c,T as l}from"./components/translation/T.mjs";import{Currency as u,GtInternalCurrency as d}from"./components/variables/Currency.mjs";import{DateTime as f,GtInternalDateTime as p}from"./components/variables/DateTime.mjs";import{GtInternalNum as m,Num as h}from"./components/variables/Num.mjs";import{GtInternalRelativeTime as g,RelativeTime as _}from"./components/variables/RelativeTime.mjs";import{InternalLocaleSelector as v}from"./components/helpers/InternalLocaleSelector.mjs";import{InternalRegionSelector as y}from"./components/helpers/InternalRegionSelector.mjs";import{InternalGTProvider as b}from"./context/InternalGTProvider.mjs";export{e as Branch,u as Currency,f as DateTime,i as Derive,t as GtInternalBranch,d as GtInternalCurrency,p as GtInternalDateTime,a as GtInternalDerive,m as GtInternalNum,n as GtInternalPlural,g as GtInternalRelativeTime,c as GtInternalTranslateJsx,o as GtInternalVar,b as InternalGTProvider,v as InternalLocaleSelector,y as InternalRegionSelector,h as Num,r as Plural,_ as RelativeTime,l as T,s as Var};
1
+ import{Branch as e,GtInternalBranch as t}from"./components/branches/Branch.mjs";import{GtInternalPlural as n,Plural as r}from"./components/branches/Plural.mjs";import{Derive as i,GtInternalDerive as a}from"./components/derivation/Derive.mjs";import{GtInternalVar as o,Var as s}from"./components/variables/Var.mjs";import{GtInternalTranslateJsx as c,T as l}from"./components/translation/T.mjs";import{Currency as u,GtInternalCurrency as d}from"./components/variables/Currency.mjs";import{DateTime as f,GtInternalDateTime as p}from"./components/variables/DateTime.mjs";import{GtInternalNum as m,Num as h}from"./components/variables/Num.mjs";import{N as g}from"./components/variables/N.mjs";import{GtInternalRelativeTime as _,RelativeTime as v}from"./components/variables/RelativeTime.mjs";import{InternalLocaleSelector as y}from"./components/helpers/InternalLocaleSelector.mjs";import{InternalRegionSelector as b}from"./components/helpers/InternalRegionSelector.mjs";import{InternalGTProvider as x}from"./context/InternalGTProvider.mjs";export{e as Branch,u as Currency,f as DateTime,i as Derive,t as GtInternalBranch,d as GtInternalCurrency,p as GtInternalDateTime,a as GtInternalDerive,m as GtInternalNum,n as GtInternalPlural,_ as GtInternalRelativeTime,c as GtInternalTranslateJsx,o as GtInternalVar,x as InternalGTProvider,y as InternalLocaleSelector,b as InternalRegionSelector,g as N,h as Num,r as Plural,v as RelativeTime,l as T,s as Var};
@@ -1,2 +1,2 @@
1
- require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../i18n-cache/singleton-operations.cjs`);let t=require(`generaltranslation/diagnostics`);async function n(n){let r=e.getReactI18nCache();try{return{[n]:await r.loadTranslations(n)}}catch(e){return console.warn((0,t.createDiagnosticMessage)({source:`@generaltranslation/react-core`,severity:`Warning`,whatHappened:`Could not load translations for locale "${n}", so content for this locale renders untranslated`,why:`the translation loader failed, usually because translations for this locale have not been generated yet`,fix:`Generate translations for this locale, or check your loadTranslations configuration.`,details:(0,t.formatDiagnosticErrorDetails)(e)})),{}}}exports.getTranslationsSnapshot=n;
1
+ require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../i18n-cache/singleton-operations.cjs`);let t=require(`generaltranslation/diagnostics`);async function n(t){let n=e.getReactI18nCache();try{return{[t]:await n.loadTranslations(t)}}catch(e){return console.warn(i(t,e)),{}}}async function r(t){try{await e.getReactI18nCache().getLookupTranslation(t)}catch(e){console.warn(i(t,e))}}function i(e,n){return(0,t.createDiagnosticMessage)({source:`@generaltranslation/react-core`,severity:`Warning`,whatHappened:`Could not load translations for locale "${e}", so content for this locale renders untranslated`,why:`the translation loader failed, usually because translations for this locale have not been generated yet`,fix:`Generate translations for this locale, or check your loadTranslations configuration.`,details:(0,t.formatDiagnosticErrorDetails)(n)})}exports.getTranslationsSnapshot=n,exports.preloadTranslations=r;
2
2
  //# sourceMappingURL=getTranslationsSnapshot.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getTranslationsSnapshot.cjs","names":["getReactI18nCache"],"sources":["../../../src/functions/helpers/getTranslationsSnapshot.ts"],"sourcesContent":["import { Hash, Locale } from 'gt-i18n/internal';\nimport type { Content } from '@generaltranslation/format';\nimport {\n createDiagnosticMessage,\n formatDiagnosticErrorDetails,\n} from 'generaltranslation/diagnostics';\nimport { getReactI18nCache } from '../../i18n-cache/singleton-operations';\n\n/**\n * Serializable cached translations for provider hydration; a failed load\n * yields a snapshot with no entry for the locale, so hydration caches nothing\n * and a later lookup retries. TODO: perhaps move to /i18n for type generics\n */\nexport async function getTranslationsSnapshot(\n locale: Locale\n): Promise<Record<Locale, Record<Hash, Content>>> {\n const i18nCache = getReactI18nCache();\n try {\n return { [locale]: await i18nCache.loadTranslations(locale) };\n } catch (error) {\n console.warn(\n createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Warning',\n whatHappened: `Could not load translations for locale \"${locale}\", so content for this locale renders untranslated`,\n why: 'the translation loader failed, usually because translations for this locale have not been generated yet',\n fix: 'Generate translations for this locale, or check your loadTranslations configuration.',\n details: formatDiagnosticErrorDetails(error),\n })\n );\n return {};\n }\n}\n"],"mappings":"6JAaA,eAAsB,EACpB,EACgD,CAChD,IAAM,EAAYA,EAAAA,mBAAmB,CACrC,GAAI,CACF,MAAO,EAAG,GAAS,MAAM,EAAU,iBAAiB,EAAO,CAAE,OACtD,EAAO,CAWd,OAVA,QAAQ,MAAA,EAAA,EAAA,yBACkB,CACtB,OAAQ,iCACR,SAAU,UACV,aAAc,2CAA2C,EAAO,oDAChE,IAAK,0GACL,IAAK,uFACL,SAAA,EAAA,EAAA,8BAAsC,EAAM,CAC7C,CAAC,CACH,CACM,EAAE"}
1
+ {"version":3,"file":"getTranslationsSnapshot.cjs","names":["getReactI18nCache"],"sources":["../../../src/functions/helpers/getTranslationsSnapshot.ts"],"sourcesContent":["import { Hash, Locale } from 'gt-i18n/internal';\nimport type { Content } from '@generaltranslation/format';\nimport {\n createDiagnosticMessage,\n formatDiagnosticErrorDetails,\n} from 'generaltranslation/diagnostics';\nimport { getReactI18nCache } from '../../i18n-cache/singleton-operations';\n\n/**\n * Serializable cached translations for provider hydration; a failed load\n * yields a snapshot with no entry for the locale, so hydration caches nothing\n * and a later lookup retries. TODO: perhaps move to /i18n for type generics\n */\nexport async function getTranslationsSnapshot(\n locale: Locale\n): Promise<Record<Locale, Record<Hash, Content>>> {\n const i18nCache = getReactI18nCache();\n try {\n return { [locale]: await i18nCache.loadTranslations(locale) };\n } catch (error) {\n console.warn(createLoadWarning(locale, error));\n return {};\n }\n}\n\n/**\n * Loads a locale's translations into the cache and copies nothing out, for a\n * caller that only waits for them. A failed load warns like\n * getTranslationsSnapshot, and a later lookup retries.\n */\nexport async function preloadTranslations(locale: Locale): Promise<void> {\n try {\n await getReactI18nCache().getLookupTranslation(locale);\n } catch (error) {\n console.warn(createLoadWarning(locale, error));\n }\n}\n\nfunction createLoadWarning(locale: Locale, error: unknown): string {\n return createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Warning',\n whatHappened: `Could not load translations for locale \"${locale}\", so content for this locale renders untranslated`,\n why: 'the translation loader failed, usually because translations for this locale have not been generated yet',\n fix: 'Generate translations for this locale, or check your loadTranslations configuration.',\n details: formatDiagnosticErrorDetails(error),\n });\n}\n"],"mappings":"6JAaA,eAAsB,EACpB,EACgD,CAChD,IAAM,EAAYA,EAAAA,mBAAmB,CACrC,GAAI,CACF,MAAO,EAAG,GAAS,MAAM,EAAU,iBAAiB,EAAO,CAAE,OACtD,EAAO,CAEd,OADA,QAAQ,KAAK,EAAkB,EAAQ,EAAM,CAAC,CACvC,EAAE,EASb,eAAsB,EAAoB,EAA+B,CACvE,GAAI,CACF,MAAMA,EAAAA,mBAAmB,CAAC,qBAAqB,EAAO,OAC/C,EAAO,CACd,QAAQ,KAAK,EAAkB,EAAQ,EAAM,CAAC,EAIlD,SAAS,EAAkB,EAAgB,EAAwB,CACjE,OAAA,EAAA,EAAA,yBAA+B,CAC7B,OAAQ,iCACR,SAAU,UACV,aAAc,2CAA2C,EAAO,oDAChE,IAAK,0GACL,IAAK,uFACL,SAAA,EAAA,EAAA,8BAAsC,EAAM,CAC7C,CAAC"}
@@ -8,6 +8,12 @@ import { Content } from "@generaltranslation/format";
8
8
  * and a later lookup retries. TODO: perhaps move to /i18n for type generics
9
9
  */
10
10
  declare function getTranslationsSnapshot(locale: Locale): Promise<Record<Locale, Record<Hash, Content>>>;
11
+ /**
12
+ * Loads a locale's translations into the cache and copies nothing out, for a
13
+ * caller that only waits for them. A failed load warns like
14
+ * getTranslationsSnapshot, and a later lookup retries.
15
+ */
16
+ declare function preloadTranslations(locale: Locale): Promise<void>;
11
17
  //#endregion
12
- export { getTranslationsSnapshot };
18
+ export { getTranslationsSnapshot, preloadTranslations };
13
19
  //# sourceMappingURL=getTranslationsSnapshot.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getTranslationsSnapshot.d.ts","names":[],"sources":["../../../src/functions/helpers/getTranslationsSnapshot.ts"],"mappings":";;;;;;AAaA;;;iBAAsB,uBAAA,CACpB,MAAA,EAAQ,MAAA,GACP,OAAA,CAAQ,MAAA,CAAO,MAAA,EAAQ,MAAA,CAAO,IAAA,EAAM,OAAA"}
1
+ {"version":3,"file":"getTranslationsSnapshot.d.ts","names":[],"sources":["../../../src/functions/helpers/getTranslationsSnapshot.ts"],"mappings":";;;;;;AAaA;;;iBAAsB,uBAAA,CACpB,MAAA,EAAQ,MAAA,GACP,OAAA,CAAQ,MAAA,CAAO,MAAA,EAAQ,MAAA,CAAO,IAAA,EAAM,OAAA;;;;;;iBAejB,mBAAA,CAAoB,MAAA,EAAQ,MAAA,GAAS,OAAA"}
@@ -1,2 +1,2 @@
1
- import{getReactI18nCache as e}from"../../i18n-cache/singleton-operations.mjs";import{createDiagnosticMessage as t,formatDiagnosticErrorDetails as n}from"generaltranslation/diagnostics";async function r(r){let i=e();try{return{[r]:await i.loadTranslations(r)}}catch(e){return console.warn(t({source:`@generaltranslation/react-core`,severity:`Warning`,whatHappened:`Could not load translations for locale "${r}", so content for this locale renders untranslated`,why:`the translation loader failed, usually because translations for this locale have not been generated yet`,fix:`Generate translations for this locale, or check your loadTranslations configuration.`,details:n(e)})),{}}}export{r as getTranslationsSnapshot};
1
+ import{getReactI18nCache as e}from"../../i18n-cache/singleton-operations.mjs";import{createDiagnosticMessage as t,formatDiagnosticErrorDetails as n}from"generaltranslation/diagnostics";async function r(t){let n=e();try{return{[t]:await n.loadTranslations(t)}}catch(e){return console.warn(a(t,e)),{}}}async function i(t){try{await e().getLookupTranslation(t)}catch(e){console.warn(a(t,e))}}function a(e,r){return t({source:`@generaltranslation/react-core`,severity:`Warning`,whatHappened:`Could not load translations for locale "${e}", so content for this locale renders untranslated`,why:`the translation loader failed, usually because translations for this locale have not been generated yet`,fix:`Generate translations for this locale, or check your loadTranslations configuration.`,details:n(r)})}export{r as getTranslationsSnapshot,i as preloadTranslations};
2
2
  //# sourceMappingURL=getTranslationsSnapshot.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getTranslationsSnapshot.mjs","names":[],"sources":["../../../src/functions/helpers/getTranslationsSnapshot.ts"],"sourcesContent":["import { Hash, Locale } from 'gt-i18n/internal';\nimport type { Content } from '@generaltranslation/format';\nimport {\n createDiagnosticMessage,\n formatDiagnosticErrorDetails,\n} from 'generaltranslation/diagnostics';\nimport { getReactI18nCache } from '../../i18n-cache/singleton-operations';\n\n/**\n * Serializable cached translations for provider hydration; a failed load\n * yields a snapshot with no entry for the locale, so hydration caches nothing\n * and a later lookup retries. TODO: perhaps move to /i18n for type generics\n */\nexport async function getTranslationsSnapshot(\n locale: Locale\n): Promise<Record<Locale, Record<Hash, Content>>> {\n const i18nCache = getReactI18nCache();\n try {\n return { [locale]: await i18nCache.loadTranslations(locale) };\n } catch (error) {\n console.warn(\n createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Warning',\n whatHappened: `Could not load translations for locale \"${locale}\", so content for this locale renders untranslated`,\n why: 'the translation loader failed, usually because translations for this locale have not been generated yet',\n fix: 'Generate translations for this locale, or check your loadTranslations configuration.',\n details: formatDiagnosticErrorDetails(error),\n })\n );\n return {};\n }\n}\n"],"mappings":"yLAaA,eAAsB,EACpB,EACgD,CAChD,IAAM,EAAY,GAAmB,CACrC,GAAI,CACF,MAAO,EAAG,GAAS,MAAM,EAAU,iBAAiB,EAAO,CAAE,OACtD,EAAO,CAWd,OAVA,QAAQ,KACN,EAAwB,CACtB,OAAQ,iCACR,SAAU,UACV,aAAc,2CAA2C,EAAO,oDAChE,IAAK,0GACL,IAAK,uFACL,QAAS,EAA6B,EAAM,CAC7C,CAAC,CACH,CACM,EAAE"}
1
+ {"version":3,"file":"getTranslationsSnapshot.mjs","names":[],"sources":["../../../src/functions/helpers/getTranslationsSnapshot.ts"],"sourcesContent":["import { Hash, Locale } from 'gt-i18n/internal';\nimport type { Content } from '@generaltranslation/format';\nimport {\n createDiagnosticMessage,\n formatDiagnosticErrorDetails,\n} from 'generaltranslation/diagnostics';\nimport { getReactI18nCache } from '../../i18n-cache/singleton-operations';\n\n/**\n * Serializable cached translations for provider hydration; a failed load\n * yields a snapshot with no entry for the locale, so hydration caches nothing\n * and a later lookup retries. TODO: perhaps move to /i18n for type generics\n */\nexport async function getTranslationsSnapshot(\n locale: Locale\n): Promise<Record<Locale, Record<Hash, Content>>> {\n const i18nCache = getReactI18nCache();\n try {\n return { [locale]: await i18nCache.loadTranslations(locale) };\n } catch (error) {\n console.warn(createLoadWarning(locale, error));\n return {};\n }\n}\n\n/**\n * Loads a locale's translations into the cache and copies nothing out, for a\n * caller that only waits for them. A failed load warns like\n * getTranslationsSnapshot, and a later lookup retries.\n */\nexport async function preloadTranslations(locale: Locale): Promise<void> {\n try {\n await getReactI18nCache().getLookupTranslation(locale);\n } catch (error) {\n console.warn(createLoadWarning(locale, error));\n }\n}\n\nfunction createLoadWarning(locale: Locale, error: unknown): string {\n return createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Warning',\n whatHappened: `Could not load translations for locale \"${locale}\", so content for this locale renders untranslated`,\n why: 'the translation loader failed, usually because translations for this locale have not been generated yet',\n fix: 'Generate translations for this locale, or check your loadTranslations configuration.',\n details: formatDiagnosticErrorDetails(error),\n });\n}\n"],"mappings":"yLAaA,eAAsB,EACpB,EACgD,CAChD,IAAM,EAAY,GAAmB,CACrC,GAAI,CACF,MAAO,EAAG,GAAS,MAAM,EAAU,iBAAiB,EAAO,CAAE,OACtD,EAAO,CAEd,OADA,QAAQ,KAAK,EAAkB,EAAQ,EAAM,CAAC,CACvC,EAAE,EASb,eAAsB,EAAoB,EAA+B,CACvE,GAAI,CACF,MAAM,GAAmB,CAAC,qBAAqB,EAAO,OAC/C,EAAO,CACd,QAAQ,KAAK,EAAkB,EAAQ,EAAM,CAAC,EAIlD,SAAS,EAAkB,EAAgB,EAAwB,CACjE,OAAO,EAAwB,CAC7B,OAAQ,iCACR,SAAU,UACV,aAAc,2CAA2C,EAAO,oDAChE,IAAK,0GACL,IAAK,uFACL,QAAS,EAA6B,EAAM,CAC7C,CAAC"}
@@ -0,0 +1,2 @@
1
+ require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../condition-store/singleton-operations.cjs`),t=require(`./spaOnly.cjs`),n=(0,require(`gt-i18n/internal`).createMessages)({getLocale:()=>e.getConditionStore().getLocale(),getEnableI18n:()=>t.isSpa()&&e.getConditionStore().getEnableI18n()});function r(e){if(e==null)return;if(typeof e==`string`)return e;let{tree:t}=e;return Array.isArray(t)?t.filter(e=>typeof e==`string`).join(``):t}const i=((e,i)=>(t.isSpa()||t.reportServerRenderedUse({name:`m`,fix:`In components, use useMessages(); on the server, use getMessages()`,message:r(e)}),n(e,i)));exports.m=i;
2
+ //# sourceMappingURL=m.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"m.cjs","names":["getReadonlyConditionStore","isSpa"],"sources":["../../../src/functions/translation/m.ts"],"sourcesContent":["import type { M, Msg } from 'gt-i18n';\nimport { createMessages } from 'gt-i18n/internal';\nimport { getReadonlyConditionStore } from '../../condition-store/singleton-operations';\nimport { isSpa, reportServerRenderedUse } from './spaOnly';\n\nconst messages = /* @__PURE__ */ createMessages({\n getLocale: () => getReadonlyConditionStore().getLocale(),\n // Outside an SPA, m renders the source once the misuse is reported.\n getEnableI18n: () => isSpa() && getReadonlyConditionStore().getEnableI18n(),\n});\n\nfunction sourceOf(message: string | Msg | null | undefined) {\n if (message == null) return undefined;\n if (typeof message === 'string') return message;\n const { tree } = message;\n if (!Array.isArray(tree)) return tree;\n return tree.filter((node) => typeof node === 'string').join('');\n}\n\n/**\n * Renders a message from msg() with the current locale. Client-rendered (SPA)\n * apps only, where it also works at module level; server-rendered apps use\n * useMessages() or getMessages().\n *\n * @example\n * const greeting = msg`Hello, ${{ name }}!`;\n * m(greeting);\n * m(greeting, { name: 'Bo' });\n */\nexport const m = ((\n message: string | Msg | null | undefined,\n values?: Record<string, unknown>\n) => {\n if (!isSpa()) {\n reportServerRenderedUse({\n name: 'm',\n fix: 'In components, use useMessages(); on the server, use getMessages()',\n message: sourceOf(message),\n });\n }\n return messages(message, values);\n}) as M;\n"],"mappings":"6IAKM,GAA2B,6BAAA,CAAA,gBAAe,CAC9C,cAAiBA,EAAAA,mBAA2B,CAAC,WAAW,CAExD,kBAAqBC,EAAAA,OAAO,EAAID,EAAAA,mBAA2B,CAAC,eAAe,CAC5E,CAAC,CAEF,SAAS,EAAS,EAA0C,CAC1D,GAAI,GAAW,KAAM,OACrB,GAAI,OAAO,GAAY,SAAU,OAAO,EACxC,GAAM,CAAE,QAAS,EAEjB,OADK,MAAM,QAAQ,EAAK,CACjB,EAAK,OAAQ,GAAS,OAAO,GAAS,SAAS,CAAC,KAAK,GAAG,CAD9B,EAcnC,MAAa,IACX,EACA,KAEKC,EAAAA,OAAO,EACV,EAAA,wBAAwB,CACtB,KAAM,IACN,IAAK,qEACL,QAAS,EAAS,EAAQ,CAC3B,CAAC,CAEG,EAAS,EAAS,EAAO"}
@@ -1,6 +1,6 @@
1
- import { M } from "gt-i18n/unstable";
1
+ import { M } from "gt-i18n";
2
2
 
3
- //#region src/unstable/m.d.ts
3
+ //#region src/functions/translation/m.d.ts
4
4
  /**
5
5
  * Renders a message from msg() with the current locale. Client-rendered (SPA)
6
6
  * apps only, where it also works at module level; server-rendered apps use
@@ -0,0 +1 @@
1
+ {"version":3,"file":"m.d.ts","names":[],"sources":["../../../src/functions/translation/m.ts"],"mappings":";;;;;AA6BA;;;;;;;;cAAa,CAAA,EAYP,CAAA"}
@@ -0,0 +1,2 @@
1
+ import{getConditionStore as e}from"../../condition-store/singleton-operations.mjs";import{isSpa as t,reportServerRenderedUse as n}from"./spaOnly.mjs";import{createMessages as r}from"gt-i18n/internal";const i=r({getLocale:()=>e().getLocale(),getEnableI18n:()=>t()&&e().getEnableI18n()});function a(e){if(e==null)return;if(typeof e==`string`)return e;let{tree:t}=e;return Array.isArray(t)?t.filter(e=>typeof e==`string`).join(``):t}const o=((e,r)=>(t()||n({name:`m`,fix:`In components, use useMessages(); on the server, use getMessages()`,message:a(e)}),i(e,r)));export{o as m};
2
+ //# sourceMappingURL=m.mjs.map