@intlayer/next-intl 9.0.0-canary.2 → 9.0.0-canary.3

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 (109) hide show
  1. package/dist/cjs/client/NextIntlClientProvider.cjs +1 -1
  2. package/dist/cjs/client/index.cjs +56 -13
  3. package/dist/cjs/index.cjs +92 -15
  4. package/dist/cjs/navigation/Link.cjs +1 -1
  5. package/dist/cjs/server/getRequestConfig.cjs +28 -0
  6. package/dist/cjs/server/getRequestConfig.cjs.map +1 -0
  7. package/dist/cjs/server/getTranslations.cjs +9 -4
  8. package/dist/cjs/server/getTranslations.cjs.map +1 -1
  9. package/dist/cjs/server/helpers.cjs +5 -3
  10. package/dist/cjs/server/helpers.cjs.map +1 -1
  11. package/dist/cjs/server/index.cjs +5 -1
  12. package/dist/cjs/server/setRequestLocale.cjs +30 -0
  13. package/dist/cjs/server/setRequestLocale.cjs.map +1 -0
  14. package/dist/esm/client/NextIntlClientProvider.mjs +1 -1
  15. package/dist/esm/client/index.mjs +1 -4
  16. package/dist/esm/index.mjs +3 -6
  17. package/dist/esm/navigation/Link.mjs +1 -1
  18. package/dist/esm/server/getRequestConfig.mjs +25 -0
  19. package/dist/esm/server/getRequestConfig.mjs.map +1 -0
  20. package/dist/esm/server/getTranslations.mjs +8 -4
  21. package/dist/esm/server/getTranslations.mjs.map +1 -1
  22. package/dist/esm/server/helpers.mjs +4 -3
  23. package/dist/esm/server/helpers.mjs.map +1 -1
  24. package/dist/esm/server/index.mjs +3 -1
  25. package/dist/esm/server/setRequestLocale.mjs +28 -0
  26. package/dist/esm/server/setRequestLocale.mjs.map +1 -0
  27. package/dist/types/client/index.d.ts +1 -4
  28. package/dist/types/index.d.ts +3 -6
  29. package/dist/types/server/getRequestConfig.d.ts +19 -0
  30. package/dist/types/server/getRequestConfig.d.ts.map +1 -0
  31. package/dist/types/server/getTranslations.d.ts +7 -29
  32. package/dist/types/server/getTranslations.d.ts.map +1 -1
  33. package/dist/types/server/helpers.d.ts +2 -1
  34. package/dist/types/server/helpers.d.ts.map +1 -1
  35. package/dist/types/server/index.d.ts +3 -1
  36. package/dist/types/server/setRequestLocale.d.ts +23 -0
  37. package/dist/types/server/setRequestLocale.d.ts.map +1 -0
  38. package/package.json +9 -8
  39. package/dist/cjs/client/helpers.cjs +0 -66
  40. package/dist/cjs/client/helpers.cjs.map +0 -1
  41. package/dist/cjs/client/useTranslations.cjs +0 -39
  42. package/dist/cjs/client/useTranslations.cjs.map +0 -1
  43. package/dist/cjs/createFormatter.cjs +0 -59
  44. package/dist/cjs/createFormatter.cjs.map +0 -1
  45. package/dist/cjs/createTranslator.cjs +0 -111
  46. package/dist/cjs/createTranslator.cjs.map +0 -1
  47. package/dist/cjs/getTranslationsDictionary.cjs +0 -31
  48. package/dist/cjs/getTranslationsDictionary.cjs.map +0 -1
  49. package/dist/cjs/getTranslationsDictionaryDynamic.cjs +0 -27
  50. package/dist/cjs/getTranslationsDictionaryDynamic.cjs.map +0 -1
  51. package/dist/cjs/hasLocale.cjs +0 -25
  52. package/dist/cjs/hasLocale.cjs.map +0 -1
  53. package/dist/cjs/package.cjs +0 -122
  54. package/dist/cjs/package.cjs.map +0 -1
  55. package/dist/cjs/useDictionary.cjs +0 -45
  56. package/dist/cjs/useDictionary.cjs.map +0 -1
  57. package/dist/cjs/useDictionaryDynamic.cjs +0 -37
  58. package/dist/cjs/useDictionaryDynamic.cjs.map +0 -1
  59. package/dist/cjs/useTranslationsDictionary.cjs +0 -37
  60. package/dist/cjs/useTranslationsDictionary.cjs.map +0 -1
  61. package/dist/cjs/useTranslationsDictionaryDynamic.cjs +0 -29
  62. package/dist/cjs/useTranslationsDictionaryDynamic.cjs.map +0 -1
  63. package/dist/esm/_virtual/_rolldown/runtime.mjs +0 -8
  64. package/dist/esm/client/helpers.mjs +0 -59
  65. package/dist/esm/client/helpers.mjs.map +0 -1
  66. package/dist/esm/client/useTranslations.mjs +0 -37
  67. package/dist/esm/client/useTranslations.mjs.map +0 -1
  68. package/dist/esm/createFormatter.mjs +0 -57
  69. package/dist/esm/createFormatter.mjs.map +0 -1
  70. package/dist/esm/createTranslator.mjs +0 -108
  71. package/dist/esm/createTranslator.mjs.map +0 -1
  72. package/dist/esm/getTranslationsDictionary.mjs +0 -29
  73. package/dist/esm/getTranslationsDictionary.mjs.map +0 -1
  74. package/dist/esm/getTranslationsDictionaryDynamic.mjs +0 -25
  75. package/dist/esm/getTranslationsDictionaryDynamic.mjs.map +0 -1
  76. package/dist/esm/hasLocale.mjs +0 -23
  77. package/dist/esm/hasLocale.mjs.map +0 -1
  78. package/dist/esm/package.mjs +0 -119
  79. package/dist/esm/package.mjs.map +0 -1
  80. package/dist/esm/useDictionary.mjs +0 -43
  81. package/dist/esm/useDictionary.mjs.map +0 -1
  82. package/dist/esm/useDictionaryDynamic.mjs +0 -35
  83. package/dist/esm/useDictionaryDynamic.mjs.map +0 -1
  84. package/dist/esm/useTranslationsDictionary.mjs +0 -35
  85. package/dist/esm/useTranslationsDictionary.mjs.map +0 -1
  86. package/dist/esm/useTranslationsDictionaryDynamic.mjs +0 -27
  87. package/dist/esm/useTranslationsDictionaryDynamic.mjs.map +0 -1
  88. package/dist/types/client/helpers.d.ts +0 -45
  89. package/dist/types/client/helpers.d.ts.map +0 -1
  90. package/dist/types/client/useTranslations.d.ts +0 -74
  91. package/dist/types/client/useTranslations.d.ts.map +0 -1
  92. package/dist/types/createFormatter.d.ts +0 -15
  93. package/dist/types/createFormatter.d.ts.map +0 -1
  94. package/dist/types/createTranslator.d.ts +0 -40
  95. package/dist/types/createTranslator.d.ts.map +0 -1
  96. package/dist/types/getTranslationsDictionary.d.ts +0 -15
  97. package/dist/types/getTranslationsDictionary.d.ts.map +0 -1
  98. package/dist/types/getTranslationsDictionaryDynamic.d.ts +0 -12
  99. package/dist/types/getTranslationsDictionaryDynamic.d.ts.map +0 -1
  100. package/dist/types/hasLocale.d.ts +0 -20
  101. package/dist/types/hasLocale.d.ts.map +0 -1
  102. package/dist/types/useDictionary.d.ts +0 -22
  103. package/dist/types/useDictionary.d.ts.map +0 -1
  104. package/dist/types/useDictionaryDynamic.d.ts +0 -15
  105. package/dist/types/useDictionaryDynamic.d.ts.map +0 -1
  106. package/dist/types/useTranslationsDictionary.d.ts +0 -19
  107. package/dist/types/useTranslationsDictionary.d.ts.map +0 -1
  108. package/dist/types/useTranslationsDictionaryDynamic.d.ts +0 -12
  109. package/dist/types/useTranslationsDictionaryDynamic.d.ts.map +0 -1
@@ -4,9 +4,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
  const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
5
5
  let _intlayer_config_built = require("@intlayer/config/built");
6
6
  let next_intlayer = require("next-intlayer");
