intor 2.3.34 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/README.md +7 -3
  2. package/dist/core/export/edge/index.js +6 -0
  3. package/dist/core/src/{server → core}/translator/create-translator.js +1 -1
  4. package/dist/core/src/core/utils/normalizers/normalize-locale.js +59 -0
  5. package/dist/core/src/core/utils/normalizers/normalize-query.js +25 -0
  6. package/dist/core/src/edge/helpers/get-translator.js +29 -0
  7. package/dist/core/src/edge/translator/init-translator.js +35 -0
  8. package/dist/core/src/routing/inbound/helpers/resolve-inbound-from-request.js +29 -0
  9. package/dist/core/src/routing/inbound/resolve-inbound.js +45 -0
  10. package/dist/core/src/routing/inbound/resolve-locale/resolve-locale.js +35 -0
  11. package/dist/{next/src/routing/inbound/resolve-pathname/resolve-pathname.js → core/src/routing/inbound/resolve-path/resolve-path.js} +2 -2
  12. package/dist/core/src/routing/locale/get-locale-from-accept-language.js +38 -0
  13. package/dist/core/src/routing/locale/get-locale-from-host.js +32 -0
  14. package/dist/core/src/routing/locale/get-locale-from-pathname.js +47 -0
  15. package/dist/core/src/routing/locale/get-locale-from-query.js +21 -0
  16. package/dist/core/src/server/helpers/get-translator.js +4 -5
  17. package/dist/core/src/server/translator/init-translator.js +1 -1
  18. package/dist/express/src/adapters/express/create-intor-handler.js +2 -4
  19. package/dist/express/src/adapters/express/get-translator.js +7 -1
  20. package/dist/express/src/{server → core}/translator/create-translator.js +1 -1
  21. package/dist/express/src/core/utils/parse-cookie-header.js +22 -0
  22. package/dist/express/src/routing/inbound/resolve-inbound.js +2 -2
  23. package/dist/express/src/routing/inbound/{resolve-pathname/resolve-pathname.js → resolve-path/resolve-path.js} +2 -2
  24. package/dist/express/src/server/helpers/get-translator.js +4 -5
  25. package/dist/express/src/server/translator/init-translator.js +1 -1
  26. package/dist/fastify/export/fastify/index.js +3 -0
  27. package/dist/fastify/src/adapters/fastify/create-intor-handler.js +54 -0
  28. package/dist/fastify/src/adapters/fastify/get-translator.js +28 -0
  29. package/dist/fastify/src/adapters/fastify/intor-fastify-plugin.js +34 -0
  30. package/dist/fastify/src/core/constants/prefix-placeholder.js +4 -0
  31. package/dist/fastify/src/core/error/intor-error.js +9 -0
  32. package/dist/fastify/src/core/logger/get-logger.js +39 -0
  33. package/dist/fastify/src/core/logger/global-logger-pool.js +8 -0
  34. package/dist/fastify/src/core/messages/load-remote-messages/collect-remote-resources.js +25 -0
  35. package/dist/fastify/src/core/messages/load-remote-messages/fetch-remote-resource.js +47 -0
  36. package/dist/fastify/src/core/messages/load-remote-messages/load-remote-messages.js +93 -0
  37. package/dist/fastify/src/core/messages/load-remote-messages/resolve-remote-resources.js +24 -0
  38. package/dist/fastify/src/core/messages/merge-messages.js +33 -0
  39. package/dist/fastify/src/core/messages/utils/is-valid-messages.js +44 -0
  40. package/dist/fastify/src/core/messages/utils/nest-object-from-path.js +21 -0
  41. package/dist/fastify/src/core/render/create-html-renderer.js +44 -0
  42. package/dist/fastify/src/core/render/utils/escape-html.js +10 -0
  43. package/dist/fastify/src/core/render/utils/render-attributes.js +17 -0
  44. package/dist/fastify/src/core/translator/create-t-rich.js +22 -0
  45. package/dist/{svelte-kit/src/server → fastify/src/core}/translator/create-translator.js +1 -1
  46. package/dist/fastify/src/core/utils/deep-merge.js +47 -0
  47. package/dist/fastify/src/core/utils/normalizers/normalize-cache-key.js +45 -0
  48. package/dist/fastify/src/core/utils/normalizers/normalize-locale.js +59 -0
  49. package/dist/fastify/src/core/utils/normalizers/normalize-pathname.js +43 -0
  50. package/dist/fastify/src/core/utils/normalizers/normalize-query.js +25 -0
  51. package/dist/fastify/src/core/utils/parse-cookie-header.js +22 -0
  52. package/dist/fastify/src/core/utils/resolve-loader-options.js +27 -0
  53. package/dist/fastify/src/routing/inbound/resolve-inbound.js +45 -0
  54. package/dist/fastify/src/routing/inbound/resolve-locale/resolve-locale.js +35 -0
  55. package/dist/{svelte-kit/src/routing/inbound/resolve-pathname/resolve-pathname.js → fastify/src/routing/inbound/resolve-path/resolve-path.js} +2 -2
  56. package/dist/fastify/src/routing/inbound/resolve-path/strategies/all.js +28 -0
  57. package/dist/fastify/src/routing/inbound/resolve-path/strategies/except-default.js +29 -0
  58. package/dist/fastify/src/routing/locale/get-locale-from-accept-language.js +38 -0
  59. package/dist/fastify/src/routing/locale/get-locale-from-host.js +32 -0
  60. package/dist/fastify/src/routing/locale/get-locale-from-pathname.js +47 -0
  61. package/dist/fastify/src/routing/locale/get-locale-from-query.js +21 -0
  62. package/dist/fastify/src/routing/pathname/canonicalize-pathname.js +47 -0
  63. package/dist/fastify/src/routing/pathname/localize-pathname.js +36 -0
  64. package/dist/fastify/src/routing/pathname/materialize-pathname.js +42 -0
  65. package/dist/fastify/src/routing/pathname/standardize-pathname.js +34 -0
  66. package/dist/fastify/src/server/helpers/get-translator.js +31 -0
  67. package/dist/fastify/src/server/messages/load-local-messages/cache/messages-pool.js +11 -0
  68. package/dist/fastify/src/server/messages/load-local-messages/load-local-messages.js +108 -0
  69. package/dist/fastify/src/server/messages/load-local-messages/read-locale-messages/collect-file-entries/collect-file-entries.js +91 -0
  70. package/dist/fastify/src/server/messages/load-local-messages/read-locale-messages/parse-file-entries/parse-file-entries.js +103 -0
  71. package/dist/fastify/src/server/messages/load-local-messages/read-locale-messages/parse-file-entries/utils/json-reader.js +12 -0
  72. package/dist/fastify/src/server/messages/load-local-messages/read-locale-messages/read-locale-messages.js +42 -0
  73. package/dist/fastify/src/server/messages/load-messages.js +78 -0
  74. package/dist/fastify/src/server/translator/init-translator.js +36 -0
  75. package/dist/hono/export/hono/index.js +3 -0
  76. package/dist/hono/src/adapters/hono/create-intor-handler.js +40 -0
  77. package/dist/hono/src/adapters/hono/get-translator.js +20 -0
  78. package/dist/hono/src/core/constants/prefix-placeholder.js +4 -0
  79. package/dist/hono/src/core/error/intor-error.js +9 -0
  80. package/dist/hono/src/core/logger/get-logger.js +39 -0
  81. package/dist/hono/src/core/logger/global-logger-pool.js +8 -0
  82. package/dist/hono/src/core/messages/load-remote-messages/collect-remote-resources.js +25 -0
  83. package/dist/hono/src/core/messages/load-remote-messages/fetch-remote-resource.js +47 -0
  84. package/dist/hono/src/core/messages/load-remote-messages/load-remote-messages.js +93 -0
  85. package/dist/hono/src/core/messages/load-remote-messages/resolve-remote-resources.js +24 -0
  86. package/dist/hono/src/core/messages/merge-messages.js +33 -0
  87. package/dist/hono/src/core/messages/utils/is-valid-messages.js +44 -0
  88. package/dist/hono/src/core/messages/utils/nest-object-from-path.js +21 -0
  89. package/dist/hono/src/core/render/create-html-renderer.js +44 -0
  90. package/dist/hono/src/core/render/utils/escape-html.js +10 -0
  91. package/dist/hono/src/core/render/utils/render-attributes.js +17 -0
  92. package/dist/hono/src/core/translator/create-t-rich.js +22 -0
  93. package/dist/{next/src/server → hono/src/core}/translator/create-translator.js +1 -1
  94. package/dist/hono/src/core/utils/deep-merge.js +47 -0
  95. package/dist/hono/src/core/utils/normalizers/normalize-locale.js +59 -0
  96. package/dist/hono/src/core/utils/normalizers/normalize-pathname.js +43 -0
  97. package/dist/hono/src/core/utils/normalizers/normalize-query.js +25 -0
  98. package/dist/hono/src/core/utils/parse-cookie-header.js +22 -0
  99. package/dist/hono/src/edge/helpers/get-translator.js +29 -0
  100. package/dist/hono/src/edge/translator/init-translator.js +35 -0
  101. package/dist/hono/src/routing/inbound/resolve-inbound.js +45 -0
  102. package/dist/hono/src/routing/inbound/resolve-locale/resolve-locale.js +35 -0
  103. package/dist/hono/src/routing/inbound/resolve-path/resolve-path.js +42 -0
  104. package/dist/hono/src/routing/inbound/resolve-path/strategies/all.js +28 -0
  105. package/dist/hono/src/routing/inbound/resolve-path/strategies/except-default.js +29 -0
  106. package/dist/hono/src/routing/inbound/resolve-path/strategies/none.js +8 -0
  107. package/dist/hono/src/routing/locale/get-locale-from-accept-language.js +38 -0
  108. package/dist/hono/src/routing/locale/get-locale-from-host.js +32 -0
  109. package/dist/hono/src/routing/locale/get-locale-from-pathname.js +47 -0
  110. package/dist/hono/src/routing/locale/get-locale-from-query.js +21 -0
  111. package/dist/hono/src/routing/pathname/canonicalize-pathname.js +47 -0
  112. package/dist/hono/src/routing/pathname/localize-pathname.js +36 -0
  113. package/dist/hono/src/routing/pathname/materialize-pathname.js +42 -0
  114. package/dist/hono/src/routing/pathname/standardize-pathname.js +34 -0
  115. package/dist/next/src/adapters/next/server/get-translator.js +7 -1
  116. package/dist/next/src/core/translator/create-translator.js +30 -0
  117. package/dist/next/src/routing/inbound/resolve-inbound.js +2 -2
  118. package/dist/next/src/routing/inbound/resolve-path/resolve-path.js +42 -0
  119. package/dist/next/src/routing/inbound/resolve-path/strategies/none.js +8 -0
  120. package/dist/next/src/server/helpers/get-translator.js +4 -5
  121. package/dist/next/src/server/translator/init-translator.js +1 -1
  122. package/dist/react/src/client/react/translator/trans.js +2 -2
  123. package/dist/react/src/client/react/translator/use-translator.js +5 -5
  124. package/dist/react/src/client/shared/helpers/get-client-locale.js +1 -7
  125. package/dist/svelte/src/client/shared/helpers/get-client-locale.js +1 -7
  126. package/dist/svelte/src/client/svelte/translator/use-translator.js +6 -6
  127. package/dist/svelte-kit/src/adapters/svelte-kit/server/create-intor-handler.js +1 -3
  128. package/dist/svelte-kit/src/core/translator/create-translator.js +30 -0
  129. package/dist/svelte-kit/src/routing/inbound/resolve-inbound.js +2 -2
  130. package/dist/svelte-kit/src/routing/inbound/resolve-path/resolve-path.js +42 -0
  131. package/dist/svelte-kit/src/routing/inbound/resolve-path/strategies/all.js +28 -0
  132. package/dist/svelte-kit/src/routing/inbound/resolve-path/strategies/except-default.js +29 -0
  133. package/dist/svelte-kit/src/routing/inbound/resolve-path/strategies/none.js +8 -0
  134. package/dist/svelte-kit/src/server/translator/init-translator.js +1 -1
  135. package/dist/types/export/edge/index.d.ts +2 -0
  136. package/dist/types/export/fastify/index.d.ts +1 -0
  137. package/dist/types/export/hono/index.d.ts +1 -0
  138. package/dist/types/src/adapters/express/create-intor-handler.d.ts +2 -4
  139. package/dist/types/src/adapters/express/get-translator.d.ts +5 -6
  140. package/dist/types/src/adapters/express/global.d.ts +4 -4
  141. package/dist/types/src/adapters/fastify/create-intor-handler.d.ts +12 -0
  142. package/dist/types/src/adapters/fastify/get-translator.d.ts +17 -0
  143. package/dist/types/src/adapters/fastify/global.d.ts +17 -0
  144. package/dist/types/src/adapters/fastify/index.d.ts +3 -0
  145. package/dist/types/src/adapters/fastify/intor-fastify-plugin.d.ts +21 -0
  146. package/dist/types/src/adapters/hono/create-intor-handler.d.ts +10 -0
  147. package/dist/types/src/adapters/hono/get-translator.d.ts +17 -0
  148. package/dist/types/src/adapters/hono/global.d.ts +17 -0
  149. package/dist/types/src/adapters/hono/index.d.ts +3 -0
  150. package/dist/types/src/adapters/next/server/get-translator.d.ts +5 -6
  151. package/dist/types/src/adapters/svelte-kit/server/create-intor-handler.d.ts +0 -2
  152. package/dist/types/src/client/react/translator/trans.d.ts +3 -12
  153. package/dist/types/src/client/react/translator/translator-instance.d.ts +1 -5
  154. package/dist/types/src/client/react/translator/use-translator.d.ts +4 -3
  155. package/dist/types/src/client/shared/helpers/get-client-locale.d.ts +3 -8
  156. package/dist/types/src/client/svelte/translator/translator-instance.d.ts +7 -7
  157. package/dist/types/src/client/svelte/translator/use-translator.d.ts +5 -4
  158. package/dist/types/src/client/vue/translator/trans.d.ts +7 -2
  159. package/dist/types/src/client/vue/translator/translator-instance.d.ts +2 -2
  160. package/dist/types/src/client/vue/translator/use-translator.d.ts +5 -4
  161. package/dist/types/src/core/index.d.ts +2 -2
  162. package/dist/types/src/core/translator/index.d.ts +1 -0
  163. package/dist/types/src/core/types/translator-instance.d.ts +9 -2
  164. package/dist/types/src/core/utils/index.d.ts +1 -0
  165. package/dist/types/src/edge/helpers/get-translator.d.ts +15 -0
  166. package/dist/types/src/edge/helpers/index.d.ts +1 -0
  167. package/dist/types/src/edge/index.d.ts +1 -0
  168. package/dist/types/src/edge/translator/index.d.ts +1 -0
  169. package/dist/types/src/edge/translator/init-translator.d.ts +14 -0
  170. package/dist/types/src/routing/inbound/helpers/index.d.ts +1 -0
  171. package/dist/types/src/routing/inbound/helpers/resolve-inbound-from-request.d.ts +3 -0
  172. package/dist/types/src/routing/inbound/index.d.ts +1 -0
  173. package/dist/types/src/routing/inbound/resolve-path/index.d.ts +1 -0
  174. package/dist/types/src/routing/inbound/{resolve-pathname/resolve-pathname.d.ts → resolve-path/resolve-path.d.ts} +2 -2
  175. package/dist/types/src/routing/inbound/{resolve-pathname → resolve-path}/strategies/all.d.ts +2 -2
  176. package/dist/types/src/routing/inbound/{resolve-pathname → resolve-path}/strategies/except-default.d.ts +2 -2
  177. package/dist/types/src/routing/inbound/resolve-path/strategies/none.d.ts +5 -0
  178. package/dist/types/src/routing/inbound/{resolve-pathname → resolve-path}/types.d.ts +5 -5
  179. package/dist/types/src/routing/index.d.ts +1 -1
  180. package/dist/types/src/server/helpers/get-translator.d.ts +6 -8
  181. package/dist/types/src/server/index.d.ts +0 -2
  182. package/dist/types/src/server/translator/index.d.ts +1 -2
  183. package/dist/types/src/server/translator/init-translator.d.ts +3 -2
  184. package/dist/vue/src/client/shared/helpers/get-client-locale.js +1 -7
  185. package/dist/vue/src/client/vue/translator/trans.js +10 -4
  186. package/dist/vue/src/client/vue/translator/use-translator.js +8 -8
  187. package/package.json +18 -1
  188. package/dist/types/src/routing/inbound/resolve-pathname/index.d.ts +0 -1
  189. package/dist/types/src/routing/inbound/resolve-pathname/strategies/none.d.ts +0 -5
  190. package/dist/types/src/server/shared/utils/index.d.ts +0 -1
  191. package/dist/types/src/server/translator/translator-instance.d.ts +0 -10
  192. /package/dist/{express/src/server/shared → core/src/core}/utils/parse-cookie-header.js +0 -0
  193. /package/dist/{express/src/routing/inbound/resolve-pathname → core/src/routing/inbound/resolve-path}/strategies/all.js +0 -0
  194. /package/dist/{express/src/routing/inbound/resolve-pathname → core/src/routing/inbound/resolve-path}/strategies/except-default.js +0 -0
  195. /package/dist/{express/src/routing/inbound/resolve-pathname → core/src/routing/inbound/resolve-path}/strategies/none.js +0 -0
  196. /package/dist/{svelte-kit/src/routing/inbound/resolve-pathname → express/src/routing/inbound/resolve-path}/strategies/all.js +0 -0
  197. /package/dist/{svelte-kit/src/routing/inbound/resolve-pathname → express/src/routing/inbound/resolve-path}/strategies/except-default.js +0 -0
  198. /package/dist/{next/src/routing/inbound/resolve-pathname → express/src/routing/inbound/resolve-path}/strategies/none.js +0 -0
  199. /package/dist/{svelte-kit/src/routing/inbound/resolve-pathname → fastify/src/routing/inbound/resolve-path}/strategies/none.js +0 -0
  200. /package/dist/next/src/routing/inbound/{resolve-pathname → resolve-path}/strategies/all.js +0 -0
  201. /package/dist/next/src/routing/inbound/{resolve-pathname → resolve-path}/strategies/except-default.js +0 -0
  202. /package/dist/types/src/{server → core}/translator/create-translator.d.ts +0 -0
  203. /package/dist/types/src/{server/shared → core}/utils/parse-cookie-header.d.ts +0 -0
  204. /package/dist/types/src/routing/inbound/{resolve-pathname → resolve-path}/strategies/index.d.ts +0 -0
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Resolve pathname decision for routing prefix strategy: "none".
3
+ */
4
+ function none() {
5
+ return { type: "pass" };
6
+ }
7
+
8
+ export { none };
@@ -1,10 +1,13 @@
1
1
  import '../../core/error/intor-error.js';
