next-intl 2.17.4 → 2.17.5

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 (194) hide show
  1. package/dist/_virtual/next-intl.esm.js +29 -0
  2. package/dist/_virtual/next-intl.esm.js.map +1 -0
  3. package/dist/client/NextIntlClientProvider.d.ts +4 -8
  4. package/dist/client/index.d.ts +6 -7
  5. package/dist/client/useClientLocale.d.ts +1 -3
  6. package/dist/client/usePathname.d.ts +14 -16
  7. package/dist/client/useRouter.d.ts +24 -28
  8. package/dist/index.d.ts +8 -3
  9. package/dist/index.js +8 -2
  10. package/dist/link/Link.d.ts +27 -30
  11. package/dist/link/index.d.ts +1 -4
  12. package/dist/middleware/NextIntlMiddlewareConfig.d.ts +28 -29
  13. package/dist/middleware/getAlternateLinksHeaderValue.d.ts +6 -9
  14. package/dist/middleware/index.d.ts +4 -3
  15. package/dist/middleware/middleware.d.ts +3 -6
  16. package/dist/middleware/resolveLocale.d.ts +6 -9
  17. package/dist/middleware/utils.d.ts +5 -8
  18. package/dist/next-intl.cjs.development.js +82 -0
  19. package/dist/next-intl.cjs.development.js.map +1 -0
  20. package/dist/next-intl.cjs.production.min.js +2 -0
  21. package/dist/next-intl.cjs.production.min.js.map +1 -0
  22. package/dist/{index.d.mts → next-intl.esm.js} +2 -2
  23. package/dist/next-intl.esm.js.map +1 -0
  24. package/dist/react-client/index.d.ts +12 -3
  25. package/dist/react-server/index.d.ts +17 -23
  26. package/dist/server/index.d.ts +6 -7
  27. package/dist/shared/BaseLink.d.ts +7 -9
  28. package/dist/shared/NextIntlClientProvider.d.ts +9 -11
  29. package/dist/shared/constants.d.ts +2 -4
  30. package/dist/shared/next-intl.esm.js +41 -0
  31. package/dist/shared/next-intl.esm.js.map +1 -0
  32. package/dist/shared/utils.d.ts +15 -16
  33. package/dist/src/client/NextIntlClientProvider.d.ts +4 -0
  34. package/dist/src/client/NextIntlClientProvider.js +16 -0
  35. package/dist/src/client/NextIntlClientProvider.js.map +1 -0
  36. package/dist/src/client/index.d.ts +6 -0
  37. package/dist/src/client/index.js +8 -0
  38. package/dist/src/client/index.js.map +1 -0
  39. package/dist/src/client/useClientLocale.d.ts +1 -0
  40. package/dist/src/client/useClientLocale.js +18 -0
  41. package/dist/src/client/useClientLocale.js.map +1 -0
  42. package/dist/{client/usePathname.d.mts → src/client/usePathname.d.ts} +1 -3
  43. package/dist/src/client/usePathname.js +34 -0
  44. package/dist/src/client/usePathname.js.map +1 -0
  45. package/dist/src/client/useRouter.d.ts +24 -0
  46. package/dist/src/client/useRouter.js +42 -0
  47. package/dist/src/client/useRouter.js.map +1 -0
  48. package/dist/src/index.d.ts +8 -0
  49. package/dist/src/index.js +9 -0
  50. package/dist/src/index.js.map +1 -0
  51. package/dist/{link/Link.d.mts → src/link/Link.d.ts} +3 -6
  52. package/dist/src/link/Link.js +29 -0
  53. package/dist/src/link/Link.js.map +1 -0
  54. package/dist/src/link/index.d.ts +1 -0
  55. package/dist/src/link/index.js +2 -0
  56. package/dist/src/link/index.js.map +1 -0
  57. package/dist/{middleware/NextIntlMiddlewareConfig.d.mts → src/middleware/NextIntlMiddlewareConfig.d.ts} +3 -4
  58. package/dist/src/middleware/NextIntlMiddlewareConfig.js +2 -0
  59. package/dist/src/middleware/NextIntlMiddlewareConfig.js.map +1 -0
  60. package/dist/{middleware/getAlternateLinksHeaderValue.d.mts → src/middleware/getAlternateLinksHeaderValue.d.ts} +2 -5
  61. package/dist/src/middleware/getAlternateLinksHeaderValue.js +64 -0
  62. package/dist/src/middleware/getAlternateLinksHeaderValue.js.map +1 -0
  63. package/dist/src/middleware/index.d.ts +4 -0
  64. package/dist/src/middleware/index.js +5 -0
  65. package/dist/src/middleware/index.js.map +1 -0
  66. package/dist/src/middleware/middleware.d.ts +3 -0
  67. package/dist/src/middleware/middleware.js +142 -0
  68. package/dist/src/middleware/middleware.js.map +1 -0
  69. package/dist/src/middleware/resolveLocale.d.ts +6 -0
  70. package/dist/src/middleware/resolveLocale.js +88 -0
  71. package/dist/src/middleware/resolveLocale.js.map +1 -0
  72. package/dist/src/middleware/utils.d.ts +5 -0
  73. package/dist/src/middleware/utils.js +37 -0
  74. package/dist/src/middleware/utils.js.map +1 -0
  75. package/dist/src/react-client/index.d.ts +12 -0
  76. package/dist/src/react-client/index.js +14 -0
  77. package/dist/src/react-client/index.js.map +1 -0
  78. package/dist/src/react-server/index.d.ts +17 -0
  79. package/dist/src/react-server/index.js +25 -0
  80. package/dist/src/react-server/index.js.map +1 -0
  81. package/dist/src/server/index.d.ts +6 -0
  82. package/dist/src/server/index.js +30 -0
  83. package/dist/src/server/index.js.map +1 -0
  84. package/dist/{shared/BaseLink.d.mts → src/shared/BaseLink.d.ts} +1 -3
  85. package/dist/src/shared/BaseLink.js +38 -0
  86. package/dist/src/shared/BaseLink.js.map +1 -0
  87. package/dist/{shared/NextIntlClientProvider.d.mts → src/shared/NextIntlClientProvider.d.ts} +2 -4
  88. package/dist/src/shared/NextIntlClientProvider.js +33 -0
  89. package/dist/src/shared/NextIntlClientProvider.js.map +1 -0
  90. package/dist/src/shared/constants.d.ts +2 -0
  91. package/dist/src/shared/constants.js +6 -0
  92. package/dist/src/shared/constants.js.map +1 -0
  93. package/dist/src/shared/utils.d.ts +15 -0
  94. package/dist/src/shared/utils.js +53 -0
  95. package/dist/src/shared/utils.js.map +1 -0
  96. package/package.json +27 -26
  97. package/src/react-server/index.tsx +2 -2
  98. package/dist/client/NextIntlClientProvider.d.mts +0 -8
  99. package/dist/client/NextIntlClientProvider.js +0 -2
  100. package/dist/client/NextIntlClientProvider.js.map +0 -1
  101. package/dist/client/NextIntlClientProvider.mjs +0 -2
  102. package/dist/client/NextIntlClientProvider.mjs.map +0 -1
  103. package/dist/client/index.d.mts +0 -7
  104. package/dist/client/index.js +0 -2
  105. package/dist/client/index.js.map +0 -1
  106. package/dist/client/index.mjs +0 -2
  107. package/dist/client/index.mjs.map +0 -1
  108. package/dist/client/useClientLocale.d.mts +0 -3
  109. package/dist/client/useClientLocale.js +0 -2
  110. package/dist/client/useClientLocale.js.map +0 -1
  111. package/dist/client/useClientLocale.mjs +0 -2
  112. package/dist/client/useClientLocale.mjs.map +0 -1
  113. package/dist/client/usePathname.js +0 -2
  114. package/dist/client/usePathname.js.map +0 -1
  115. package/dist/client/usePathname.mjs +0 -2
  116. package/dist/client/usePathname.mjs.map +0 -1
  117. package/dist/client/useRouter.d.mts +0 -28
  118. package/dist/client/useRouter.js +0 -2
  119. package/dist/client/useRouter.js.map +0 -1
  120. package/dist/client/useRouter.mjs +0 -2
  121. package/dist/client/useRouter.mjs.map +0 -1
  122. package/dist/index.js.map +0 -1
  123. package/dist/index.mjs +0 -2
  124. package/dist/index.mjs.map +0 -1
  125. package/dist/link/Link.js +0 -2
  126. package/dist/link/Link.js.map +0 -1
  127. package/dist/link/Link.mjs +0 -2
  128. package/dist/link/Link.mjs.map +0 -1
  129. package/dist/link/index.d.mts +0 -4
  130. package/dist/link/index.js +0 -2
  131. package/dist/link/index.js.map +0 -1
  132. package/dist/link/index.mjs +0 -2
  133. package/dist/link/index.mjs.map +0 -1
  134. package/dist/middleware/NextIntlMiddlewareConfig.js +0 -2
  135. package/dist/middleware/NextIntlMiddlewareConfig.js.map +0 -1
  136. package/dist/middleware/NextIntlMiddlewareConfig.mjs +0 -1
  137. package/dist/middleware/NextIntlMiddlewareConfig.mjs.map +0 -1
  138. package/dist/middleware/getAlternateLinksHeaderValue.js +0 -2
  139. package/dist/middleware/getAlternateLinksHeaderValue.js.map +0 -1
  140. package/dist/middleware/getAlternateLinksHeaderValue.mjs +0 -2
  141. package/dist/middleware/getAlternateLinksHeaderValue.mjs.map +0 -1
  142. package/dist/middleware/index.d.mts +0 -3
  143. package/dist/middleware/index.js +0 -2
  144. package/dist/middleware/index.js.map +0 -1
  145. package/dist/middleware/index.mjs +0 -2
  146. package/dist/middleware/index.mjs.map +0 -1
  147. package/dist/middleware/middleware.d.mts +0 -6
  148. package/dist/middleware/middleware.js +0 -2
  149. package/dist/middleware/middleware.js.map +0 -1
  150. package/dist/middleware/middleware.mjs +0 -2
  151. package/dist/middleware/middleware.mjs.map +0 -1
  152. package/dist/middleware/resolveLocale.d.mts +0 -9
  153. package/dist/middleware/resolveLocale.js +0 -2
  154. package/dist/middleware/resolveLocale.js.map +0 -1
  155. package/dist/middleware/resolveLocale.mjs +0 -2
  156. package/dist/middleware/resolveLocale.mjs.map +0 -1
  157. package/dist/middleware/utils.d.mts +0 -8
  158. package/dist/middleware/utils.js +0 -2
  159. package/dist/middleware/utils.js.map +0 -1
  160. package/dist/middleware/utils.mjs +0 -2
  161. package/dist/middleware/utils.mjs.map +0 -1
  162. package/dist/react-client/index.d.mts +0 -3
  163. package/dist/react-client/index.js +0 -2
  164. package/dist/react-client/index.js.map +0 -1
  165. package/dist/react-client/index.mjs +0 -2
  166. package/dist/react-client/index.mjs.map +0 -1
  167. package/dist/react-server/index.d.mts +0 -23
  168. package/dist/react-server/index.js +0 -7
  169. package/dist/react-server/index.js.map +0 -1
  170. package/dist/react-server/index.mjs +0 -7
  171. package/dist/react-server/index.mjs.map +0 -1
  172. package/dist/server/index.d.mts +0 -7
  173. package/dist/server/index.js +0 -14
  174. package/dist/server/index.js.map +0 -1
  175. package/dist/server/index.mjs +0 -14
  176. package/dist/server/index.mjs.map +0 -1
  177. package/dist/shared/BaseLink.js +0 -2
  178. package/dist/shared/BaseLink.js.map +0 -1
  179. package/dist/shared/BaseLink.mjs +0 -2
  180. package/dist/shared/BaseLink.mjs.map +0 -1
  181. package/dist/shared/NextIntlClientProvider.js +0 -2
  182. package/dist/shared/NextIntlClientProvider.js.map +0 -1
  183. package/dist/shared/NextIntlClientProvider.mjs +0 -2
  184. package/dist/shared/NextIntlClientProvider.mjs.map +0 -1
  185. package/dist/shared/constants.d.mts +0 -4
  186. package/dist/shared/constants.js +0 -2
  187. package/dist/shared/constants.js.map +0 -1
  188. package/dist/shared/constants.mjs +0 -2
  189. package/dist/shared/constants.mjs.map +0 -1
  190. package/dist/shared/utils.d.mts +0 -16
  191. package/dist/shared/utils.js +0 -2
  192. package/dist/shared/utils.js.map +0 -1
  193. package/dist/shared/utils.mjs +0 -2
  194. package/dist/shared/utils.mjs.map +0 -1