7
- let react_jsx_runtime = require("react/jsx-runtime");
8
7
  let _intlayer_config_colors = require("@intlayer/config/colors");
9
8
  let _intlayer_config_logger = require("@intlayer/config/logger");
9
+ let react_jsx_runtime = require("react/jsx-runtime");
10
10
 
11
11
  //#region src/client/NextIntlClientProvider.tsx
12
12
  /**
@@ -1,19 +1,62 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_useDictionaryDynamic = require('../useDictionaryDynamic.cjs');
3
- const require_useDictionary = require('../useDictionary.cjs');
4
- const require_client_helpers = require('./helpers.cjs');
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
5
3
  const require_client_NextIntlClientProvider = require('./NextIntlClientProvider.cjs');
6
4
  const require_client_useLocale = require('./useLocale.cjs');
7
- const require_client_useTranslations = require('./useTranslations.cjs');
5
+ let _intlayer_use_intl = require("@intlayer/use-intl");
8
6
 
9
- exports.IntlProvider = require_client_helpers.IntlProvider;
7
+ Object.defineProperty(exports, 'IntlProvider', {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _intlayer_use_intl.IntlProvider;
11
+ }
12
+ });
10
13
  exports.NextIntlClientProvider = require_client_NextIntlClientProvider.NextIntlClientProvider;
11
- exports.useDictionary = require_useDictionary.useDictionary;
12
- exports.useDictionaryDynamic = require_useDictionaryDynamic.useDictionaryDynamic;
13
- exports.useExtracted = require_client_helpers.useExtracted;
14
- exports.useFormatter = require_client_helpers.useFormatter;
14
+ Object.defineProperty(exports, 'useDictionary', {
15
+ enumerable: true,
16
+ get: function () {
17
+ return _intlayer_use_intl.useDictionary;
18
+ }
19
+ });
20
+ Object.defineProperty(exports, 'useDictionaryDynamic', {
21
+ enumerable: true,
22
+ get: function () {
23
+ return _intlayer_use_intl.useDictionaryDynamic;
24
+ }
25
+ });
26
+ Object.defineProperty(exports, 'useExtracted', {
27
+ enumerable: true,
28
+ get: function () {
29
+ return _intlayer_use_intl._useExtracted;
30
+ }
31
+ });
32
+ Object.defineProperty(exports, 'useFormatter', {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _intlayer_use_intl.useFormatter;
36
+ }
37
+ });
15
38
  exports.useLocale = require_client_useLocale.useLocale;
16
- exports.useMessages = require_client_helpers.useMessages;
17
- exports.useNow = require_client_helpers.useNow;
18
- exports.useTimeZone = require_client_helpers.useTimeZone;
19
- exports.useTranslations = require_client_useTranslations.useTranslations;
39
+ Object.defineProperty(exports, 'useMessages', {
40
+ enumerable: true,
41
+ get: function () {
42
+ return _intlayer_use_intl.useMessages;
43
+ }
44
+ });
45
+ Object.defineProperty(exports, 'useNow', {
46
+ enumerable: true,
47
+ get: function () {
48
+ return _intlayer_use_intl.useNow;
49
+ }
50
+ });
51
+ Object.defineProperty(exports, 'useTimeZone', {
52
+ enumerable: true,
53
+ get: function () {
54
+ return _intlayer_use_intl.useTimeZone;
55
+ }
56
+ });
57
+ Object.defineProperty(exports, 'useTranslations', {
58
+ enumerable: true,
59
+ get: function () {
60
+ return _intlayer_use_intl.useTranslations;
61
+ }
62
+ });
@@ -1,23 +1,100 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
2
3
  const require_routing = require('./routing.cjs');
3
- const require_hasLocale = require('./hasLocale.cjs');
4
- const require_useDictionaryDynamic = require('./useDictionaryDynamic.cjs');
5
- const require_useDictionary = require('./useDictionary.cjs');
6
- const require_client_helpers = require('./client/helpers.cjs');
7
4
  const require_client_NextIntlClientProvider = require('./client/NextIntlClientProvider.cjs');
8
5
  const require_client_useLocale = require('./client/useLocale.cjs');
9
- const require_client_useTranslations = require('./client/useTranslations.cjs');
6
+ let _intlayer_use_intl = require("@intlayer/use-intl");
10
7
 
11
- exports.IntlProvider = require_client_helpers.IntlProvider;
8
+ Object.defineProperty(exports, 'IntlError', {
9
+ enumerable: true,
10
+ get: function () {
11
+ return _intlayer_use_intl.IntlError;
12
+ }
13
+ });
14
+ Object.defineProperty(exports, 'IntlErrorCode', {
15
+ enumerable: true,
16
+ get: function () {
17
+ return _intlayer_use_intl.IntlErrorCode;
18
+ }
19
+ });
20
+ Object.defineProperty(exports, 'IntlProvider', {
21
+ enumerable: true,
22
+ get: function () {
23
+ return _intlayer_use_intl.IntlProvider;
24
+ }
25
+ });
12
26
  exports.NextIntlClientProvider = require_client_NextIntlClientProvider.NextIntlClientProvider;
27
+ Object.defineProperty(exports, 'createFormatter', {
28
+ enumerable: true,
29
+ get: function () {
30
+ return _intlayer_use_intl.createFormatter;
31
+ }
32
+ });
33
+ Object.defineProperty(exports, 'createTranslator', {
34
+ enumerable: true,
35
+ get: function () {
36
+ return _intlayer_use_intl.createTranslator;
37
+ }
38
+ });
13
39
  exports.defineRouting = require_routing.defineRouting;
14
- exports.hasLocale = require_hasLocale.hasLocale;
15
- exports.useDictionary = require_useDictionary.useDictionary;
16
- exports.useDictionaryDynamic = require_useDictionaryDynamic.useDictionaryDynamic;
17
- exports.useExtracted = require_client_helpers.useExtracted;
18
- exports.useFormatter = require_client_helpers.useFormatter;
40
+ Object.defineProperty(exports, 'hasLocale', {
41
+ enumerable: true,
42
+ get: function () {
43
+ return _intlayer_use_intl.hasLocale;
44
+ }
45
+ });
46
+ Object.defineProperty(exports, 'initializeConfig', {
47
+ enumerable: true,
48
+ get: function () {
49
+ return _intlayer_use_intl.initializeConfig;
50
+ }
51
+ });
52
+ Object.defineProperty(exports, 'useDictionary', {
53
+ enumerable: true,
54
+ get: function () {
55
+ return _intlayer_use_intl.useDictionary;
56
+ }
57
+ });
58
+ Object.defineProperty(exports, 'useDictionaryDynamic', {
59
+ enumerable: true,
60
+ get: function () {
61
+ return _intlayer_use_intl.useDictionaryDynamic;
62
+ }
63
+ });
64
+ Object.defineProperty(exports, 'useExtracted', {
65
+ enumerable: true,
66
+ get: function () {
67
+ return _intlayer_use_intl._useExtracted;
68
+ }
69
+ });
70
+ Object.defineProperty(exports, 'useFormatter', {
71
+ enumerable: true,
72
+ get: function () {
73
+ return _intlayer_use_intl.useFormatter;
74
+ }
75
+ });
19
76
  exports.useLocale = require_client_useLocale.useLocale;
20
- exports.useMessages = require_client_helpers.useMessages;
21
- exports.useNow = require_client_helpers.useNow;
22
- exports.useTimeZone = require_client_helpers.useTimeZone;
23
- exports.useTranslations = require_client_useTranslations.useTranslations;
77
+ Object.defineProperty(exports, 'useMessages', {
78
+ enumerable: true,
79
+ get: function () {
80
+ return _intlayer_use_intl.useMessages;
81
+ }
82
+ });
83
+ Object.defineProperty(exports, 'useNow', {
84
+ enumerable: true,
85
+ get: function () {
86
+ return _intlayer_use_intl.useNow;
87
+ }
88
+ });
89
+ Object.defineProperty(exports, 'useTimeZone', {
90
+ enumerable: true,
91
+ get: function () {
92
+ return _intlayer_use_intl.useTimeZone;
93
+ }
94
+ });
95
+ Object.defineProperty(exports, 'useTranslations', {
96
+ enumerable: true,
97
+ get: function () {
98
+ return _intlayer_use_intl.useTranslations;
99
+ }
100
+ });
@@ -4,10 +4,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
  const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
5
5
  const require_navigation_localizeHref = require('./localizeHref.cjs');
6
6
  let next_intlayer = require("next-intlayer");
7
- let react = require("react");
8
7
  let react_jsx_runtime = require("react/jsx-runtime");
9
8
  let next_link = require("next/link");
10
9
  next_link = require_runtime.__toESM(next_link);
10
+ let react = require("react");
11
11
 
12
12
  //#region src/navigation/Link.tsx
13
13
  /**
@@ -0,0 +1,28 @@
1
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ let _intlayer_config_built = require("@intlayer/config/built");
4
+ let _intlayer_config_colors = require("@intlayer/config/colors");
5
+ let _intlayer_config_logger = require("@intlayer/config/logger");
6
+
7
+ //#region src/server/getRequestConfig.ts
8
+ /**
9
+ * Drop-in for next-intl's `getRequestConfig`.
10
+ *
11
+ * In next-intl this registers the per-request config (locale + messages) read
12
+ * by its own plugin. With intlayer the locale is resolved from routing /
13
+ * storage and messages come from compiled dictionaries, so the returned config
14
+ * is never consumed — this is an identity passthrough kept so existing
15
+ * `i18n/request.ts` files keep resolving and type-checking.
16
+ *
17
+ * @deprecated getRequestConfig has no use case with intlayer. The locale and
18
+ * messages are resolved automatically; the file can be removed.
19
+ */
20
+ const getRequestConfig = (createRequestConfig) => {
21
+ if (process.env.NODE_ENV === "development") (0, _intlayer_config_logger.getAppLogger)({ log: _intlayer_config_built.log })(`${(0, _intlayer_config_logger.colorize)("getRequestConfig", _intlayer_config_colors.CYAN)} has no use case with intlayer. The locale and messages are resolved automatically; the i18n/request.ts file can be removed`);
22
+ return createRequestConfig;
23
+ };
24
+
25
+ //#endregion
26
+ exports.default = getRequestConfig;
27
+ exports.getRequestConfig = getRequestConfig;
28
+ //# sourceMappingURL=getRequestConfig.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRequestConfig.cjs","names":["CYAN"],"sources":["../../../src/server/getRequestConfig.ts"],"sourcesContent":["import { log } from '@intlayer/config/built';\nimport { CYAN } from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport type { getRequestConfig as _getRequestConfig } from 'next-intl/server';\n\n/**\n * Drop-in for next-intl's `getRequestConfig`.\n *\n * In next-intl this registers the per-request config (locale + messages) read\n * by its own plugin. With intlayer the locale is resolved from routing /\n * storage and messages come from compiled dictionaries, so the returned config\n * is never consumed — this is an identity passthrough kept so existing\n * `i18n/request.ts` files keep resolving and type-checking.\n *\n * @deprecated getRequestConfig has no use case with intlayer. The locale and\n * messages are resolved automatically; the file can be removed.\n */\nexport const getRequestConfig: typeof _getRequestConfig = (\n createRequestConfig\n) => {\n if (process.env.NODE_ENV === 'development') {\n const appLogger = getAppLogger({ log });\n appLogger(\n `${colorize('getRequestConfig', CYAN)} has no use case with intlayer. The locale and messages are resolved automatically; the i18n/request.ts file can be removed`\n );\n }\n\n return createRequestConfig;\n};\n\nexport default getRequestConfig;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAiBA,MAAa,oBACX,wBACG;AACH,KAAI,QAAQ,IAAI,aAAa,cAE3B,2CAD+B,EAAE,iCAAK,CAC7B,CACP,yCAAY,oBAAoBA,6BAAK,CAAC,6HACvC;AAGH,QAAO"}
@@ -1,6 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
3
  const require_server_getLocale = require('./getLocale.cjs');