2
2
  import 'logry';
3
3
  import 'p-limit';
4
+ import 'intor-translator';
4
5
  import { createTRich } from '../../core/translator/create-t-rich.js';
5
6
  import { initTranslator } from '../translator/init-translator.js';
6
7
 
7
- // Implementation
8
+ /**
9
+ * Get a server-side translator for the current execution context.
10
+ */
8
11
  async function getTranslator(config, params) {
9
12
  const { locale, readers, allowCacheWrite, fetch, preKey, handlers, plugins } = params;
10
13
  // Initialize a locale-bound translator snapshot with messages loaded
@@ -22,10 +25,6 @@ async function getTranslator(config, params) {
22
25
  hasKey: scoped.hasKey,
23
26
  t: scoped.t,
24
27
  tRich: createTRich(scoped.t),
25
- // NOTE:
26
- // The runtime implementation is intentionally erased.
27
- // Type safety is guaranteed by public type contracts.
28
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
28
  };
30
29
  }
31
30
 
@@ -2,11 +2,11 @@ import '../../core/error/intor-error.js';
2
2
  import { resolveLoaderOptions } from '../../core/utils/resolve-loader-options.js';
3
3
  import 'logry';
4
4
  import 'p-limit';
5
+ import { createTranslator } from '../../core/translator/create-translator.js';
5
6
  import 'intor-translator';