@@ -0,0 +1,29 @@
1
+ function _extends() {
2
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
3
+ for (var i = 1; i < arguments.length; i++) {
4
+ var source = arguments[i];
5
+ for (var key in source) {
6
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
7
+ target[key] = source[key];
8
+ }
9
+ }
10
+ }
11
+ return target;
12
+ };
13
+ return _extends.apply(this, arguments);
14
+ }
15
+ function _objectWithoutPropertiesLoose(source, excluded) {
16
+ if (source == null) return {};
17
+ var target = {};
18
+ var sourceKeys = Object.keys(source);
19
+ var key, i;
20
+ for (i = 0; i < sourceKeys.length; i++) {
21
+ key = sourceKeys[i];
22
+ if (excluded.indexOf(key) >= 0) continue;
23
+ target[key] = source[key];
24
+ }
25
+ return target;
26
+ }
27
+
28
+ export { _extends as extends, _objectWithoutPropertiesLoose as objectWithoutPropertiesLoose };
29
+ //# sourceMappingURL=next-intl.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"next-intl.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,8 +1,4 @@
1
- import { ComponentProps } from 'react';
2
- import NextIntlClientProvider$1 from '../shared/NextIntlClientProvider.js';
3
- import 'use-intl';
4
-
5
- /** @deprecated Should be imported from `next-intl`, not `next-intl/client`. */
6
- declare function NextIntlClientProvider(props: ComponentProps<typeof NextIntlClientProvider$1>): JSX.Element;
7
-
8
- export { NextIntlClientProvider as default };
1
+ import { ComponentProps } from 'react';
2
+ import NextIntlClientProvider_ from '../shared/NextIntlClientProvider';
3
+ /** @deprecated Should be imported from `next-intl`, not `next-intl/client`. */
4
+ export default function NextIntlClientProvider(props: ComponentProps<typeof NextIntlClientProvider_>): JSX.Element;
@@ -1,7 +1,6 @@
1
- export { default as useRouter } from './useRouter.js';
2
- export { default as usePathname } from './usePathname.js';
3
- export { default as NextIntlClientProvider } from './NextIntlClientProvider.js';
4
- import 'next/dist/shared/lib/app-router-context';
5
- import 'react';
6
- import '../shared/NextIntlClientProvider.js';
7
- import 'use-intl';
1
+ /**
2
+ * Client-only APIs available via `next-intl/client`.
3
+ */
4
+ export { default as useRouter } from './useRouter';
5
+ export { default as usePathname } from './usePathname';
6
+ export { default as NextIntlClientProvider } from './NextIntlClientProvider';
@@ -1,3 +1 @@
1
- declare function useClientLocale(): string;
2
-
3
- export { useClientLocale as default };
1
+ export default function useClientLocale(): string;
@@ -1,16 +1,14 @@
1
- /**
2
- * Returns the pathname without a potential locale prefix.
3
- *
4
- * @example
5
- * ```tsx
6
- * 'use client';
7
- *
8
- * import {usePathname} from 'next-intl/client';
9
- *
10
- * // When the user is on `/en`, this will be `/`
11
- * const pathname = usePathname();
12
- * ```
13
- */
14
- declare function usePathname(): string;
15
-
16
- export { usePathname as default };
1
+ /**
2
+ * Returns the pathname without a potential locale prefix.
3
+ *
4
+ * @example
5
+ * ```tsx
6
+ * 'use client';
7
+ *
8
+ * import {usePathname} from 'next-intl/client';
9
+ *
10
+ * // When the user is on `/en`, this will be `/`
11
+ * const pathname = usePathname();
12
+ * ```
13
+ */
14
+ export default function usePathname(): string;
@@ -1,28 +1,24 @@
1
- import * as next_dist_shared_lib_app_router_context from 'next/dist/shared/lib/app-router-context';
2
-
3
- /**
4
- * Returns a wrapped instance of `useRouter` from `next/navigation` that
5
- * will automatically localize the `href` parameters it receives.
6
- *
7
- * @example
8
- * ```tsx
9
- * 'use client';
10
- *
11
- * import {useRouter} from 'next-intl/client';
12
- *
13
- * const router = useRouter();
14
- *
15
- * // When the user is on `/en`, the router will navigate to `/en/about`
16
- * router.push('/about');
17
- * ```
18
- */
19
- declare function useRouter(): {
20
- push(href: string, options?: next_dist_shared_lib_app_router_context.NavigateOptions | undefined): void;
21
- replace(href: string, options?: next_dist_shared_lib_app_router_context.NavigateOptions | undefined): void;
22
- prefetch(href: string, options?: next_dist_shared_lib_app_router_context.PrefetchOptions | undefined): void;
23
- back(): void;
24
- forward(): void;
25
- refresh(): void;
26
- };
27
-
28
- export { useRouter as default };
1
+ /**
2
+ * Returns a wrapped instance of `useRouter` from `next/navigation` that
3
+ * will automatically localize the `href` parameters it receives.
4
+ *
5
+ * @example
6
+ * ```tsx
7
+ * 'use client';
8
+ *
9
+ * import {useRouter} from 'next-intl/client';
10
+ *
11
+ * const router = useRouter();
12
+ *
13
+ * // When the user is on `/en`, the router will navigate to `/en/about`
14
+ * router.push('/about');
15
+ * ```
16
+ */
17
+ export default function useRouter(): {
18
+ push(href: string, options?: import("next/dist/shared/lib/app-router-context").NavigateOptions | undefined): void;
19
+ replace(href: string, options?: import("next/dist/shared/lib/app-router-context").NavigateOptions | undefined): void;
20
+ prefetch(href: string, options?: import("next/dist/shared/lib/app-router-context").PrefetchOptions | undefined): void;
21
+ back(): void;
22
+ forward(): void;
23
+ refresh(): void;
24
+ };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,8 @@
1
- export * from 'use-intl';
2
- export { default as NextIntlClientProvider, default as NextIntlProvider } from './shared/NextIntlClientProvider.js';
3
- import 'react';
1
+ /**
2
+ * This is the default entry file when consumers import from
3
+ * 'next-intl'. We use the client APIs in this case.
4
+ *
5
+ * Note that the `react-server` environment (i.e. RSC) imports
6
+ * from `./react-server` instead.
7
+ */
8
+ export * from './react-client';
package/dist/index.js CHANGED
@@ -1,2 +1,8 @@
1
- "use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var p=(r,o,f,x)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of c(o))!d.call(r,e)&&e!==f&&a(r,e,{get:()=>o[e],enumerable:!(x=b(o,e))||x.enumerable});return r},t=(r,o,f)=>(p(r,o,"default"),f&&p(f,o,"default"));var g=r=>p(a({},"__esModule",{value:!0}),r);var m={};module.exports=g(m);t(m,require("./react-client"),module.exports);0&&(module.exports={...require("./react-client")});
2
- //# sourceMappingURL=index.js.map
1
+
2
+ 'use strict'
3
+
4
+ if (process.env.NODE_ENV === 'production') {
5
+ module.exports = require('./next-intl.cjs.production.min.js')
6
+ } else {
7
+ module.exports = require('./next-intl.cjs.development.js')
8
+ }
@@ -1,30 +1,27 @@
1
- import React, { ComponentProps } from 'react';
2
- import _default$1 from '../shared/BaseLink.js';
3
- import 'next/link';
4
-
5
- type Props = Omit<ComponentProps<typeof _default$1>, 'locale'> & {
6
- locale?: string;
7
- };
8
- /**
9
- * Wraps `next/link` and prefixes the `href` with the current locale if
10
- * necessary.
11
- *
12
- * @example
13
- * ```tsx
14
- * import {Link} from 'next-intl';
15
- *
16
- * // When the user is on `/en`, the link will point to `/en/about`
17
- * <Link href="/about">About</Link>
18
- *
19
- * // You can override the `locale` to switch to another language
20
- * <Link href="/" locale="de">Switch to German</Link>
21
- * ```
22
- *
23
- * Note that when a `locale` prop is passed to switch the locale, the `prefetch`
24
- * prop is not supported. This is because Next.js would prefetch the page and
25
- * the `set-cookie` response header would cause the locale cookie on the current
26
- * page to be overwritten before the user even decides to change the locale.
27
- */
28
- declare const _default: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
29
-
30
- export { _default as default };
1
+ import React, { ComponentProps } from 'react';
2
+ import BaseLink from '../shared/BaseLink';
3
+ type Props = Omit<ComponentProps<typeof BaseLink>, 'locale'> & {
4
+ locale?: string;
5
+ };
6
+ /**
7
+ * Wraps `next/link` and prefixes the `href` with the current locale if
8
+ * necessary.
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * import {Link} from 'next-intl';
13
+ *
14
+ * // When the user is on `/en`, the link will point to `/en/about`
15
+ * <Link href="/about">About</Link>
16
+ *
17
+ * // You can override the `locale` to switch to another language
18
+ * <Link href="/" locale="de">Switch to German</Link>
19
+ * ```
20
+ *
21
+ * Note that when a `locale` prop is passed to switch the locale, the `prefetch`
22
+ * prop is not supported. This is because Next.js would prefetch the page and
23
+ * the `set-cookie` response header would cause the locale cookie on the current
24
+ * page to be overwritten before the user even decides to change the locale.
25
+ */
26
+ declare const _default: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
27
+ export default _default;
@@ -1,4 +1 @@
1
- export { default } from './Link.js';
2
- import 'react';
3
- import '../shared/BaseLink.js';
4
- import 'next/link';
1
+ export { default } from './Link';
@@ -1,29 +1,28 @@
1
- type LocalePrefix = 'as-needed' | 'always';
2
- type RoutingBaseConfig = {
3
- /** A list of all locales that are supported. */
4
- locales: Array<string>;
5
- defaultLocale: string;
6
- /** The default locale can be used without a prefix (e.g. `/about`). If you prefer to have a prefix for the default locale as well (e.g. `/en/about`), you can switch this option to `always`.
7
- */
8
- localePrefix?: LocalePrefix;
9
- };
10
- type DomainConfig = Omit<RoutingBaseConfig, 'locales' | 'localePrefix'> & {
11
- /** The domain name (e.g. "example.com", "www.example.com" or "fr.example.com"). Note that the `x-forwarded-host` or alternatively the `host` header will be used to determine the requested domain. */
12
- domain: string;
13
- locales?: RoutingBaseConfig['locales'];
14
- };
15
- type MiddlewareConfig = RoutingBaseConfig & {
16
- /** Can be used to change the locale handling per domain. */
17
- domains?: Array<DomainConfig>;
18
- /** By setting this to `false`, the `accept-language` header will no longer be used for locale detection. */
19
- localeDetection?: boolean;
20
- /** Sets the `Link` response header to notify search engines about content in other languages (defaults to `true`). See https://developers.google.com/search/docs/specialty/international/localized-versions#http */
21
- alternateLinks?: boolean;
22
- };
23
- type MiddlewareConfigWithDefaults = MiddlewareConfig & {
24
- alternateLinks: boolean;
25
- localePrefix: LocalePrefix;
26
- localeDetection: boolean;
27
- };
28
-
29
- export { DomainConfig, MiddlewareConfigWithDefaults, MiddlewareConfig as default };
1
+ type LocalePrefix = 'as-needed' | 'always';
2
+ type RoutingBaseConfig = {
3
+ /** A list of all locales that are supported. */
4
+ locales: Array<string>;
5
+ defaultLocale: string;
6
+ /** The default locale can be used without a prefix (e.g. `/about`). If you prefer to have a prefix for the default locale as well (e.g. `/en/about`), you can switch this option to `always`.
7
+ */
8
+ localePrefix?: LocalePrefix;
9
+ };
10
+ export type DomainConfig = Omit<RoutingBaseConfig, 'locales' | 'localePrefix'> & {
11
+ /** The domain name (e.g. "example.com", "www.example.com" or "fr.example.com"). Note that the `x-forwarded-host` or alternatively the `host` header will be used to determine the requested domain. */
12
+ domain: string;
13
+ locales?: RoutingBaseConfig['locales'];
14
+ };
15
+ type MiddlewareConfig = RoutingBaseConfig & {
16
+ /** Can be used to change the locale handling per domain. */
17
+ domains?: Array<DomainConfig>;
18
+ /** By setting this to `false`, the `accept-language` header will no longer be used for locale detection. */
19
+ localeDetection?: boolean;
20
+ /** Sets the `Link` response header to notify search engines about content in other languages (defaults to `true`). See https://developers.google.com/search/docs/specialty/international/localized-versions#http */
21
+ alternateLinks?: boolean;
22
+ };
23
+ export type MiddlewareConfigWithDefaults = MiddlewareConfig & {
24
+ alternateLinks: boolean;
25
+ localePrefix: LocalePrefix;
26
+ localeDetection: boolean;
27
+ };
28
+ export default MiddlewareConfig;
@@ -1,9 +1,6 @@
1
- import { NextRequest } from 'next/server';
2
- import { MiddlewareConfigWithDefaults } from './NextIntlMiddlewareConfig.js';
3
-
4
- /**
5
- * See https://developers.google.com/search/docs/specialty/international/localized-versions
6
- */
7
- declare function getAlternateLinksHeaderValue(config: MiddlewareConfigWithDefaults, request: NextRequest): string;
8
-
9
- export { getAlternateLinksHeaderValue as default };
1
+ import { NextRequest } from 'next/server';
2
+ import { MiddlewareConfigWithDefaults } from './NextIntlMiddlewareConfig';
3
+ /**
4
+ * See https://developers.google.com/search/docs/specialty/international/localized-versions
5
+ */
6
+ export default function getAlternateLinksHeaderValue(config: MiddlewareConfigWithDefaults, request: NextRequest): string;
@@ -1,3 +1,4 @@
1
- export { default } from './middleware.js';
2
- import 'next/server';
3
- import './NextIntlMiddlewareConfig.js';
1
+ /**
2
+ * The middleware, available as `next-intl/middleware`.
3
+ */
4
+ export { default } from './middleware';
@@ -1,6 +1,3 @@
1
- import { NextRequest, NextResponse } from 'next/server';
2
- import MiddlewareConfig from './NextIntlMiddlewareConfig.js';
3
-
4
- declare function createMiddleware(config: MiddlewareConfig): (request: NextRequest) => NextResponse<unknown>;
5
-
6
- export { createMiddleware as default };
1
+ import { NextRequest, NextResponse } from 'next/server';
2
+ import MiddlewareConfig from './NextIntlMiddlewareConfig';
3
+ export default function createMiddleware(config: MiddlewareConfig): (request: NextRequest) => NextResponse<unknown>;
@@ -1,9 +1,6 @@
1
- import { RequestCookies } from 'next/dist/server/web/spec-extension/cookies';
2
- import { MiddlewareConfigWithDefaults, DomainConfig } from './NextIntlMiddlewareConfig.js';
3
-
4
- declare function resolveLocale(config: MiddlewareConfigWithDefaults, requestHeaders: Headers, requestCookies: RequestCookies, pathname: string): {
5
- locale: string;
6
- domain?: DomainConfig;
7
- };
8
-
9
- export { resolveLocale as default };
1
+ import { RequestCookies } from 'next/dist/server/web/spec-extension/cookies';
2
+ import { DomainConfig, MiddlewareConfigWithDefaults } from './NextIntlMiddlewareConfig';
3
+ export default function resolveLocale(config: MiddlewareConfigWithDefaults, requestHeaders: Headers, requestCookies: RequestCookies, pathname: string): {
4
+ locale: string;
5
+ domain?: DomainConfig;
6
+ };
@@ -1,8 +1,5 @@
1
- import { DomainConfig } from './NextIntlMiddlewareConfig.js';
2
-
3
- declare function getLocaleFromPathname(pathname: string): string;
4
- declare function getHost(requestHeaders: Headers): string | undefined;
5
- declare function isLocaleSupportedOnDomain(locale: string, domain: DomainConfig): boolean;
6
- declare function getBestMatchingDomain(curHostDomain: DomainConfig | undefined, locale: string, domainConfigs: Array<DomainConfig>): DomainConfig | undefined;
7
-
8
- export { getBestMatchingDomain, getHost, getLocaleFromPathname, isLocaleSupportedOnDomain };
1
+ import { DomainConfig } from './NextIntlMiddlewareConfig';
2
+ export declare function getLocaleFromPathname(pathname: string): string;
3
+ export declare function getHost(requestHeaders: Headers): string | undefined;
4
+ export declare function isLocaleSupportedOnDomain(locale: string, domain: DomainConfig): boolean;
5
+ export declare function getBestMatchingDomain(curHostDomain: DomainConfig | undefined, locale: string, domainConfigs: Array<DomainConfig>): DomainConfig | undefined;
@@ -0,0 +1,82 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var useIntl = require('use-intl');
6
+ var router = require('next/router');
7
+ var React = require('react');
8
+
9
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
+
11
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
12
+
13
+ function _extends() {
14
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
15
+ for (var i = 1; i < arguments.length; i++) {
16
+ var source = arguments[i];
17
+ for (var key in source) {
18
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
19
+ target[key] = source[key];
20
+ }
21
+ }
22
+ }
23
+ return target;
24
+ };
25
+ return _extends.apply(this, arguments);
26
+ }
27
+ function _objectWithoutPropertiesLoose(source, excluded) {
28
+ if (source == null) return {};
29
+ var target = {};
30
+ var sourceKeys = Object.keys(source);
31
+ var key, i;
32
+ for (i = 0; i < sourceKeys.length; i++) {
33
+ key = sourceKeys[i];
34
+ if (excluded.indexOf(key) >= 0) continue;
35
+ target[key] = source[key];
36
+ }
37
+ return target;
38
+ }
39
+
40
+ var _excluded = ["children", "locale", "now"];
41
+ function NextIntlClientProvider(_ref) {
42
+ var children = _ref.children,
43
+ locale = _ref.locale,
44
+ now = _ref.now,
45
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
46
+ var router$1;
47
+ try {
48
+ // Reading from context is practically ok to do conditionally
49
+ // eslint-disable-next-line react-hooks/rules-of-hooks
50
+ router$1 = router.useRouter();
51
+ } catch (error) {
52
+ // Calling `useRouter` is not supported in the app folder
53
+ }
54
+ // The router can be undefined if used in a context outside
55
+ // of Next.js (e.g. unit tests, Storybook, ...)
56
+ if (!locale && router$1) {
57
+ locale = router$1.locale;
58
+ }
59
+ // Currently RSC serialize dates to strings, therefore make sure we have
60
+ // a date object. We might be able to remove this once more types have
61
+ // first-class serialization support (https://github.com/facebook/react/issues/25687)
62
+ if (typeof now === 'string') {
63
+ now = new Date(now);
64
+ }
65
+ if (!locale) {
66
+ throw new Error("Couldn't determine locale. Please pass an explicit `locale` prop the provider, or if you're using the `pages` folder, use internationalized routing (https://nextjs.org/docs/advanced-features/i18n-routing)." );
67
+ }
68
+ return React__default["default"].createElement(useIntl.IntlProvider, _extends({
69
+ locale: locale,
70
+ now: now
71
+ }, rest), children);
72
+ }
73
+
74
+ exports.NextIntlClientProvider = NextIntlClientProvider;
75
+ exports.NextIntlProvider = NextIntlClientProvider;
76
+ Object.keys(useIntl).forEach(function (k) {
77
+ if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
78
+ enumerable: true,
79
+ get: function () { return useIntl[k]; }
80
+ });
81
+ });
82
+ //# sourceMappingURL=next-intl.cjs.development.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"next-intl.cjs.development.js","sources":["../src/shared/NextIntlClientProvider.tsx"],"sourcesContent":["'use client';\n\nimport {useRouter} from 'next/router';\nimport React, {ComponentProps} from 'react';\nimport {IntlProvider} from 'use-intl';\n\ntype Props = Omit<ComponentProps<typeof IntlProvider>, 'locale' | 'now'> & {\n locale?: string;\n /** If a string is supplied, make sure this conforms to the ISO 8601 format (YYYY-MM-DDTHH:mm:ss.sssZ */\n now?: Date | string;\n};\n\nexport default function NextIntlClientProvider({\n children,\n locale,\n now,\n ...rest\n}: Props) {\n let router;\n try {\n // Reading from context is practically ok to do conditionally\n // eslint-disable-next-line react-hooks/rules-of-hooks\n router = useRouter();\n } catch (error) {\n // Calling `useRouter` is not supported in the app folder\n }\n\n // The router can be undefined if used in a context outside\n // of Next.js (e.g. unit tests, Storybook, ...)\n if (!locale && router) {\n locale = router.locale;\n }\n\n // Currently RSC serialize dates to strings, therefore make sure we have\n // a date object. We might be able to remove this once more types have\n // first-class serialization support (https://github.com/facebook/react/issues/25687)\n if (typeof now === 'string') {\n now = new Date(now);\n }\n\n if (!locale) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? \"Couldn't determine locale. Please pass an explicit `locale` prop the provider, or if you're using the `pages` folder, use internationalized routing (https://nextjs.org/docs/advanced-features/i18n-routing).\"\n : undefined\n );\n }\n\n return (\n <IntlProvider locale={locale} now={now} {...rest}>\n {children}\n </IntlProvider>\n );\n}\n"],"names":["_excluded","NextIntlClientProvider","_ref","children","locale","now","rest","_objectWithoutPropertiesLoose","router","useRouter","error","Date","Error","React","createElement","IntlProvider","_extends"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAa,IAAAA,SAAA,GAAA,CAAA,UAAA,EAAA,QAAA,EAAA,KAAA,CAAA,CAAA;AAYW,SAAAC,sBAAsBA,CAAAC,IAAA,EAKtC;AAAA,EAAA,IAJNC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;IACRC,MAAM,GAAAF,IAAA,CAANE,MAAM;IACNC,GAAG,GAAAH,IAAA,CAAHG,GAAG;AACAC,IAAAA,IAAI,GAAAC,6BAAA,CAAAL,IAAA,EAAAF,SAAA,CAAA,CAAA;AAEP,EAAA,IAAIQ,QAAM,CAAA;EACV,IAAI;AACF;AACA;IACAA,QAAM,GAAGC,gBAAS,EAAE,CAAA;GACrB,CAAC,OAAOC,KAAK,EAAE;AACd;AAAA,GAAA;AAGF;AACA;AACA,EAAA,IAAI,CAACN,MAAM,IAAII,QAAM,EAAE;IACrBJ,MAAM,GAAGI,QAAM,CAACJ,MAAM,CAAA;AACvB,GAAA;AAED;AACA;AACA;AACA,EAAA,IAAI,OAAOC,GAAG,KAAK,QAAQ,EAAE;AAC3BA,IAAAA,GAAG,GAAG,IAAIM,IAAI,CAACN,GAAG,CAAC,CAAA;AACpB,GAAA;EAED,IAAI,CAACD,MAAM,EAAE;AACX,IAAA,MAAM,IAAIQ,KAAK,CAET,+MAA+M,CACtM,CACd,CAAA;AACF,GAAA;AAED,EAAA,OACEC,yBAAC,CAAAC,aAAA,CAAAC,oBAAY,EAAAC,QAAA,CAAA;AAACZ,IAAAA,MAAM,EAAEA,MAAM;AAAEC,IAAAA,GAAG,EAAEA,GAAAA;GAASC,EAAAA,IAAI,CAC7CH,EAAAA,QAAQ,CACI,CAAA;AAEnB;;;;;;;;;;;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("use-intl"),r=require("next/router");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=t(require("react"));function o(){return o=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},o.apply(this,arguments)}var i=["children","locale","now"];function l(t){var l,u=t.children,a=t.locale,c=t.now,f=function(e,r){if(null==e)return{};var t,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)r.indexOf(t=i[n])>=0||(o[t]=e[t]);return o}(t,i);try{l=r.useRouter()}catch(e){}if(!a&&l&&(a=l.locale),"string"==typeof c&&(c=new Date(c)),!a)throw new Error(void 0);return n.default.createElement(e.IntlProvider,o({locale:a,now:c},f),u)}exports.NextIntlClientProvider=l,exports.NextIntlProvider=l,Object.keys(e).forEach((function(r){"default"===r||exports.hasOwnProperty(r)||Object.defineProperty(exports,r,{enumerable:!0,get:function(){return e[r]}})}));
2
+ //# sourceMappingURL=next-intl.cjs.production.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"next-intl.cjs.production.min.js","sources":["../src/shared/NextIntlClientProvider.tsx"],"sourcesContent":["'use client';\n\nimport {useRouter} from 'next/router';\nimport React, {ComponentProps} from 'react';\nimport {IntlProvider} from 'use-intl';\n\ntype Props = Omit<ComponentProps<typeof IntlProvider>, 'locale' | 'now'> & {\n locale?: string;\n /** If a string is supplied, make sure this conforms to the ISO 8601 format (YYYY-MM-DDTHH:mm:ss.sssZ */\n now?: Date | string;\n};\n\nexport default function NextIntlClientProvider({\n children,\n locale,\n now,\n ...rest\n}: Props) {\n let router;\n try {\n // Reading from context is practically ok to do conditionally\n // eslint-disable-next-line react-hooks/rules-of-hooks\n router = useRouter();\n } catch (error) {\n // Calling `useRouter` is not supported in the app folder\n }\n\n // The router can be undefined if used in a context outside\n // of Next.js (e.g. unit tests, Storybook, ...)\n if (!locale && router) {\n locale = router.locale;\n }\n\n // Currently RSC serialize dates to strings, therefore make sure we have\n // a date object. We might be able to remove this once more types have\n // first-class serialization support (https://github.com/facebook/react/issues/25687)\n if (typeof now === 'string') {\n now = new Date(now);\n }\n\n if (!locale) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? \"Couldn't determine locale. Please pass an explicit `locale` prop the provider, or if you're using the `pages` folder, use internationalized routing (https://nextjs.org/docs/advanced-features/i18n-routing).\"\n : undefined\n );\n }\n\n return (\n <IntlProvider locale={locale} now={now} {...rest}>\n {children}\n </IntlProvider>\n );\n}\n"],"names":["_excluded","NextIntlClientProvider","_ref","router","children","locale","now","rest","_objectWithoutPropertiesLoose","useRouter","error","Date","Error","undefined","React","createElement","IntlProvider","_extends"],"mappings":"6bAAa,IAAAA,EAAA,CAAA,WAAA,SAAA,OAYW,SAAAC,EAAsBC,GAKtC,IACFC,EALJC,EAAQF,EAARE,SACAC,EAAMH,EAANG,OACAC,EAAGJ,EAAHI,IACGC,oIAAIC,CAAAN,EAAAF,GAGP,IAGEG,EAASM,EAASA,WACnB,CAAC,MAAOC,GACP,CAgBF,IAXKL,GAAUF,IACbE,EAASF,EAAOE,QAMC,iBAARC,IACTA,EAAM,IAAIK,KAAKL,KAGZD,EACH,MAAM,IAAIO,WAGJC,GAIR,OACEC,UAACC,cAAAC,EAAYA,aAAAC,EAAA,CAACZ,OAAQA,EAAQC,IAAKA,GAASC,GACzCH,EAGP"}
@@ -1,3 +1,3 @@
1
1
  export * from 'use-intl';