3
- const require_createTranslator = require('../createTranslator.cjs');
4
+ let _intlayer_use_intl = require("@intlayer/use-intl");
4
5
 
5
6
  //#region src/server/getTranslations.ts
6
7
  /**
@@ -11,8 +12,9 @@ const require_createTranslator = require('../createTranslator.cjs');
11
12
  * arguments (`{value, number}`). Rich text is available through `t.rich()`
12
13
  * and `t.markup()`.
13
14
  *
14
- * Also accepts an options object `{ namespace, locale }` to match next-intl's
15
- * full server API surface.
15
+ * Resolves the active locale from the current request (or the `locale` option)
16
+ * and delegates to `@intlayer/use-intl`'s `createTranslator`, the same runtime
17
+ * that backs the client `useTranslations`.
16
18
  *
17
19
  * @example
18
20
  * ```ts
@@ -37,7 +39,10 @@ const getTranslations = (async (namespaceOrOptions) => {
37
39
  namespace = namespaceOrOptions.namespace;
38
40
  localeOverride = namespaceOrOptions.locale;
39
41
  } else namespace = namespaceOrOptions;
40
- return require_createTranslator.createTranslator(localeOverride ?? await require_server_getLocale.getLocale(), namespace);
42
+ return (0, _intlayer_use_intl.createTranslator)({
43
+ locale: localeOverride ?? await require_server_getLocale.getLocale(),
44
+ namespace
45
+ });
41
46
  });
42
47
 
43
48
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"getTranslations.cjs","names":["createTranslator","getLocale"],"sources":["../../../src/server/getTranslations.ts"],"sourcesContent":["import type { ValidDotPathsFor } from '@intlayer/core/transpiler';\nimport type {\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { ReactNode } from 'react';\nimport {\n createTranslator,\n type MarkupChunkRenderer,\n type RichChunkRenderer,\n} from '../createTranslator';\nimport { getLocale } from './getLocale';\n\n/**\n * Options accepted by the options-object overload of {@link getTranslations}.\n */\ntype GetTranslationsOptions<N extends DictionaryKeys> = {\n /** The dictionary namespace to scope translations to. */\n namespace?: N;\n /** Override the locale instead of reading it from the current request. */\n locale?: LocalesValues;\n};\n\n/**\n * The translation function returned by {@link getTranslations}.\n *\n * Beyond the plain call signature, the function exposes:\n * - `has(key)` — returns `true` when the key exists in the namespace.\n * - `raw(key)` — returns the unprocessed message value.\n * - `rich(key, values)` — resolves `<tag>chunks</tag>` markup to React nodes.\n * - `markup(key, values)` — resolves `<tag>chunks</tag>` markup to a string.\n */\ntype TranslateFunction<N extends DictionaryKeys> = {\n /** Translate a key to a string, with optional ICU interpolation params. */\n <P extends ValidDotPathsFor<N>>(\n key: P,\n params?: Record<string, unknown>\n ): string;\n /** Returns `true` if the given key exists in the namespace. */\n has<P extends ValidDotPathsFor<N>>(key: P): boolean;\n /** Returns the raw unprocessed message for the given key. */\n raw<P extends ValidDotPathsFor<N>>(key: P): unknown;\n /** Resolves rich-text markup, mapping tags through React renderers. */\n rich<P extends ValidDotPathsFor<N>>(\n key: P,\n values?: Record<string, RichChunkRenderer | ReactNode>\n ): ReactNode;\n /** Resolves rich-text markup, mapping tags through string renderers. */\n markup<P extends ValidDotPathsFor<N>>(\n key: P,\n values?: Record<string, MarkupChunkRenderer | string | number>\n ): string;\n};\n\n/** Loosely-typed function returned for nested `'dict.scope'` namespaces. */\ntype LooseTranslateFunction = {\n (key: string, params?: Record<string, unknown>): string;\n has(key: string): boolean;\n raw(key: string): unknown;\n rich(\n key: string,\n values?: Record<string, RichChunkRenderer | ReactNode>\n ): ReactNode;\n markup(\n key: string,\n values?: Record<string, MarkupChunkRenderer | string | number>\n ): string;\n};\n\n/**\n * Overload set for {@link getTranslations}:\n *\n * 1. A bare dictionary key → fully-typed `t()` (autocompleted dot-paths).\n * 2. An options object `{ namespace?, locale? }` → typed when namespace is\n * a known `DictionaryKeys` value.\n * 3. A nested namespace `'dictionary.sub.scope'` → `t()` accepts relative\n * `string` paths, matching next-intl's scoped-namespace behaviour.\n * 4. No namespace → root scope; the first segment of each key designates\n * the dictionary (`t('about.title')`).\n */\ntype GetTranslations = {\n <N extends DictionaryKeys>(namespace: N): Promise<TranslateFunction<N>>;\n <N extends DictionaryKeys>(\n options: GetTranslationsOptions<N>\n ): Promise<TranslateFunction<N>>;\n (namespace: `${string}.${string}`): Promise<LooseTranslateFunction>;\n (): Promise<LooseTranslateFunction>;\n};\n\n/**\n * Drop-in for next-intl's server `getTranslations()`.\n *\n * Messages support ICU MessageFormat syntax: simple arguments (`{name}`),\n * plural (`{count, plural, one {…} other {…}}`, `#`), select, and formatted\n * arguments (`{value, number}`). Rich text is available through `t.rich()`\n * and `t.markup()`.\n *\n * Also accepts an options object `{ namespace, locale }` to match next-intl's\n * full server API surface.\n *\n * @example\n * ```ts\n * // Bare namespace — fully typed dot-paths\n * const t = await getTranslations('about');\n * return <h1>{t('counter.label')}</h1>;\n *\n * // ICU plural\n * t('items', { count: 3 });\n *\n * // Options object with locale override\n * const t = await getTranslations({ namespace: 'about', locale: 'fr' });\n *\n * // Rich text\n * t.rich('terms', { link: (chunks) => <a href=\"/terms\">{chunks}</a> });\n * ```\n */\nexport const getTranslations: GetTranslations = (async (\n namespaceOrOptions?: string | GetTranslationsOptions<DictionaryKeys>\n) => {\n let namespace: string | undefined;\n let localeOverride: LocalesValues | undefined;\n\n if (typeof namespaceOrOptions === 'object' && namespaceOrOptions !== null) {\n namespace = namespaceOrOptions.namespace;\n localeOverride = namespaceOrOptions.locale;\n } else {\n namespace = namespaceOrOptions as string | undefined;\n }\n\n const locale = localeOverride ?? (await getLocale());\n\n return createTranslator(locale as LocalesValues, namespace);\n}) as GetTranslations;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoHA,MAAa,mBAAoC,OAC/C,uBACG;CACH,IAAI;CACJ,IAAI;AAEJ,KAAI,OAAO,uBAAuB,YAAY,uBAAuB,MAAM;AACzE,cAAY,mBAAmB;AAC/B,mBAAiB,mBAAmB;OAEpC,aAAY;AAKd,QAAOA,0CAFQ,kBAAmB,MAAMC,oCAAW,EAEF,UAAU"}
1
+ {"version":3,"file":"getTranslations.cjs","names":["getLocale"],"sources":["../../../src/server/getTranslations.ts"],"sourcesContent":["import type {\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport {\n createTranslator,\n type LooseTranslateFunction,\n type TranslateFunction,\n} from '@intlayer/use-intl';\nimport { getLocale } from './getLocale';\n\n/**\n * Options accepted by the options-object overload of {@link getTranslations}.\n */\ntype GetTranslationsOptions<N extends DictionaryKeys> = {\n /** The dictionary namespace to scope translations to. */\n namespace?: N;\n /** Override the locale instead of reading it from the current request. */\n locale?: LocalesValues;\n};\n\n/**\n * Overload set for {@link getTranslations}:\n *\n * 1. A bare dictionary key → fully-typed `t()` (autocompleted dot-paths).\n * 2. An options object `{ namespace?, locale? }` → typed when namespace is\n * a known `DictionaryKeys` value.\n * 3. A nested namespace `'dictionary.sub.scope'` → `t()` accepts relative\n * `string` paths, matching next-intl's scoped-namespace behaviour.\n * 4. No namespace → root scope; the first segment of each key designates\n * the dictionary (`t('about.title')`).\n *\n * The translate function shape (`t`, `t.rich`, `t.markup`, `t.raw`, `t.has`)\n * is shared with `@intlayer/use-intl`.\n */\ntype GetTranslations = {\n <N extends DictionaryKeys>(namespace: N): Promise<TranslateFunction<N>>;\n <N extends DictionaryKeys>(\n options: GetTranslationsOptions<N>\n ): Promise<TranslateFunction<N>>;\n (namespace: `${string}.${string}`): Promise<LooseTranslateFunction>;\n (): Promise<LooseTranslateFunction>;\n};\n\n/**\n * Drop-in for next-intl's server `getTranslations()`.\n *\n * Messages support ICU MessageFormat syntax: simple arguments (`{name}`),\n * plural (`{count, plural, one {…} other {…}}`, `#`), select, and formatted\n * arguments (`{value, number}`). Rich text is available through `t.rich()`\n * and `t.markup()`.\n *\n * Resolves the active locale from the current request (or the `locale` option)\n * and delegates to `@intlayer/use-intl`'s `createTranslator`, the same runtime\n * that backs the client `useTranslations`.\n *\n * @example\n * ```ts\n * // Bare namespace — fully typed dot-paths\n * const t = await getTranslations('about');\n * return <h1>{t('counter.label')}</h1>;\n *\n * // ICU plural\n * t('items', { count: 3 });\n *\n * // Options object with locale override\n * const t = await getTranslations({ namespace: 'about', locale: 'fr' });\n *\n * // Rich text\n * t.rich('terms', { link: (chunks) => <a href=\"/terms\">{chunks}</a> });\n * ```\n */\nexport const getTranslations: GetTranslations = (async (\n namespaceOrOptions?: string | GetTranslationsOptions<DictionaryKeys>\n) => {\n let namespace: string | undefined;\n let localeOverride: LocalesValues | undefined;\n\n if (typeof namespaceOrOptions === 'object' && namespaceOrOptions !== null) {\n namespace = namespaceOrOptions.namespace;\n localeOverride = namespaceOrOptions.locale;\n } else {\n namespace = namespaceOrOptions as string | undefined;\n }\n\n const locale = localeOverride ?? (await getLocale());\n\n return createTranslator({ locale: locale as LocalesValues, namespace });\n}) as GetTranslations;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwEA,MAAa,mBAAoC,OAC/C,uBACG;CACH,IAAI;CACJ,IAAI;AAEJ,KAAI,OAAO,uBAAuB,YAAY,uBAAuB,MAAM;AACzE,cAAY,mBAAmB;AAC/B,mBAAiB,mBAAmB;OAEpC,aAAY;AAKd,iDAAwB;EAAE,QAFX,kBAAmB,MAAMA,oCAAW;EAEQ;EAAW,CAAC"}
@@ -1,14 +1,16 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_createFormatter = require('../createFormatter.cjs');
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
3
  const require_server_getLocale = require('./getLocale.cjs');
4
+ let _intlayer_use_intl = require("@intlayer/use-intl");
4
5
 
5
6
  //#region src/server/helpers.ts
6
7
  /**
7
8
  * Drop-in for next-intl's server `getFormatter()`.
8
- * Returns locale-aware formatters backed by the native `Intl.*` APIs.
9
+ * Returns locale-aware formatters backed by the native `Intl.*` APIs,
10
+ * built by `@intlayer/use-intl`'s `createFormatter`.
9
11
  */
10
12
  const getFormatter = (async (options) => {
11
- return require_createFormatter.createFormatter(options?.locale ?? await require_server_getLocale.getLocale());
13
+ return (0, _intlayer_use_intl.createFormatter)({ locale: options?.locale ?? await require_server_getLocale.getLocale() });
12
14
  });
13
15
  /**
14
16
  * Drop-in for next-intl's server `getNow()`.
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.cjs","names":["createFormatter","getLocale"],"sources":["../../../src/server/helpers.ts"],"sourcesContent":["import type {\n getFormatter as _getFormatter,\n getNow as _getNow,\n getTimeZone as _getTimeZone,\n} from 'next-intl/server';\nimport { createFormatter } from '../createFormatter';\nimport { getLocale } from './getLocale';\n\n/**\n * Drop-in for next-intl's server `getFormatter()`.\n * Returns locale-aware formatters backed by the native `Intl.*` APIs.\n */\nexport const getFormatter: typeof _getFormatter = (async (options?: {\n locale?: string;\n}) => {\n const locale = options?.locale ?? (await getLocale());\n return createFormatter(locale as string);\n}) as typeof _getFormatter;\n\n/**\n * Drop-in for next-intl's server `getNow()`.\n * Returns the current `Date`.\n */\nexport const getNow: typeof _getNow = (async () =>\n new Date()) as typeof _getNow;\n\n/**\n * Drop-in for next-intl's server `getTimeZone()`.\n * Returns the system time zone resolved from `Intl.DateTimeFormat`.\n */\nexport const getTimeZone: typeof _getTimeZone = (async () =>\n Intl.DateTimeFormat().resolvedOptions().timeZone) as typeof _getTimeZone;\n"],"mappings":";;;;;;;;;AAYA,MAAa,gBAAsC,OAAO,YAEpD;AAEJ,QAAOA,wCADQ,SAAS,UAAW,MAAMC,oCAAW,CACZ;;;;;;AAO1C,MAAa,UAA0B,4BACrC,IAAI,MAAM;;;;;AAMZ,MAAa,eAAoC,YAC/C,KAAK,gBAAgB,CAAC,iBAAiB,CAAC"}
1
+ {"version":3,"file":"helpers.cjs","names":["getLocale"],"sources":["../../../src/server/helpers.ts"],"sourcesContent":["import { createFormatter } from '@intlayer/use-intl';\nimport type {\n getFormatter as _getFormatter,\n getNow as _getNow,\n getTimeZone as _getTimeZone,\n} from 'next-intl/server';\nimport { getLocale } from './getLocale';\n\n/**\n * Drop-in for next-intl's server `getFormatter()`.\n * Returns locale-aware formatters backed by the native `Intl.*` APIs,\n * built by `@intlayer/use-intl`'s `createFormatter`.\n */\nexport const getFormatter: typeof _getFormatter = (async (options?: {\n locale?: string;\n}) => {\n const locale = options?.locale ?? (await getLocale());\n return createFormatter({ locale: locale as string });\n}) as typeof _getFormatter;\n\n/**\n * Drop-in for next-intl's server `getNow()`.\n * Returns the current `Date`.\n */\nexport const getNow: typeof _getNow = (async () =>\n new Date()) as typeof _getNow;\n\n/**\n * Drop-in for next-intl's server `getTimeZone()`.\n * Returns the system time zone resolved from `Intl.DateTimeFormat`.\n */\nexport const getTimeZone: typeof _getTimeZone = (async () =>\n Intl.DateTimeFormat().resolvedOptions().timeZone) as typeof _getTimeZone;\n"],"mappings":";;;;;;;;;;;AAaA,MAAa,gBAAsC,OAAO,YAEpD;AAEJ,gDAAuB,EAAE,QADV,SAAS,UAAW,MAAMA,oCAAW,EACD,CAAC;;;;;;AAOtD,MAAa,UAA0B,4BACrC,IAAI,MAAM;;;;;AAMZ,MAAa,eAAoC,YAC/C,KAAK,gBAAgB,CAAC,iBAAiB,CAAC"}
@@ -3,6 +3,8 @@ const require_server_getLocale = require('./getLocale.cjs');
3
3
  const require_getDictionary = require('../getDictionary.cjs');
4
4
  const require_getDictionaryDynamic = require('../getDictionaryDynamic.cjs');
5
5
  const require_server_helpers = require('./helpers.cjs');
6
+ const require_server_getRequestConfig = require('./getRequestConfig.cjs');
7
+ const require_server_setRequestLocale = require('./setRequestLocale.cjs');
6
8
  const require_server_setLocale = require('./setLocale.cjs');
7
9
  const require_server_getTranslations = require('./getTranslations.cjs');
8
10
  const require_server_getMessages = require('./getMessages.cjs');
@@ -13,6 +15,8 @@ exports.getFormatter = require_server_helpers.getFormatter;
13
15
  exports.getLocale = require_server_getLocale.getLocale;
14
16
  exports.getMessages = require_server_getMessages.getMessages;
15
17
  exports.getNow = require_server_helpers.getNow;
18
+ exports.getRequestConfig = require_server_getRequestConfig;
16
19
  exports.getTimeZone = require_server_helpers.getTimeZone;
17
20
  exports.getTranslations = require_server_getTranslations.getTranslations;
18
- exports.setLocale = require_server_setLocale.setLocale;
21
+ exports.setLocale = require_server_setLocale.setLocale;
22
+ exports.setRequestLocale = require_server_setRequestLocale.setRequestLocale;
@@ -0,0 +1,30 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ let _intlayer_config_built = require("@intlayer/config/built");
4
+ let _intlayer_config_colors = require("@intlayer/config/colors");
5
+ let _intlayer_config_logger = require("@intlayer/config/logger");
6
+
7
+ //#region src/server/setRequestLocale.ts
8
+ /**
9
+ * Drop-in for next-intl's `setRequestLocale`.
10
+ *
11
+ * In next-intl this stores the locale in a request-scoped cache to opt into
12
+ * static rendering. Intlayer resolves the active locale from the configured
13
+ * `routing.storage` (cookie / header) or the localized route segment, so there
14
+ * is nothing to set here — this is a no-op kept for API compatibility.
15
+ *
16
+ * @deprecated setRequestLocale has no use case with intlayer. The locale is
17
+ * resolved automatically from routing / storage.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * setRequestLocale(locale); // safe to keep, but has no effect
22
+ * ```
23
+ */
24
+ const setRequestLocale = (_locale) => {
25
+ if (process.env.NODE_ENV === "development") (0, _intlayer_config_logger.getAppLogger)({ log: _intlayer_config_built.log })(`${(0, _intlayer_config_logger.colorize)("setRequestLocale", _intlayer_config_colors.CYAN)} has no use case with intlayer. The locale is resolved automatically from routing and storage`);
26
+ };
27
+
28
+ //#endregion
29
+ exports.setRequestLocale = setRequestLocale;
30
+ //# sourceMappingURL=setRequestLocale.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setRequestLocale.cjs","names":["CYAN"],"sources":["../../../src/server/setRequestLocale.ts"],"sourcesContent":["import { log } from '@intlayer/config/built';\nimport { CYAN } from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport type { setRequestLocale as _setRequestLocale } from 'next-intl/server';\n\n/**\n * Drop-in for next-intl's `setRequestLocale`.\n *\n * In next-intl this stores the locale in a request-scoped cache to opt into\n * static rendering. Intlayer resolves the active locale from the configured\n * `routing.storage` (cookie / header) or the localized route segment, so there\n * is nothing to set here — this is a no-op kept for API compatibility.\n *\n * @deprecated setRequestLocale has no use case with intlayer. The locale is\n * resolved automatically from routing / storage.\n *\n * @example\n * ```ts\n * setRequestLocale(locale); // safe to keep, but has no effect\n * ```\n */\nexport const setRequestLocale: typeof _setRequestLocale = (_locale): void => {\n if (process.env.NODE_ENV === 'development') {\n const appLogger = getAppLogger({ log });\n appLogger(\n `${colorize('setRequestLocale', CYAN)} has no use case with intlayer. The locale is resolved automatically from routing and storage`\n );\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAqBA,MAAa,oBAA8C,YAAkB;AAC3E,KAAI,QAAQ,IAAI,aAAa,cAE3B,2CAD+B,EAAE,iCAAK,CAC7B,CACP,yCAAY,oBAAoBA,6BAAK,CAAC,+FACvC"}
@@ -2,9 +2,9 @@
2
2
 
3
3
  import { log } from "@intlayer/config/built";
4
4
  import { IntlayerClientProvider } from "next-intlayer";
5
- import { jsx } from "react/jsx-runtime";
6
5
  import { CYAN } from "@intlayer/config/colors";
7
6
  import { colorize, getAppLogger } from "@intlayer/config/logger";
7
+ import { jsx } from "react/jsx-runtime";
8
8
 
9
9
  //#region src/client/NextIntlClientProvider.tsx
10
10
  /**
@@ -1,8 +1,5 @@
1
- import { useDictionaryDynamic } from "../useDictionaryDynamic.mjs";
2
- import { useDictionary } from "../useDictionary.mjs";
3
- import { IntlProvider, useExtracted, useFormatter, useMessages, useNow, useTimeZone } from "./helpers.mjs";
4
1
  import { NextIntlClientProvider } from "./NextIntlClientProvider.mjs";
5
2
  import { useLocale } from "./useLocale.mjs";
6
- import { useTranslations } from "./useTranslations.mjs";
3
+ import { IntlProvider, _useExtracted as useExtracted, useDictionary, useDictionaryDynamic, useFormatter, useMessages, useNow, useTimeZone, useTranslations } from "@intlayer/use-intl";
7
4
 
8
5
  export { IntlProvider, NextIntlClientProvider, useDictionary, useDictionaryDynamic, useExtracted, useFormatter, useLocale, useMessages, useNow, useTimeZone, useTranslations };
@@ -1,10 +1,7 @@
1
1
  import { defineRouting } from "./routing.mjs";
2
- import { hasLocale } from "./hasLocale.mjs";
3
- import { useDictionaryDynamic } from "./useDictionaryDynamic.mjs";
4
- import { useDictionary } from "./useDictionary.mjs";
5
- import { IntlProvider, useExtracted, useFormatter, useMessages, useNow, useTimeZone } from "./client/helpers.mjs";
6
2
  import { NextIntlClientProvider } from "./client/NextIntlClientProvider.mjs";
7
3
  import { useLocale } from "./client/useLocale.mjs";
8
- import { useTranslations } from "./client/useTranslations.mjs";
4
+ import { IntlProvider, useDictionary, useDictionaryDynamic, useExtracted, useFormatter, useMessages, useNow, useTimeZone, useTranslations } from "./client/index.mjs";
5
+ import { IntlError, IntlErrorCode, createFormatter, createTranslator, hasLocale, initializeConfig } from "@intlayer/use-intl";
9
6
 
10
- export { IntlProvider, NextIntlClientProvider, defineRouting, hasLocale, useDictionary, useDictionaryDynamic, useExtracted, useFormatter, useLocale, useMessages, useNow, useTimeZone, useTranslations };
7
+ export { IntlError, IntlErrorCode, IntlProvider, NextIntlClientProvider, createFormatter, createTranslator, defineRouting, hasLocale, initializeConfig, useDictionary, useDictionaryDynamic, useExtracted, useFormatter, useLocale, useMessages, useNow, useTimeZone, useTranslations };
@@ -2,9 +2,9 @@
2
2
 
3
3
  import { localizeHref } from "./localizeHref.mjs";
4
4
  import { useLocale } from "next-intlayer";
5
- import { forwardRef } from "react";
6
5
  import { jsx } from "react/jsx-runtime";
7
6
  import NextLink from "next/link";
7
+ import { forwardRef } from "react";
8
8
 
9
9
  //#region src/navigation/Link.tsx
10
10
  /**
@@ -0,0 +1,25 @@
1
+ import { log } from "@intlayer/config/built";
2
+ import { CYAN } from "@intlayer/config/colors";
3
+ import { colorize, getAppLogger } from "@intlayer/config/logger";
4
+
5
+ //#region src/server/getRequestConfig.ts
6
+ /**
7
+ * Drop-in for next-intl's `getRequestConfig`.
8
+ *
9
+ * In next-intl this registers the per-request config (locale + messages) read
10
+ * by its own plugin. With intlayer the locale is resolved from routing /
11
+ * storage and messages come from compiled dictionaries, so the returned config
12
+ * is never consumed — this is an identity passthrough kept so existing
13
+ * `i18n/request.ts` files keep resolving and type-checking.
14
+ *
15
+ * @deprecated getRequestConfig has no use case with intlayer. The locale and
16
+ * messages are resolved automatically; the file can be removed.
17
+ */
18
+ const getRequestConfig = (createRequestConfig) => {
19
+ getAppLogger({ log })(`${colorize("getRequestConfig", CYAN)} has no use case with intlayer. The locale and messages are resolved automatically; the i18n/request.ts file can be removed`);
20
+ return createRequestConfig;
21
+ };
22
+
23
+ //#endregion
24
+ export { getRequestConfig as default, getRequestConfig };
25
+ //# sourceMappingURL=getRequestConfig.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRequestConfig.mjs","names":[],"sources":["../../../src/server/getRequestConfig.ts"],"sourcesContent":["import { log } from '@intlayer/config/built';\nimport { CYAN } from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport type { getRequestConfig as _getRequestConfig } from 'next-intl/server';\n\n/**\n * Drop-in for next-intl's `getRequestConfig`.\n *\n * In next-intl this registers the per-request config (locale + messages) read\n * by its own plugin. With intlayer the locale is resolved from routing /\n * storage and messages come from compiled dictionaries, so the returned config\n * is never consumed — this is an identity passthrough kept so existing\n * `i18n/request.ts` files keep resolving and type-checking.\n *\n * @deprecated getRequestConfig has no use case with intlayer. The locale and\n * messages are resolved automatically; the file can be removed.\n */\nexport const getRequestConfig: typeof _getRequestConfig = (\n createRequestConfig\n) => {\n if (process.env.NODE_ENV === 'development') {\n const appLogger = getAppLogger({ log });\n appLogger(\n `${colorize('getRequestConfig', CYAN)} has no use case with intlayer. The locale and messages are resolved automatically; the i18n/request.ts file can be removed`\n );\n }\n\n return createRequestConfig;\n};\n\nexport default getRequestConfig;\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAa,oBACX,wBACG;AAGD,CADkB,aAAa,EAAE,KAAK,CAC7B,CACP,GAAG,SAAS,oBAAoB,KAAK,CAAC,6HACvC;AAGH,QAAO"}
@@ -1,5 +1,5 @@
1
1
  import { getLocale } from "./getLocale.mjs";
2
- import { createTranslator } from "../createTranslator.mjs";
2
+ import { createTranslator } from "@intlayer/use-intl";
3
3
 
4
4
  //#region src/server/getTranslations.ts
5
5
  /**
@@ -10,8 +10,9 @@ import { createTranslator } from "../createTranslator.mjs";
10
10
  * arguments (`{value, number}`). Rich text is available through `t.rich()`
11
11
  * and `t.markup()`.
12
12
  *
13
- * Also accepts an options object `{ namespace, locale }` to match next-intl's
14
- * full server API surface.
13
+ * Resolves the active locale from the current request (or the `locale` option)
14
+ * and delegates to `@intlayer/use-intl`'s `createTranslator`, the same runtime
15
+ * that backs the client `useTranslations`.
15
16
  *
16
17
  * @example
17
18
  * ```ts
@@ -36,7 +37,10 @@ const getTranslations = (async (namespaceOrOptions) => {
36
37
  namespace = namespaceOrOptions.namespace;
37
38
  localeOverride = namespaceOrOptions.locale;
38
39
  } else namespace = namespaceOrOptions;
39
- return createTranslator(localeOverride ?? await getLocale(), namespace);
40
+ return createTranslator({
41
+ locale: localeOverride ?? await getLocale(),
42
+ namespace
43
+ });
40
44
  });
41
45
 
42
46
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"getTranslations.mjs","names":[],"sources":["../../../src/server/getTranslations.ts"],"sourcesContent":["import type { ValidDotPathsFor } from '@intlayer/core/transpiler';\nimport type {\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { ReactNode } from 'react';\nimport {\n createTranslator,\n type MarkupChunkRenderer,\n type RichChunkRenderer,\n} from '../createTranslator';\nimport { getLocale } from './getLocale';\n\n/**\n * Options accepted by the options-object overload of {@link getTranslations}.\n */\ntype GetTranslationsOptions<N extends DictionaryKeys> = {\n /** The dictionary namespace to scope translations to. */\n namespace?: N;\n /** Override the locale instead of reading it from the current request. */\n locale?: LocalesValues;\n};\n\n/**\n * The translation function returned by {@link getTranslations}.\n *\n * Beyond the plain call signature, the function exposes:\n * - `has(key)` — returns `true` when the key exists in the namespace.\n * - `raw(key)` — returns the unprocessed message value.\n * - `rich(key, values)` — resolves `<tag>chunks</tag>` markup to React nodes.\n * - `markup(key, values)` — resolves `<tag>chunks</tag>` markup to a string.\n */\ntype TranslateFunction<N extends DictionaryKeys> = {\n /** Translate a key to a string, with optional ICU interpolation params. */\n <P extends ValidDotPathsFor<N>>(\n key: P,\n params?: Record<string, unknown>\n ): string;\n /** Returns `true` if the given key exists in the namespace. */\n has<P extends ValidDotPathsFor<N>>(key: P): boolean;\n /** Returns the raw unprocessed message for the given key. */\n raw<P extends ValidDotPathsFor<N>>(key: P): unknown;\n /** Resolves rich-text markup, mapping tags through React renderers. */\n rich<P extends ValidDotPathsFor<N>>(\n key: P,\n values?: Record<string, RichChunkRenderer | ReactNode>\n ): ReactNode;\n /** Resolves rich-text markup, mapping tags through string renderers. */\n markup<P extends ValidDotPathsFor<N>>(\n key: P,\n values?: Record<string, MarkupChunkRenderer | string | number>\n ): string;\n};\n\n/** Loosely-typed function returned for nested `'dict.scope'` namespaces. */\ntype LooseTranslateFunction = {\n (key: string, params?: Record<string, unknown>): string;\n has(key: string): boolean;\n raw(key: string): unknown;\n rich(\n key: string,\n values?: Record<string, RichChunkRenderer | ReactNode>\n ): ReactNode;\n markup(\n key: string,\n values?: Record<string, MarkupChunkRenderer | string | number>\n ): string;\n};\n\n/**\n * Overload set for {@link getTranslations}:\n *\n * 1. A bare dictionary key → fully-typed `t()` (autocompleted dot-paths).\n * 2. An options object `{ namespace?, locale? }` → typed when namespace is\n * a known `DictionaryKeys` value.\n * 3. A nested namespace `'dictionary.sub.scope'` → `t()` accepts relative\n * `string` paths, matching next-intl's scoped-namespace behaviour.\n * 4. No namespace → root scope; the first segment of each key designates\n * the dictionary (`t('about.title')`).\n */\ntype GetTranslations = {\n <N extends DictionaryKeys>(namespace: N): Promise<TranslateFunction<N>>;\n <N extends DictionaryKeys>(\n options: GetTranslationsOptions<N>\n ): Promise<TranslateFunction<N>>;\n (namespace: `${string}.${string}`): Promise<LooseTranslateFunction>;\n (): Promise<LooseTranslateFunction>;\n};\n\n/**\n * Drop-in for next-intl's server `getTranslations()`.\n *\n * Messages support ICU MessageFormat syntax: simple arguments (`{name}`),\n * plural (`{count, plural, one {…} other {…}}`, `#`), select, and formatted\n * arguments (`{value, number}`). Rich text is available through `t.rich()`\n * and `t.markup()`.\n *\n * Also accepts an options object `{ namespace, locale }` to match next-intl's\n * full server API surface.\n *\n * @example\n * ```ts\n * // Bare namespace — fully typed dot-paths\n * const t = await getTranslations('about');\n * return <h1>{t('counter.label')}</h1>;\n *\n * // ICU plural\n * t('items', { count: 3 });\n *\n * // Options object with locale override\n * const t = await getTranslations({ namespace: 'about', locale: 'fr' });\n *\n * // Rich text\n * t.rich('terms', { link: (chunks) => <a href=\"/terms\">{chunks}</a> });\n * ```\n */\nexport const getTranslations: GetTranslations = (async (\n namespaceOrOptions?: string | GetTranslationsOptions<DictionaryKeys>\n) => {\n let namespace: string | undefined;\n let localeOverride: LocalesValues | undefined;\n\n if (typeof namespaceOrOptions === 'object' && namespaceOrOptions !== null) {\n namespace = namespaceOrOptions.namespace;\n localeOverride = namespaceOrOptions.locale;\n } else {\n namespace = namespaceOrOptions as string | undefined;\n }\n\n const locale = localeOverride ?? (await getLocale());\n\n return createTranslator(locale as LocalesValues, namespace);\n}) as GetTranslations;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoHA,MAAa,mBAAoC,OAC/C,uBACG;CACH,IAAI;CACJ,IAAI;AAEJ,KAAI,OAAO,uBAAuB,YAAY,uBAAuB,MAAM;AACzE,cAAY,mBAAmB;AAC/B,mBAAiB,mBAAmB;OAEpC,aAAY;AAKd,QAAO,iBAFQ,kBAAmB,MAAM,WAAW,EAEF,UAAU"}
1
+ {"version":3,"file":"getTranslations.mjs","names":[],"sources":["../../../src/server/getTranslations.ts"],"sourcesContent":["import type {\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport {\n createTranslator,\n type LooseTranslateFunction,\n type TranslateFunction,\n} from '@intlayer/use-intl';\nimport { getLocale } from './getLocale';\n\n/**\n * Options accepted by the options-object overload of {@link getTranslations}.\n */\ntype GetTranslationsOptions<N extends DictionaryKeys> = {\n /** The dictionary namespace to scope translations to. */\n namespace?: N;\n /** Override the locale instead of reading it from the current request. */\n locale?: LocalesValues;\n};\n\n/**\n * Overload set for {@link getTranslations}:\n *\n * 1. A bare dictionary key → fully-typed `t()` (autocompleted dot-paths).\n * 2. An options object `{ namespace?, locale? }` → typed when namespace is\n * a known `DictionaryKeys` value.\n * 3. A nested namespace `'dictionary.sub.scope'` → `t()` accepts relative\n * `string` paths, matching next-intl's scoped-namespace behaviour.\n * 4. No namespace → root scope; the first segment of each key designates\n * the dictionary (`t('about.title')`).\n *\n * The translate function shape (`t`, `t.rich`, `t.markup`, `t.raw`, `t.has`)\n * is shared with `@intlayer/use-intl`.\n */\ntype GetTranslations = {\n <N extends DictionaryKeys>(namespace: N): Promise<TranslateFunction<N>>;\n <N extends DictionaryKeys>(\n options: GetTranslationsOptions<N>\n ): Promise<TranslateFunction<N>>;\n (namespace: `${string}.${string}`): Promise<LooseTranslateFunction>;\n (): Promise<LooseTranslateFunction>;\n};\n\n/**\n * Drop-in for next-intl's server `getTranslations()`.\n *\n * Messages support ICU MessageFormat syntax: simple arguments (`{name}`),\n * plural (`{count, plural, one {…} other {…}}`, `#`), select, and formatted\n * arguments (`{value, number}`). Rich text is available through `t.rich()`\n * and `t.markup()`.\n *\n * Resolves the active locale from the current request (or the `locale` option)\n * and delegates to `@intlayer/use-intl`'s `createTranslator`, the same runtime\n * that backs the client `useTranslations`.\n *\n * @example\n * ```ts\n * // Bare namespace — fully typed dot-paths\n * const t = await getTranslations('about');\n * return <h1>{t('counter.label')}</h1>;\n *\n * // ICU plural\n * t('items', { count: 3 });\n *\n * // Options object with locale override\n * const t = await getTranslations({ namespace: 'about', locale: 'fr' });\n *\n * // Rich text\n * t.rich('terms', { link: (chunks) => <a href=\"/terms\">{chunks}</a> });\n * ```\n */\nexport const getTranslations: GetTranslations = (async (\n namespaceOrOptions?: string | GetTranslationsOptions<DictionaryKeys>\n) => {\n let namespace: string | undefined;\n let localeOverride: LocalesValues | undefined;\n\n if (typeof namespaceOrOptions === 'object' && namespaceOrOptions !== null) {\n namespace = namespaceOrOptions.namespace;\n localeOverride = namespaceOrOptions.locale;\n } else {\n namespace = namespaceOrOptions as string | undefined;\n }\n\n const locale = localeOverride ?? (await getLocale());\n\n return createTranslator({ locale: locale as LocalesValues, namespace });\n}) as GetTranslations;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwEA,MAAa,mBAAoC,OAC/C,uBACG;CACH,IAAI;CACJ,IAAI;AAEJ,KAAI,OAAO,uBAAuB,YAAY,uBAAuB,MAAM;AACzE,cAAY,mBAAmB;AAC/B,mBAAiB,mBAAmB;OAEpC,aAAY;AAKd,QAAO,iBAAiB;EAAE,QAFX,kBAAmB,MAAM,WAAW;EAEQ;EAAW,CAAC"}
@@ -1,13 +1,14 @@
1
- import { createFormatter } from "../createFormatter.mjs";
2
1
  import { getLocale } from "./getLocale.mjs";
2
+ import { createFormatter } from "@intlayer/use-intl";
3
3
 
4
4
  //#region src/server/helpers.ts
5
5
  /**
6
6
  * Drop-in for next-intl's server `getFormatter()`.
7
- * Returns locale-aware formatters backed by the native `Intl.*` APIs.
7
+ * Returns locale-aware formatters backed by the native `Intl.*` APIs,
8
+ * built by `@intlayer/use-intl`'s `createFormatter`.
8
9
  */
9
10
  const getFormatter = (async (options) => {
10
- return createFormatter(options?.locale ?? await getLocale());
11
+ return createFormatter({ locale: options?.locale ?? await getLocale() });
11
12
  });
12
13
  /**
13
14
  * Drop-in for next-intl's server `getNow()`.
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.mjs","names":[],"sources":["../../../src/server/helpers.ts"],"sourcesContent":["import type {\n getFormatter as _getFormatter,\n getNow as _getNow,\n getTimeZone as _getTimeZone,\n} from 'next-intl/server';\nimport { createFormatter } from '../createFormatter';\nimport { getLocale } from './getLocale';\n\n/**\n * Drop-in for next-intl's server `getFormatter()`.\n * Returns locale-aware formatters backed by the native `Intl.*` APIs.\n */\nexport const getFormatter: typeof _getFormatter = (async (options?: {\n locale?: string;\n}) => {\n const locale = options?.locale ?? (await getLocale());\n return createFormatter(locale as string);\n}) as typeof _getFormatter;\n\n/**\n * Drop-in for next-intl's server `getNow()`.\n * Returns the current `Date`.\n */\nexport const getNow: typeof _getNow = (async () =>\n new Date()) as typeof _getNow;\n\n/**\n * Drop-in for next-intl's server `getTimeZone()`.\n * Returns the system time zone resolved from `Intl.DateTimeFormat`.\n */\nexport const getTimeZone: typeof _getTimeZone = (async () =>\n Intl.DateTimeFormat().resolvedOptions().timeZone) as typeof _getTimeZone;\n"],"mappings":";;;;;;;;AAYA,MAAa,gBAAsC,OAAO,YAEpD;AAEJ,QAAO,gBADQ,SAAS,UAAW,MAAM,WAAW,CACZ;;;;;;AAO1C,MAAa,UAA0B,4BACrC,IAAI,MAAM;;;;;AAMZ,MAAa,eAAoC,YAC/C,KAAK,gBAAgB,CAAC,iBAAiB,CAAC"}
1
+ {"version":3,"file":"helpers.mjs","names":[],"sources":["../../../src/server/helpers.ts"],"sourcesContent":["import { createFormatter } from '@intlayer/use-intl';\nimport type {\n getFormatter as _getFormatter,\n getNow as _getNow,\n getTimeZone as _getTimeZone,\n} from 'next-intl/server';\nimport { getLocale } from './getLocale';\n\n/**\n * Drop-in for next-intl's server `getFormatter()`.\n * Returns locale-aware formatters backed by the native `Intl.*` APIs,\n * built by `@intlayer/use-intl`'s `createFormatter`.\n */\nexport const getFormatter: typeof _getFormatter = (async (options?: {\n locale?: string;\n}) => {\n const locale = options?.locale ?? (await getLocale());\n return createFormatter({ locale: locale as string });\n}) as typeof _getFormatter;\n\n/**\n * Drop-in for next-intl's server `getNow()`.\n * Returns the current `Date`.\n */\nexport const getNow: typeof _getNow = (async () =>\n new Date()) as typeof _getNow;\n\n/**\n * Drop-in for next-intl's server `getTimeZone()`.\n * Returns the system time zone resolved from `Intl.DateTimeFormat`.\n */\nexport const getTimeZone: typeof _getTimeZone = (async () =>\n Intl.DateTimeFormat().resolvedOptions().timeZone) as typeof _getTimeZone;\n"],"mappings":";;;;;;;;;AAaA,MAAa,gBAAsC,OAAO,YAEpD;AAEJ,QAAO,gBAAgB,EAAE,QADV,SAAS,UAAW,MAAM,WAAW,EACD,CAAC;;;;;;AAOtD,MAAa,UAA0B,4BACrC,IAAI,MAAM;;;;;AAMZ,MAAa,eAAoC,YAC/C,KAAK,gBAAgB,CAAC,iBAAiB,CAAC"}
@@ -2,8 +2,10 @@ import { getLocale } from "./getLocale.mjs";
2
2
  import { getDictionary } from "../getDictionary.mjs";
3
3
  import { getDictionaryDynamic } from "../getDictionaryDynamic.mjs";
4
4
  import { getFormatter, getNow, getTimeZone } from "./helpers.mjs";
5
+ import getRequestConfig from "./getRequestConfig.mjs";
6
+ import { setRequestLocale } from "./setRequestLocale.mjs";
5
7
  import { setLocale } from "./setLocale.mjs";
6
8
  import { getTranslations } from "./getTranslations.mjs";
7
9
  import { getMessages } from "./getMessages.mjs";
8
10
 
9
- export { getDictionary, getDictionaryDynamic, getFormatter, getLocale, getMessages, getNow, getTimeZone, getTranslations, setLocale };
11
+ export { getDictionary, getDictionaryDynamic, getFormatter, getLocale, getMessages, getNow, getRequestConfig, getTimeZone, getTranslations, setLocale, setRequestLocale };
@@ -0,0 +1,28 @@
1
+ import { log } from "@intlayer/config/built";
2
+ import { CYAN } from "@intlayer/config/colors";
3
+ import { colorize, getAppLogger } from "@intlayer/config/logger";
4
+
5
+ //#region src/server/setRequestLocale.ts
6
+ /**
7
+ * Drop-in for next-intl's `setRequestLocale`.
8
+ *
9
+ * In next-intl this stores the locale in a request-scoped cache to opt into
10
+ * static rendering. Intlayer resolves the active locale from the configured
11
+ * `routing.storage` (cookie / header) or the localized route segment, so there
12
+ * is nothing to set here — this is a no-op kept for API compatibility.
13
+ *
14
+ * @deprecated setRequestLocale has no use case with intlayer. The locale is
15
+ * resolved automatically from routing / storage.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * setRequestLocale(locale); // safe to keep, but has no effect
20
+ * ```
21
+ */
22
+ const setRequestLocale = (_locale) => {
23
+ getAppLogger({ log })(`${colorize("setRequestLocale", CYAN)} has no use case with intlayer. The locale is resolved automatically from routing and storage`);
24
+ };
25
+
26
+ //#endregion
27
+ export { setRequestLocale };
28
+ //# sourceMappingURL=setRequestLocale.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setRequestLocale.mjs","names":[],"sources":["../../../src/server/setRequestLocale.ts"],"sourcesContent":["import { log } from '@intlayer/config/built';\nimport { CYAN } from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport type { setRequestLocale as _setRequestLocale } from 'next-intl/server';\n\n/**\n * Drop-in for next-intl's `setRequestLocale`.\n *\n * In next-intl this stores the locale in a request-scoped cache to opt into\n * static rendering. Intlayer resolves the active locale from the configured\n * `routing.storage` (cookie / header) or the localized route segment, so there\n * is nothing to set here — this is a no-op kept for API compatibility.\n *\n * @deprecated setRequestLocale has no use case with intlayer. The locale is\n * resolved automatically from routing / storage.\n *\n * @example\n * ```ts\n * setRequestLocale(locale); // safe to keep, but has no effect\n * ```\n */\nexport const setRequestLocale: typeof _setRequestLocale = (_locale): void => {\n if (process.env.NODE_ENV === 'development') {\n const appLogger = getAppLogger({ log });\n appLogger(\n `${colorize('setRequestLocale', CYAN)} has no use case with intlayer. The locale is resolved automatically from routing and storage`\n );\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqBA,MAAa,oBAA8C,YAAkB;AAGzE,CADkB,aAAa,EAAE,KAAK,CAC7B,CACP,GAAG,SAAS,oBAAoB,KAAK,CAAC,+FACvC"}