6
7
  import { loadMessages } from '../messages/load-messages.js';
7
8
  import 'node:path';
8
9
  import 'node:fs/promises';
9
- import { createTranslator } from './create-translator.js';
10
10
 
11
11
  /**
12
12
  * Initialize a locale-bound Translator snapshot.
@@ -8,8 +8,8 @@ import { useTranslator } from './use-translator.js';
8
8
  */
9
9
  function Trans(props) {
10
10
  const { i18nKey, components, values } = props;
11
- const translator = useTranslator();
12
- return jsx(Fragment, { children: translator.tRich(i18nKey, components, values) });
11
+ const { tRich } = useTranslator();
12
+ return jsx(Fragment, { children: tRich(i18nKey, components, values) });
13
13
  }
14
14
 
15
15
  export { Trans };
@@ -2,7 +2,11 @@ import '../provider/intor-provider.js';
2
2
  import { useIntorContext } from '../provider/use-intor-context.js';
3
3
  import { createTRich } from './create-t-rich.js';
4
4
 
5
- // Implementation
5
+ /**
6
+ * React hook for accessing the active, scope-aware translator instance.
7
+ *
8
+ * @platform React
9
+ */
6
10
  function useTranslator(preKey) {
7
11
  const { translator, setLocale } = useIntorContext();
8
12
  const scoped = translator.scoped(preKey);
@@ -14,10 +18,6 @@ function useTranslator(preKey) {
14
18
  hasKey: scoped.hasKey,
15
19
  t: scoped.t,
16
20
  tRich: createTRich(scoped.t),
17
- // NOTE:
18
- // The runtime implementation is intentionally erased.
19
- // Type safety is guaranteed by public type contracts.
20
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
21
  };
22
22
  }