2
- export { default as NextIntlClientProvider, default as NextIntlProvider } from './shared/NextIntlClientProvider.mjs';
3
- import 'react';
2
+ export { default as NextIntlClientProvider, default as NextIntlProvider } from './shared/next-intl.esm.js';
3
+ //# sourceMappingURL=next-intl.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"next-intl.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,3 +1,12 @@
1
- export * from 'use-intl';
2
- export { default as NextIntlClientProvider, default as NextIntlProvider } from '../shared/NextIntlClientProvider.js';
3
- import 'react';
1
+ /**
2
+ * This is the main entry file when non-'react-server'
3
+ * environments import from 'next-intl'.
4
+ *
5
+ * Maintainer notes:
6
+ * - Make sure this mirrors the API from 'react-server'.
7
+ * - Make sure everything exported from this module is
8
+ * supported in all Next.js versions that are supported.
9
+ */
10
+ export * from 'use-intl';
11
+ export { default as NextIntlClientProvider } from '../shared/NextIntlClientProvider';
12
+ export { default as NextIntlProvider } from '../shared/NextIntlClientProvider';
@@ -1,23 +1,17 @@
1
- export * from 'use-intl/dist/src/core';
2
- export { default as NextIntlClientProvider } from '../shared/NextIntlClientProvider.js';
3
- import 'react';
4
- import 'use-intl';
5
-
6
- /**
7
- * This is the main entry file when 'react-server' environments
8
- * (i.e. RSC) import from 'next-intl'. Currently we export everything
9
- * from `use-intl` core, but React-APIs are stubbed out.
10
- *
11
- * Make sure this mirrors the API from '../react-client'.
12
- */
13
-
14
- declare function notSupported(): void;
15
- declare const IntlProvider: typeof notSupported;
16
- declare const useTranslations: typeof notSupported;
17
- declare const useIntl: typeof notSupported;
18
- declare const useLocale: typeof notSupported;
19
- declare const useNow: typeof notSupported;
20
- declare const useTimeZone: typeof notSupported;
21
- declare const Link: typeof notSupported;
22
-
23
- export { IntlProvider, Link, useIntl, useLocale, useNow, useTimeZone, useTranslations };
1
+ /**
2
+ * This is the main entry file when 'react-server' environments
3
+ * (i.e. RSC) import from 'next-intl'. Currently we export everything
4
+ * from `use-intl` core, but React-APIs are stubbed out.
5
+ *
6
+ * Make sure this mirrors the API from '../react-client'.
7
+ */
8
+ export * from 'use-intl/dist/src/core';
9
+ export { default as NextIntlClientProvider } from '../shared/NextIntlClientProvider';
10
+ declare function notSupported(): void;
11
+ export declare const IntlProvider: typeof notSupported;
12
+ export declare const useTranslations: typeof notSupported;
13
+ export declare const useIntl: typeof notSupported;
14
+ export declare const useLocale: typeof notSupported;
15
+ export declare const useNow: typeof notSupported;
16
+ export declare const useTimeZone: typeof notSupported;
17
+ export declare const Link: typeof notSupported;
@@ -1,7 +1,6 @@
1
- import * as next_server from 'next/server';
2
- import MiddlewareConfig from '../middleware/NextIntlMiddlewareConfig.js';
3
-
4
- /** @deprecated Should be imported as `import createMiddleware from 'next-intl/middleware', not from `next-intl/server`. */
5
- declare function createIntlMiddleware(config: MiddlewareConfig): (request: next_server.NextRequest) => next_server.NextResponse<unknown>;
6
-
7
- export { createIntlMiddleware };
1
+ /**
2
+ * Server-only APIs available via `next-intl/server`.
3
+ */
4
+ import MiddlewareConfig from '../middleware/NextIntlMiddlewareConfig';
5
+ /** @deprecated Should be imported as `import createMiddleware from 'next-intl/middleware', not from `next-intl/server`. */
6
+ export declare function createIntlMiddleware(config: MiddlewareConfig): (request: import("next/server").NextRequest) => import("next/server").NextResponse<unknown>;
@@ -1,9 +1,7 @@
1
- import NextLink from 'next/link';
2
- import React, { ComponentProps } from 'react';
3
-
4
- type Props = Omit<ComponentProps<typeof NextLink>, 'locale'> & {
5
- locale: string;
6
- };
7
- declare const _default: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
8
-
9
- export { _default as default };
1
+ import NextLink from 'next/link';
2
+ import React, { ComponentProps } from 'react';
3
+ type Props = Omit<ComponentProps<typeof NextLink>, 'locale'> & {
4
+ locale: string;
5
+ };
6
+ declare const _default: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
7
+ export default _default;
@@ -1,11 +1,9 @@
1
- import { ComponentProps } from 'react';
2
- import { IntlProvider } from 'use-intl';
3
-
4
- type Props = Omit<ComponentProps<typeof IntlProvider>, 'locale' | 'now'> & {
5
- locale?: string;
6
- /** If a string is supplied, make sure this conforms to the ISO 8601 format (YYYY-MM-DDTHH:mm:ss.sssZ */
7
- now?: Date | string;
8
- };
9
- declare function NextIntlClientProvider({ children, locale, now, ...rest }: Props): JSX.Element;
10
-
11
- export { NextIntlClientProvider as default };
1
+ import { ComponentProps } from 'react';
2
+ import { IntlProvider } from 'use-intl';
3
+ type Props = Omit<ComponentProps<typeof IntlProvider>, 'locale' | 'now'> & {
4
+ locale?: string;
5
+ /** If a string is supplied, make sure this conforms to the ISO 8601 format (YYYY-MM-DDTHH:mm:ss.sssZ */
6
+ now?: Date | string;
7
+ };
8
+ export default function NextIntlClientProvider({ children, locale, now, ...rest }: Props): JSX.Element;
9
+ export {};
@@ -1,4 +1,2 @@
1
- declare const COOKIE_LOCALE_NAME = "NEXT_LOCALE";
2
- declare const LOCALE_SEGMENT_NAME = "locale";
3
-
4
- export { COOKIE_LOCALE_NAME, LOCALE_SEGMENT_NAME };
1
+ export declare const COOKIE_LOCALE_NAME = "NEXT_LOCALE";
2
+ export declare const LOCALE_SEGMENT_NAME = "locale";