23
23
 
@@ -7,13 +7,7 @@ import { detectBrowserLocale } from '../utils/locale/detect-browser-locale.js';
7
7
  import { getLocaleFromCookie } from '../utils/locale/get-locale-from-cookie.js';
8
8
 
9
9
  /**
10
- * Resolve the locale in a client-only environment.
11
- *
12
- * This helper is intended for pure CSR setups (e.g. Vite).
13
- *
14
- * For framework-based apps, prefer `useTranslator()`.
15
- *
16
- * - Client-side only
10
+ * Resolve the active locale in a pure client-side environment.
17
11
  */
18
12
  function getClientLocale(config) {
19
13
  const { defaultLocale, supportedLocales, cookie } = config;
@@ -7,13 +7,7 @@ import { detectBrowserLocale } from '../utils/locale/detect-browser-locale.js';
7
7
  import { getLocaleFromCookie } from '../utils/locale/get-locale-from-cookie.js';
8
8
 
9
9
  /**
10
- * Resolve the locale in a client-only environment.
11
- *
12
- * This helper is intended for pure CSR setups (e.g. Vite).
13
- *
14
- * For framework-based apps, prefer `useTranslator()`.
15
- *
16
- * - Client-side only
10
+ * Resolve the active locale in a pure client-side environment.
17
11
  */
18
12
  function getClientLocale(config) {
19
13
  const { defaultLocale, supportedLocales, cookie } = config;
@@ -2,13 +2,17 @@ import { derived } from 'svelte/store';
2
2
  import '../../../core/error/intor-error.js';
3
3
  import 'logry';
4
4
  import 'p-limit';
5
- import { createTRich } from '../../../core/translator/create-t-rich.js';
6
5
  import 'intor-translator';
6
+ import { createTRich } from '../../../core/translator/create-t-rich.js';
7
7
  import 'svelte';
8
8
  import '../provider/intor-provider.svelte';
9
9
  import { useIntorContext } from '../provider/use-intor-context.js';
10
10
 
11
- // Implementation
11
+ /**
12
+ * Svelte utility for accessing the active, scope-aware translator instance.
13
+ *
14
+ * @platform Svelte
15
+ */
12
16
  function useTranslator(preKey) {
13
17
  const { translator, locale, setLocale } = useIntorContext();
14
18
  const scoped = derived(translator, ($t) => $t.scoped(preKey));
@@ -20,10 +24,6 @@ function useTranslator(preKey) {
20
24
  hasKey: derived(scoped, ($t) => $t.hasKey),
21
25
  t: derived(scoped, ($t) => $t.t),
22
26
  tRich: derived(scoped, ($t) => createTRich($t.t)),
23
- // NOTE:
24
- // The runtime implementation is intentionally erased.
25
- // Type safety is guaranteed by public type contracts.
26
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
27
  };
28
28
  }
29
29
 
@@ -11,14 +11,12 @@ import { getLocaleFromAcceptLanguage } from '../../../routing/locale/get-locale-
11
11
  /**
12
12
  * Resolves locale-aware routing for the current execution context.
13
13
  *
14
- * The resolved routing state is exposed via response headers.
15
- *
16
14
  * - Acts as the canonical routing authority within the SvelteKit request lifecycle.
17
15
  *
18
16
  * @platform SvelteKit
19
17
  */
20
18
  function createIntorHandler(config) {
21
- return async ({ event, resolve }) => {
19
+ return async function intorHandler({ event, resolve }) {
22
20
  const { host, searchParams, pathname: rawPathname } = event.url;
23
21
  // Locale from Accept-Language header
24
22
  const acceptLanguage = event.request.headers.get("accept-language");
@@ -0,0 +1,30 @@
1
+ import { Translator } from 'intor-translator';
2
+ import { mergeMessages } from '../messages/merge-messages.js';
3
+
4
+ /**
5
+ * Create a server-side Translator instance for a fixed locale.
6
+ *
7
+ * - Merges static config messages with runtime-loaded messages
8
+ * - Initializes a Translator bound to a specific locale
9
+ * - Injects fallback rules, handlers, and plugins from config
10
+ */
11
+ function createTranslator(params) {
12
+ const { config, locale, messages, handlers, plugins } = params;
13
+ // Merge static config messages with runtime-loaded messages
14
+ const finalMessages = mergeMessages(config.messages, messages, {
15
+ config,
16
+ locale,
17
+ });
18
+ const translator = new Translator({
19
+ locale,
20
+ messages: finalMessages,
21
+ fallbackLocales: config.fallbackLocales,
22
+ loadingMessage: config.translator?.loadingMessage,
23
+ missingMessage: config.translator?.missingMessage,
24
+ handlers,
25
+ plugins,
26
+ });
27
+ return translator;
28
+ }
29
+
30
+ export { createTranslator };
@@ -2,7 +2,7 @@ import { getLocaleFromPathname } from '../locale/get-locale-from-pathname.js';
2
2
  import { getLocaleFromHost } from '../locale/get-locale-from-host.js';
3
3
  import { getLocaleFromQuery } from '../locale/get-locale-from-query.js';
4
4
  import { resolveLocale } from './resolve-locale/resolve-locale.js';
5
- import { resolvePathname } from './resolve-pathname/resolve-pathname.js';
5
+ import { resolvePath } from './resolve-path/resolve-path.js';
6
6
 
7
7
  /**
8
8
  * Resolves inbound routing state.
@@ -30,7 +30,7 @@ async function resolveInbound(config, rawPathname, localeInputs, options) {
30
30
  // ------------------------------------------------------
31
31
  // Resolve localized pathname and redirect requirement
32
32
  // ------------------------------------------------------
33
- const { pathname, shouldRedirect } = resolvePathname(config, rawPathname, {
33
+ const { pathname, shouldRedirect } = resolvePath(config, rawPathname, {
34
34
  locale,
35
35
  hasPathLocale: !!pathLocale,
36
36
  hasPersisted: !!cookie});
@@ -0,0 +1,42 @@
1
+ import { localizePathname } from '../../pathname/localize-pathname.js';
2
+ import { all } from './strategies/all.js';
3
+ import { exceptDefault } from './strategies/except-default.js';
4
+ import { none } from './strategies/none.js';
5
+
6
+ const assertNever = (x) => {
7
+ throw new Error(`Unhandled prefix strategy: ${x}`);
8
+ };
9
+ /**
10
+ * Resolves the canonical pathname based on locale prefix behavior.
11
+ *
12
+ * The resolved pathname represents the final, normalized form
13
+ * used for routing and navigation.
14
+ */
15
+ const resolvePath = (config, rawPathname, context) => {
16
+ const { localePrefix } = config.routing;
17
+ let directive;
18
+ switch (localePrefix) {
19
+ case "all": {
20
+ directive = all(config, context);
21
+ break;
22
+ }
23
+ case "except-default": {
24
+ directive = exceptDefault(config, context);
25
+ break;
26
+ }
27
+ case "none": {
28
+ directive = none();
29
+ break;
30
+ }
31
+ default: {
32
+ return assertNever(localePrefix);
33
+ }
34
+ }
35
+ const { pathname } = localizePathname(rawPathname, config, context.locale);
36
+ return {
37
+ pathname,
38
+ shouldRedirect: directive.type === "redirect",
39
+ };
40
+ };
41
+
42
+ export { resolvePath };
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Resolve pathname decision for routing prefix strategy: "all".
3
+ */
4
+ function all(config, context) {
5
+ const { hasPathLocale, hasPersisted} = context;
6
+ const { redirect } = config.routing.inbound.firstVisit;
7
+ const isFirstVisit = !hasPersisted;
8
+ // ----------------------------------------------------------
9
+ // URL already canonical
10
+ // ----------------------------------------------------------
11
+ if (hasPathLocale) {
12
+ return { type: "pass" };
13
+ }
14
+ // ----------------------------------------------------------
15
+ // Apply first-visit redirect policy
16
+ // ----------------------------------------------------------
17
+ if (isFirstVisit) {
18
+ if (!redirect)
19
+ return { type: "pass" };
20
+ return { type: "redirect" };
21
+ }
22
+ // ----------------------------------------------------------
23
+ // Redirect to the locale-prefixed URL
24
+ // ----------------------------------------------------------
25
+ return { type: "redirect" };
26
+ }
27
+
28
+ export { all };
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Resolve pathname decision for routing prefix strategy: "except-default".
3
+ */
4
+ function exceptDefault(config, context) {
5
+ const { hasPathLocale, hasPersisted} = context;
6
+ const { redirect } = config.routing.inbound.firstVisit;
7
+ const isFirstVisit = !hasPersisted;
8
+ const isDefaultLocale = context.locale === config.defaultLocale;
9
+ // ----------------------------------------------------------
10
+ // URL already canonical
11
+ // ----------------------------------------------------------
12
+ if (hasPathLocale) {
13
+ return { type: "pass" };
14
+ }
15
+ // ----------------------------------------------------------
16
+ // Apply first-visit redirect policy
17
+ // ----------------------------------------------------------
18
+ if (isFirstVisit) {
19
+ if (!redirect)
20
+ return { type: "pass" };
21
+ return isDefaultLocale ? { type: "pass" } : { type: "redirect" };
22
+ }
23
+ // ----------------------------------------------------------
24
+ // Redirect non-default locale to the locale-prefixed URL
25
+ // ----------------------------------------------------------
26
+ return isDefaultLocale ? { type: "pass" } : { type: "redirect" };
27
+ }
28
+
29
+ export { exceptDefault };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Resolve pathname decision for routing prefix strategy: "none".
3
+ */
4
+ function none() {
5
+ return { type: "pass" };
6
+ }
7
+
8
+ export { none };
@@ -2,11 +2,11 @@ import '../../core/error/intor-error.js';
2
2
  import { resolveLoaderOptions } from '../../core/utils/resolve-loader-options.js';
3
3
  import 'logry';
4
4
  import 'p-limit';
5
+ import { createTranslator } from '../../core/translator/create-translator.js';
5
6
  import 'intor-translator';
6
7
  import { loadMessages } from '../messages/load-messages.js';
7
8
  import 'node:path';
8
9
  import 'node:fs/promises';
9
- import { createTranslator } from './create-translator.js';
10
10
 
11
11
  /**
12
12
  * Initialize a locale-bound Translator snapshot.
@@ -0,0 +1,2 @@
1
+ export { getTranslator } from "../../src/edge";
2
+ export { resolveInboundFromRequest } from "../../src/routing";
@@ -0,0 +1 @@
1
+ export { intorFastifyPlugin, getTranslator } from "../../src/adapters/fastify";
@@ -0,0 +1 @@
1
+ export { createIntorHandler, getTranslator } from "../../src/adapters/hono";
@@ -4,11 +4,9 @@ import { type GetTranslatorParams } from "../../server";
4
4
  /**
5
5
  * Resolves locale-aware routing for the current execution context.
6
6
  *
7
- * The resolved routing state is exposed via response headers.
8
- *
9
- * - Permits cache writes during server execution.
7
+ * - Binds resolved routing state to the request.
10
8
  * - Convenience routing shortcuts are also bound to the request for downstream consumption.
11
9
  *
12
10
  * @platform Express
13
11
  */
14
- export declare function createIntorHandler(config: IntorResolvedConfig, options?: Omit<GetTranslatorParams, "locale">): (req: Request, _res: Response, next: NextFunction) => Promise<void>;
12
+ export declare function createIntorHandler(config: IntorResolvedConfig, options?: Omit<GetTranslatorParams, "locale" | "fetch" | "allowCacheWrite">): (req: Request, _res: Response, next: NextFunction) => Promise<void>;
@@ -1,9 +1,9 @@
1
1
  import type { IntorResolvedConfig } from "../../config";
2
- import type { GenConfigKeys, GenMessages, GenReplacements } from "../../core";
3
- import type { GetTranslatorParams, TranslatorInstanceServer } from "../../server";
2
+ import type { GenConfigKeys, GenMessages, GenReplacements, GenRich, TranslatorInstance } from "../../core";
3
+ import type { GetTranslatorParams } from "../../server";
4
4
  import type { Request } from "express";
5
5
  import type { LocalizedPreKey } from "intor-translator";
6
- type GetTranslatorExpressParams = Omit<GetTranslatorParams, "locale">;
6
+ type GetTranslatorExpressParams<CK extends GenConfigKeys = "__default__"> = Omit<GetTranslatorParams<CK>, "locale">;
7
7
  /**
8
8
  * Get a server-side translator for the current execution context.
9
9
  *
@@ -11,8 +11,7 @@ type GetTranslatorExpressParams = Omit<GetTranslatorParams, "locale">;
11
11
  *
12
12
  * @platform Express
13
13
  */
14
- export declare function getTranslator<CK extends GenConfigKeys = "__default__", ReplacementSchema = GenReplacements<CK>>(config: IntorResolvedConfig, req: Request, params?: GetTranslatorExpressParams): Promise<TranslatorInstanceServer<GenMessages<CK>, ReplacementSchema>>;
15
- export declare function getTranslator<CK extends GenConfigKeys = "__default__", ReplacementSchema = GenReplacements<CK>, PK extends string = LocalizedPreKey<GenMessages<CK>>>(config: IntorResolvedConfig, req: Request, params?: GetTranslatorExpressParams & {
14
+ export declare function getTranslator<CK extends GenConfigKeys = "__default__", ReplacementSchema = GenReplacements<CK>, RichSchema = GenRich<CK>, PK extends LocalizedPreKey<GenMessages<CK>> | undefined = undefined>(config: IntorResolvedConfig, req: Request, params?: GetTranslatorExpressParams<CK> & {
16
15
  preKey?: PK;
17
- }): Promise<TranslatorInstanceServer<GenMessages<CK>, ReplacementSchema, PK>>;
16
+ }): Promise<TranslatorInstance<GenMessages<CK>, ReplacementSchema, RichSchema, PK>>;
18
17
  export {};
@@ -1,5 +1,5 @@
1
+ import type { TranslatorInstance } from "../../core";
1
2
  import type { InboundContext } from "../../routing";
2
- import type { TranslatorInstanceServer } from "../../server";
3
3
  import type { Locale, LocaleMessages } from "intor-translator";
4
4
  /**
5
5
  * Global type augmentations for Express request
@@ -9,9 +9,9 @@ declare global {
9
9
  interface Request {
10
10
  intor: InboundContext;
11
11
  locale: Locale;
12
- hasKey: TranslatorInstanceServer<LocaleMessages>["hasKey"];
13
- t: TranslatorInstanceServer<LocaleMessages>["t"];
14
- tRich: TranslatorInstanceServer<LocaleMessages>["tRich"];
12
+ hasKey: TranslatorInstance<LocaleMessages>["hasKey"];
13
+ t: TranslatorInstance<LocaleMessages>["t"];
14
+ tRich: TranslatorInstance<LocaleMessages>["tRich"];
15
15
  }
16
16
  }
17
17
  }
@@ -0,0 +1,12 @@
1
+ import type { IntorResolvedConfig } from "../../config";
2
+ import type { FastifyRequest } from "fastify";
3
+ import { type GetTranslatorParams } from "../../server";
4
+ /**
5
+ * Resolves locale-aware routing for the current execution context.
6
+ *
7
+ * - Binds resolved routing state to the request.
8
+ * - Convenience routing shortcuts are also bound to the request for downstream consumption.
9
+ *
10
+ * @platform Fastify
11
+ */
12
+ export declare function createIntorHandler(config: IntorResolvedConfig, options?: Omit<GetTranslatorParams, "locale" | "fetch" | "allowCacheWrite">): (request: FastifyRequest) => Promise<void>;
@@ -0,0 +1,17 @@
1
+ import type { IntorResolvedConfig } from "../../config";
2
+ import type { GenConfigKeys, GenMessages, GenReplacements, GenRich, TranslatorInstance } from "../../core";
3
+ import type { GetTranslatorParams } from "../../server";
4
+ import type { FastifyRequest } from "fastify";
5
+ import type { LocalizedPreKey } from "intor-translator";
6
+ type GetTranslatorFastifyParams<CK extends GenConfigKeys = "__default__"> = Omit<GetTranslatorParams<CK>, "locale">;
7
+ /**
8
+ * Get a server-side translator for the current execution context.
9
+ *
10
+ * - Automatically resolves the locale from the framework context.
11
+ *
12
+ * @platform Fastify
13
+ */
14
+ export declare function getTranslator<CK extends GenConfigKeys = "__default__", ReplacementSchema = GenReplacements<CK>, RichSchema = GenRich<CK>, PK extends LocalizedPreKey<GenMessages<CK>> | undefined = undefined>(config: IntorResolvedConfig, request: FastifyRequest, params?: GetTranslatorFastifyParams<CK> & {
15
+ preKey?: PK;
16
+ }): Promise<TranslatorInstance<GenMessages<CK>, ReplacementSchema, RichSchema, PK>>;
17
+ export {};
@@ -0,0 +1,17 @@
1
+ import "fastify";
2
+ import type { TranslatorInstance } from "../../core";
3
+ import type { InboundContext } from "../../routing";
4
+ import type { Locale, LocaleMessages } from "intor-translator";
5
+ /**
6
+ * Global type augmentations for Fastify request
7
+ */
8
+ declare module "fastify" {
9
+ interface FastifyRequest {
10
+ intor: InboundContext;
11
+ locale: Locale;
12
+ hasKey: TranslatorInstance<LocaleMessages>["hasKey"];
13
+ t: TranslatorInstance<LocaleMessages>["t"];
14
+ tRich: TranslatorInstance<LocaleMessages>["tRich"];
15
+ }
16
+ }
17
+ export {};
@@ -0,0 +1,3 @@
1
+ export { intorFastifyPlugin } from "./intor-fastify-plugin";
2
+ export { getTranslator } from "./get-translator";
3
+ export * from "./global";
@@ -0,0 +1,21 @@
1
+ import type { IntorResolvedConfig } from "../../config";
2
+ import type { GetTranslatorParams } from "../../server";
3
+ import type { FastifyInstance } from "fastify";
4
+ interface IntorFastifyPluginOptions extends Omit<GetTranslatorParams, "locale"> {
5
+ config: IntorResolvedConfig;
6
+ /**
7
+ * Bind DX shortcuts to request:
8
+ * - request.locale
9
+ * - request.hasKey
10
+ * - request.t
11
+ * - request.tRich
12
+ *
13
+ * Defaults to true
14
+ */
15
+ shortcuts?: boolean;
16
+ }
17
+ /**
18
+ * Intor Fastify adapter plugin
19
+ */
20
+ export declare function intorFastifyPlugin(fastify: FastifyInstance, options: IntorFastifyPluginOptions): void;
21
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { IntorResolvedConfig } from "../../config";
2
+ import type { Context, Next } from "hono";
3
+ /**
4
+ * Resolves locale-aware routing for the current execution context.
5
+ *
6
+ * - Binds resolved routing state to the request.
7
+ *
8
+ * @platform Hono
9
+ */
10
+ export declare function createIntorHandler(config: IntorResolvedConfig): (c: Context, next: Next) => Promise<void>;
@@ -0,0 +1,17 @@
1
+ import type { IntorResolvedConfig } from "../../config";
2
+ import type { GenConfigKeys, GenMessages, GenReplacements, GenRich, TranslatorInstance } from "../../core";
3
+ import type { GetTranslatorParams } from "../../edge";
4
+ import type { Context } from "hono";
5
+ import type { LocalizedPreKey } from "intor-translator";
6
+ type GetTranslatorHonoParams<CK extends GenConfigKeys = "__default__"> = Omit<GetTranslatorParams<CK>, "locale">;
7
+ /**
8
+ * Get a edge-runtime translator for the current execution context.
9
+ *
10
+ * - Automatically resolves the locale from the framework context.
11
+ *
12
+ * @platform Hono
13
+ */
14
+ export declare function getTranslator<CK extends GenConfigKeys = "__default__", ReplacementSchema = GenReplacements<CK>, RichSchema = GenRich<CK>, PK extends LocalizedPreKey<GenMessages<CK>> | undefined = undefined>(config: IntorResolvedConfig, c: Context, params?: GetTranslatorHonoParams<CK> & {
15
+ preKey?: PK;
16
+ }): Promise<TranslatorInstance<GenMessages<CK>, ReplacementSchema, RichSchema, PK>>;
17
+ export {};
@@ -0,0 +1,17 @@
1
+ import "hono";
2
+ import type { TranslatorInstance } from "../../core";
3
+ import type { InboundContext } from "../../routing";
4
+ import type { LocaleMessages } from "intor-translator";
5
+ /**
6
+ * Global type augmentations for Hono context variables
7
+ */
8
+ declare module "hono" {
9
+ interface ContextVariableMap {
10
+ intor: InboundContext;
11
+ locale: TranslatorInstance<LocaleMessages>["locale"];
12
+ hasKey: TranslatorInstance<LocaleMessages>["hasKey"];
13
+ t: TranslatorInstance<LocaleMessages>["t"];
14
+ tRich: TranslatorInstance<LocaleMessages>["tRich"];
15
+ }
16
+ }
17
+ export {};
@@ -0,0 +1,3 @@
1
+ export { createIntorHandler } from "./create-intor-handler";
2
+ export { getTranslator } from "./get-translator";
3
+ export * from "./global";
@@ -1,8 +1,8 @@
1
1
  import type { IntorResolvedConfig } from "../../../config";
2
- import type { GenConfigKeys, GenMessages, GenReplacements } from "../../../core";
3
- import type { GetTranslatorParams, TranslatorInstanceServer } from "../../../server";
2
+ import type { GenConfigKeys, GenMessages, GenReplacements, GenRich, TranslatorInstance } from "../../../core";
3
+ import type { GetTranslatorParams } from "../../../server";
4
4
  import type { LocalizedPreKey } from "intor-translator";
5
- type GetTranslatorNextParams = Omit<GetTranslatorParams, "locale">;
5
+ type GetTranslatorNextParams<CK extends GenConfigKeys = "__default__"> = Omit<GetTranslatorParams<CK>, "locale">;
6
6
  /**
7
7
  * Get a server-side translator for the current execution context.
8
8
  *
@@ -10,8 +10,7 @@ type GetTranslatorNextParams = Omit<GetTranslatorParams, "locale">;
10
10
  *
11
11
  * @platform Next.js
12
12
  */
13
- export declare function getTranslator<CK extends GenConfigKeys = "__default__", ReplacementSchema = GenReplacements<CK>>(config: IntorResolvedConfig, params?: GetTranslatorNextParams): Promise<TranslatorInstanceServer<GenMessages<CK>, ReplacementSchema>>;
14
- export declare function getTranslator<CK extends GenConfigKeys = "__default__", ReplacementSchema = GenReplacements<CK>, PK extends string = LocalizedPreKey<GenMessages<CK>>>(config: IntorResolvedConfig, params?: GetTranslatorNextParams & {
13
+ export declare function getTranslator<CK extends GenConfigKeys = "__default__", ReplacementSchema = GenReplacements<CK>, RichSchema = GenRich<CK>, PK extends LocalizedPreKey<GenMessages<CK>> | undefined = undefined>(config: IntorResolvedConfig, params: GetTranslatorNextParams<CK> & {
15
14
  preKey?: PK;
16
- }): Promise<TranslatorInstanceServer<GenMessages<CK>, ReplacementSchema, PK>>;
15
+ }): Promise<TranslatorInstance<GenMessages<CK>, ReplacementSchema, RichSchema, PK>>;
17
16
  export {};
@@ -3,8 +3,6 @@ import type { Handle } from "@sveltejs/kit";
3
3
  /**
4
4
  * Resolves locale-aware routing for the current execution context.
5
5
  *
6
- * The resolved routing state is exposed via response headers.
7
- *
8
6
  * - Acts as the canonical routing authority within the SvelteKit request lifecycle.
9
7
  *
10
8
  * @platform SvelteKit
@@ -4,18 +4,9 @@ import type { LocalizedKey, LocalizedReplacement, LocalizedRich, Replacement } f
4
4
  type TransProps<CK extends GenConfigKeys = "__default__", K extends string = LocalizedKey<GenMessages<CK>>, RI = LocalizedRich<GenRich<CK>, K>, RE extends Replacement = LocalizedReplacement<GenReplacements<CK>, K>> = {
5
5
  /** The message key to translate. */
6
6
  i18nKey: K | (string & {});
7
- /**
8
- * Optional React renderers for semantic tags in rich messages.
9
- *
10
- * Maps a tag name to either a React node or a render function,
11
- * allowing customization of rich tag rendering.
12
- */
13
- components?: ReactTagRenderers<RI>;
14
- /**
15
- * Optional replacement values for message interpolation.
16
- *
17
- * These values are passed to the underlying translator.
18
- */
7
+ /** Optional React renderers for semantic tags. */
8
+ components?: ReactTagRenderers<RI> | ReactTagRenderers;
9
+ /** Optional replacement values for interpolation. */
19
10
  values?: RE | Replacement;
20
11
  };
21
12
  /**
@@ -2,11 +2,7 @@ import type { ReactTagRenderers } from "../render";
2
2
  import type { TranslatorInstance } from "../../../core";
3
3
  import type { JSX } from "react/jsx-runtime";
4
4
  import { type Locale, type LocaleMessages, type LocalizedKey, type LocalizedReplacement, type LocalizedRich, type Replacement, type Rich, type ScopedKey } from "intor-translator";
5
- export type TranslatorInstanceReact<M extends LocaleMessages, ReplacementSchema = Replacement, RichSchema = Rich, PK extends string | undefined = undefined> = TranslatorInstance<M, ReplacementSchema, PK> & {
6
- /** `messages`: The message object containing all translations. */
7
- messages: M;
8
- /** Current locale in use. */
9
- locale: Locale<M>;
5
+ export type TranslatorInstanceReact<M extends LocaleMessages, ReplacementSchema = Replacement, RichSchema = Rich, PK extends string | undefined = undefined> = Omit<TranslatorInstance<M, ReplacementSchema, RichSchema, PK>, "tRich"> & {
10
6
  /** Indicates whether translations are currently loading. */
11
7
  isLoading: boolean;
12
8
  /** Update the active locale. */
@@ -2,7 +2,8 @@ import type { TranslatorInstanceReact } from "./translator-instance";
2
2
  import type { GenConfigKeys, GenMessages, GenReplacements, GenRich } from "../../../core";
3
3
  import type { LocalizedPreKey } from "intor-translator";
4
4
  /**
5
- * React hook to access the active translator instance.
5
+ * React hook for accessing the active, scope-aware translator instance.
6
+ *
7
+ * @platform React
6
8
  */
7
- export declare function useTranslator<CK extends GenConfigKeys = "__default__", ReplacementSchema = GenReplacements<CK>, RichSchema = GenRich<CK>>(): TranslatorInstanceReact<GenMessages<CK>, ReplacementSchema, RichSchema, undefined>;
8
- export declare function useTranslator<CK extends GenConfigKeys = "__default__", ReplacementSchema = GenReplacements<CK>, RichSchema = GenRich<CK>, PK extends string = LocalizedPreKey<GenMessages<CK>>>(preKey?: PK): TranslatorInstanceReact<GenMessages<CK>, ReplacementSchema, RichSchema, PK>;
9
+ export declare function useTranslator<CK extends GenConfigKeys = "__default__", ReplacementSchema = GenReplacements<CK>, RichSchema = GenRich<CK>, PK extends LocalizedPreKey<GenMessages<CK>> | undefined = undefined>(preKey?: PK): TranslatorInstanceReact<GenMessages<CK>, ReplacementSchema, RichSchema, PK>;