next-intl 2.14.0 → 2.14.1

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 (145) hide show
  1. package/dist/link/index.d.ts +1 -0
  2. package/dist/next-intl.cjs.development.js +1 -142
  3. package/dist/next-intl.cjs.development.js.map +1 -1
  4. package/dist/next-intl.cjs.production.min.js +1 -1
  5. package/dist/next-intl.cjs.production.min.js.map +1 -1
  6. package/dist/next-intl.esm.js +0 -1
  7. package/dist/next-intl.esm.js.map +1 -1
  8. package/dist/react-client/index.d.ts +4 -2
  9. package/dist/src/client/index.js.map +1 -1
  10. package/dist/src/link/Link.js.map +1 -0
  11. package/dist/src/link/index.d.ts +1 -0
  12. package/dist/src/link/index.js +2 -0
  13. package/dist/src/link/index.js.map +1 -0
  14. package/dist/src/middleware/middleware.js.map +1 -1
  15. package/dist/src/react-client/index.d.ts +4 -2
  16. package/dist/src/react-client/index.js +4 -2
  17. package/dist/src/react-client/index.js.map +1 -1
  18. package/dist/src/react-server/index.js.map +1 -1
  19. package/dist/src/server/index.js.map +1 -1
  20. package/dist/src/shared/constants.js.map +1 -1
  21. package/link.d.ts +1 -0
  22. package/package.json +4 -2
  23. package/src/link/index.tsx +1 -0
  24. package/src/react-client/index.tsx +4 -2
  25. package/dist/client/hasPathnamePrefixed.d.ts +0 -1
  26. package/dist/client/localizeHref.d.ts +0 -4
  27. package/dist/client/next-intl.esm.js +0 -18
  28. package/dist/client/next-intl.esm.js.map +0 -1
  29. package/dist/client/next-intl.esm2.js +0 -18
  30. package/dist/client/next-intl.esm2.js.map +0 -1
  31. package/dist/react-client/next-intl.esm.js +0 -37
  32. package/dist/react-client/next-intl.esm.js.map +0 -1
  33. package/dist/react-client/next-intl.esm2.js +0 -37
  34. package/dist/react-client/next-intl.esm2.js.map +0 -1
  35. package/dist/react-client/next-intl.esm3.js +0 -15
  36. package/dist/react-client/next-intl.esm3.js.map +0 -1
  37. package/dist/react-client/useLocalizedRouter.d.ts +0 -8
  38. package/dist/react-server/Link.d.ts +0 -7
  39. package/dist/react-server/useFormatter.d.ts +0 -2
  40. package/dist/react-server/useHook.d.ts +0 -1
  41. package/dist/react-server/useIntl.d.ts +0 -5
  42. package/dist/react-server/useLocale.d.ts +0 -2
  43. package/dist/react-server/useNow.d.ts +0 -2
  44. package/dist/react-server/useTimeZone.d.ts +0 -2
  45. package/dist/react-server/useTranslations.d.ts +0 -2
  46. package/dist/server/createRequestConfig.d.ts +0 -4
  47. package/dist/server/getConfig.d.ts +0 -23
  48. package/dist/server/getFormatter.d.ts +0 -6
  49. package/dist/server/getIntl.d.ts +0 -7
  50. package/dist/server/getLocale.d.ts +0 -2
  51. package/dist/server/getNow.d.ts +0 -2
  52. package/dist/server/getRequestConfig.d.ts +0 -10
  53. package/dist/server/getTimeZone.d.ts +0 -2
  54. package/dist/server/getTranslations.d.ts +0 -38
  55. package/dist/server/redirect.d.ts +0 -1
  56. package/dist/shared/isLocalUrl.d.ts +0 -5
  57. package/dist/shared/localizePathname.d.ts +0 -1
  58. package/dist/shared/next-intl.esm2.js +0 -49
  59. package/dist/shared/next-intl.esm2.js.map +0 -1
  60. package/dist/shared/next-intl.esm3.js +0 -55
  61. package/dist/shared/next-intl.esm3.js.map +0 -1
  62. package/dist/shared/next-intl.esm4.js +0 -6
  63. package/dist/shared/next-intl.esm4.js.map +0 -1
  64. package/dist/shared/prefixHref.d.ts +0 -4
  65. package/dist/shared/unlocalizePathname.d.ts +0 -1
  66. package/dist/src/client/hasPathnamePrefixed.d.ts +0 -1
  67. package/dist/src/client/hasPathnamePrefixed.js +0 -6
  68. package/dist/src/client/hasPathnamePrefixed.js.map +0 -1
  69. package/dist/src/client/localizeHref.d.ts +0 -4
  70. package/dist/src/client/localizeHref.js +0 -15
  71. package/dist/src/client/localizeHref.js.map +0 -1
  72. package/dist/src/react-client/Link.js.map +0 -1
  73. package/dist/src/react-client/useLocalizedRouter.d.ts +0 -8
  74. package/dist/src/react-client/useLocalizedRouter.js +0 -12
  75. package/dist/src/react-client/useLocalizedRouter.js.map +0 -1
  76. package/dist/src/react-server/Link.d.ts +0 -7
  77. package/dist/src/react-server/Link.js +0 -8
  78. package/dist/src/react-server/Link.js.map +0 -1
  79. package/dist/src/react-server/useFormatter.d.ts +0 -2
  80. package/dist/src/react-server/useFormatter.js +0 -8
  81. package/dist/src/react-server/useFormatter.js.map +0 -1
  82. package/dist/src/react-server/useHook.d.ts +0 -1
  83. package/dist/src/react-server/useHook.js +0 -24
  84. package/dist/src/react-server/useHook.js.map +0 -1
  85. package/dist/src/react-server/useIntl.d.ts +0 -5
  86. package/dist/src/react-server/useIntl.js +0 -11
  87. package/dist/src/react-server/useIntl.js.map +0 -1
  88. package/dist/src/react-server/useLocale.d.ts +0 -2
  89. package/dist/src/react-server/useLocale.js +0 -7
  90. package/dist/src/react-server/useLocale.js.map +0 -1
  91. package/dist/src/react-server/useNow.d.ts +0 -2
  92. package/dist/src/react-server/useNow.js +0 -9
  93. package/dist/src/react-server/useNow.js.map +0 -1
  94. package/dist/src/react-server/useTimeZone.d.ts +0 -2
  95. package/dist/src/react-server/useTimeZone.js +0 -8
  96. package/dist/src/react-server/useTimeZone.js.map +0 -1
  97. package/dist/src/react-server/useTranslations.d.ts +0 -2
  98. package/dist/src/react-server/useTranslations.js +0 -9
  99. package/dist/src/react-server/useTranslations.js.map +0 -1
  100. package/dist/src/server/createRequestConfig.d.ts +0 -4
  101. package/dist/src/server/createRequestConfig.js +0 -5
  102. package/dist/src/server/createRequestConfig.js.map +0 -1
  103. package/dist/src/server/getConfig.d.ts +0 -23
  104. package/dist/src/server/getConfig.js +0 -23
  105. package/dist/src/server/getConfig.js.map +0 -1
  106. package/dist/src/server/getFormatter.d.ts +0 -6
  107. package/dist/src/server/getFormatter.js +0 -9
  108. package/dist/src/server/getFormatter.js.map +0 -1
  109. package/dist/src/server/getIntl.d.ts +0 -7
  110. package/dist/src/server/getIntl.js +0 -15
  111. package/dist/src/server/getIntl.js.map +0 -1
  112. package/dist/src/server/getLocale.d.ts +0 -2
  113. package/dist/src/server/getLocale.js +0 -33
  114. package/dist/src/server/getLocale.js.map +0 -1
  115. package/dist/src/server/getNow.d.ts +0 -2
  116. package/dist/src/server/getNow.js +0 -8
  117. package/dist/src/server/getNow.js.map +0 -1
  118. package/dist/src/server/getRequestConfig.d.ts +0 -10
  119. package/dist/src/server/getRequestConfig.js +0 -7
  120. package/dist/src/server/getRequestConfig.js.map +0 -1
  121. package/dist/src/server/getTimeZone.d.ts +0 -2
  122. package/dist/src/server/getTimeZone.js +0 -8
  123. package/dist/src/server/getTimeZone.js.map +0 -1
  124. package/dist/src/server/getTranslations.d.ts +0 -38
  125. package/dist/src/server/getTranslations.js +0 -23
  126. package/dist/src/server/getTranslations.js.map +0 -1
  127. package/dist/src/server/redirect.d.ts +0 -1
  128. package/dist/src/server/redirect.js +0 -9
  129. package/dist/src/server/redirect.js.map +0 -1
  130. package/dist/src/shared/isLocalUrl.d.ts +0 -5
  131. package/dist/src/shared/isLocalUrl.js +0 -10
  132. package/dist/src/shared/isLocalUrl.js.map +0 -1
  133. package/dist/src/shared/localizePathname.d.ts +0 -1
  134. package/dist/src/shared/localizePathname.js +0 -8
  135. package/dist/src/shared/localizePathname.js.map +0 -1
  136. package/dist/src/shared/prefixHref.d.ts +0 -4
  137. package/dist/src/shared/prefixHref.js +0 -15
  138. package/dist/src/shared/prefixHref.js.map +0 -1
  139. package/dist/src/shared/unlocalizePathname.d.ts +0 -1
  140. package/dist/src/shared/unlocalizePathname.js +0 -4
  141. package/dist/src/shared/unlocalizePathname.js.map +0 -1
  142. /package/dist/{react-client → link}/Link.d.ts +0 -0
  143. /package/dist/src/{react-client → link}/Link.d.ts +0 -0
  144. /package/dist/src/{react-client → link}/Link.js +0 -0
  145. /package/src/{react-client → link}/Link.tsx +0 -0
@@ -0,0 +1 @@
1
+ export { default } from './Link';
@@ -3,15 +3,12 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var useIntl = require('use-intl');
6
- var React = require('react');
7
- var navigation = require('next/navigation');
8
- var NextLink = require('next/link');
9
6
  var router = require('next/router');
7
+ var React = require('react');
10
8
 
11
9
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
12
10
 
13
11
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
14
- var NextLink__default = /*#__PURE__*/_interopDefaultLegacy(NextLink);
15
12
 
16
13
  function _extends() {
17
14
  _extends = Object.assign ? Object.assign.bind() : function (target) {
@@ -40,143 +37,6 @@ function _objectWithoutPropertiesLoose(source, excluded) {
40
37
  return target;
41
38
  }
42
39
 
43
- // Reuse the legacy cookie name
44
- // In a URL like "/en-US/about", the locale segment is "en-US"
45
- var LOCALE_SEGMENT_NAME = 'locale';
46
-
47
- function useClientLocale() {
48
- var locale;
49
- var params = navigation.useParams();
50
- if (params[LOCALE_SEGMENT_NAME]) {
51
- locale = params[LOCALE_SEGMENT_NAME];
52
- } else {
53
- // eslint-disable-next-line react-hooks/rules-of-hooks -- Reading from context conditionally is fine
54
- locale = useIntl.useLocale();
55
- }
56
- return locale;
57
- }
58
-
59
- function isRelativeHref(href) {
60
- var pathname = typeof href === 'object' ? href.pathname : href;
61
- return pathname != null && !pathname.startsWith('/');
62
- }
63
- function isLocalHref(href) {
64
- if (typeof href === 'object') {
65
- return href.host == null && href.hostname == null;
66
- } else {
67
- var hasProtocol = /^[a-z]+:/i.test(href);
68
- return !hasProtocol;
69
- }
70
- }
71
- function localizeHref(href, locale, defaultLocale, pathname) {
72
- if (defaultLocale === void 0) {
73
- defaultLocale = locale;
74
- }
75
- if (!isLocalHref(href) || isRelativeHref(href)) {
76
- return href;
77
- }
78
- var isSwitchingLocale = locale !== defaultLocale;
79
- var isPathnamePrefixed = locale == null || hasPathnamePrefixed(locale, pathname);
80
- var shouldPrefix = isPathnamePrefixed || isSwitchingLocale;
81
- if (shouldPrefix && locale != null) {
82
- return prefixHref(href, locale);
83
- }
84
- return href;
85
- }
86
- function prefixHref(href, locale) {
87
- var prefixedHref;
88
- if (typeof href === 'string') {
89
- prefixedHref = localizePathname(locale, href);
90
- } else {
91
- prefixedHref = _extends({}, href);
92
- if (href.pathname) {
93
- prefixedHref.pathname = localizePathname(locale, href.pathname);
94
- }
95
- }
96
- return prefixedHref;
97
- }
98
- function localizePathname(locale, pathname) {
99
- var localizedHref = '/' + locale;
100
- if (pathname !== '/') {
101
- localizedHref += pathname;
102
- }
103
- return localizedHref;
104
- }
105
- function hasPathnamePrefixed(locale, pathname) {
106
- var prefix = "/" + locale;
107
- return pathname === prefix || pathname.startsWith(prefix + "/");
108
- }
109
-
110
- var _excluded$2 = ["href", "locale", "prefetch"];
111
- function BaseLink(_ref, ref) {
112
- var href = _ref.href,
113
- locale = _ref.locale,
114
- prefetch = _ref.prefetch,
115
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
116
- var pathname = navigation.usePathname();
117
- var defaultLocale = useClientLocale();
118
- var isChangingLocale = locale !== defaultLocale;
119
- var _useState = React.useState(function () {
120
- return isLocalHref(href) && locale ?
121
- // Potentially the href shouldn't be prefixed, but to determine this we
122
- // need a) the default locale and b) the information if we use prefixed
123
- // routing. During the server side render (both in RSC as well as SSR),
124
- // we don't have this information. Therefore we always prefix the href
125
- // since this will always result in a valid URL, even if it might cause
126
- // a redirect. This is better than pointing to a non-localized href
127
- // during the server render, which would potentially be wrong. The final
128
- // href is determined in the effect below.
129
- prefixHref(href, locale) : href;
130
- }),
131
- localizedHref = _useState[0],
132
- setLocalizedHref = _useState[1];
133
- React.useEffect(function () {
134
- setLocalizedHref(localizeHref(href, locale, defaultLocale, pathname != null ? pathname : undefined));
135
- }, [defaultLocale, href, locale, pathname]);
136
- if (isChangingLocale) {
137
- if (prefetch && "development" !== 'production') {
138
- console.error('The `prefetch` prop is currently not supported when using the `locale` prop on `Link` to switch the locale.`');
139
- }
140
- prefetch = false;
141
- }
142
- return React__default["default"].createElement(NextLink__default["default"], _extends({
143
- ref: ref,
144
- href: localizedHref,
145
- prefetch: prefetch
146
- }, rest));
147
- }
148
- var BaseLink$1 = /*#__PURE__*/React.forwardRef(BaseLink);
149
-
150
- var _excluded$1 = ["locale"];
151
- /**
152
- * Wraps `next/link` and prefixes the `href` with the current locale if
153
- * necessary.
154
- *
155
- * @example
156
- * ```tsx
157
- * import {Link} from 'next-intl';
158
- *
159
- * // When the user is on `/en`, the link will point to `/en/about`
160
- * <Link href="/about">About</Link>
161
- *
162
- * // You can override the `locale` to switch to another language
163
- * <Link href="/" locale="de">Switch to German</Link>
164
- * ```
165
- *
166
- * Note that when a `locale` prop is passed to switch the locale, the `prefetch`
167
- * prop is not supported. This is because Next.js would prefetch the page and
168
- * the `set-cookie` response header would cause the locale cookie on the current
169
- * page to be overwritten before the user even decides to change the locale.
170
- */
171
- function Link(_ref) {
172
- var locale = _ref.locale,
173
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
174
- var defaultLocale = useClientLocale();
175
- return React__default["default"].createElement(BaseLink$1, _extends({
176
- locale: locale || defaultLocale
177
- }, rest));
178
- }
179
-
180
40
  var _excluded = ["children", "locale", "now"];
181
41
  function NextIntlClientProvider(_ref) {
182
42
  var children = _ref.children,
@@ -211,7 +71,6 @@ function NextIntlClientProvider(_ref) {
211
71
  }, rest), children);
212
72
  }
213
73
 
214
- exports.Link = Link;
215
74
  exports.NextIntlClientProvider = NextIntlClientProvider;
216
75
  exports.NextIntlProvider = NextIntlClientProvider;
217
76
  Object.keys(useIntl).forEach(function (k) {
@@ -1 +1 @@
1
- {"version":3,"file":"next-intl.cjs.development.js","sources":["../src/shared/constants.tsx","../src/client/useClientLocale.tsx","../src/shared/utils.tsx","../src/shared/BaseLink.tsx","../src/react-client/Link.tsx","../src/shared/NextIntlClientProvider.tsx","../src/client/useRouter.tsx","../src/react-client/useLocalizedRouter.tsx","../src/react-client/index.tsx"],"sourcesContent":["// Reuse the legacy cookie name\n// https://nextjs.org/docs/advanced-features/i18n-routing#leveraging-the-next_locale-cookie\nexport const COOKIE_LOCALE_NAME = 'NEXT_LOCALE';\n\n// Should take precedence over the cookie\nexport const HEADER_LOCALE_NAME = 'X-NEXT-INTL-LOCALE';\n\n// In a URL like \"/en-US/about\", the locale segment is \"en-US\"\nexport const LOCALE_SEGMENT_NAME = 'locale';\n","import {useParams} from 'next/navigation';\nimport {useLocale} from 'use-intl';\nimport {LOCALE_SEGMENT_NAME} from '../shared/constants';\n\nexport default function useClientLocale(): string {\n let locale;\n\n const params = useParams();\n if (params[LOCALE_SEGMENT_NAME]) {\n locale = params[LOCALE_SEGMENT_NAME];\n } else {\n // eslint-disable-next-line react-hooks/rules-of-hooks -- Reading from context conditionally is fine\n locale = useLocale();\n }\n\n return locale;\n}\n","import {UrlObject} from 'url';\nimport NextLink from 'next/link';\nimport {ComponentProps} from 'react';\n\ntype Href = ComponentProps<typeof NextLink>['href'];\n\nexport function isRelativeHref(href: Href) {\n const pathname = typeof href === 'object' ? href.pathname : href;\n return pathname != null && !pathname.startsWith('/');\n}\n\nexport function isLocalHref(href: Href) {\n if (typeof href === 'object') {\n return href.host == null && href.hostname == null;\n } else {\n const hasProtocol = /^[a-z]+:/i.test(href);\n return !hasProtocol;\n }\n}\n\nexport function localizeHref(\n href: string,\n locale: string,\n defaultLocale: string,\n pathname: string\n): string;\nexport function localizeHref(\n href: UrlObject | string,\n locale: string,\n defaultLocale: string,\n pathname: string\n): UrlObject | string;\nexport function localizeHref(\n href: UrlObject | string,\n locale: string,\n defaultLocale: string = locale,\n pathname: string\n) {\n if (!isLocalHref(href) || isRelativeHref(href)) {\n return href;\n }\n\n const isSwitchingLocale = locale !== defaultLocale;\n const isPathnamePrefixed =\n locale == null || hasPathnamePrefixed(locale, pathname);\n const shouldPrefix = isPathnamePrefixed || isSwitchingLocale;\n\n if (shouldPrefix && locale != null) {\n return prefixHref(href, locale);\n }\n\n return href;\n}\n\nexport function prefixHref(href: string, locale: string): string;\nexport function prefixHref(\n href: UrlObject | string,\n locale: string\n): UrlObject | string;\nexport function prefixHref(href: UrlObject | string, locale: string) {\n let prefixedHref;\n if (typeof href === 'string') {\n prefixedHref = localizePathname(locale, href);\n } else {\n prefixedHref = {...href};\n if (href.pathname) {\n prefixedHref.pathname = localizePathname(locale, href.pathname);\n }\n }\n\n return prefixedHref;\n}\n\nexport function unlocalizePathname(pathname: string, locale: string) {\n return pathname.replace(new RegExp(`^/${locale}`), '') || '/';\n}\n\nexport function localizePathname(locale: string, pathname: string) {\n let localizedHref = '/' + locale;\n\n if (pathname !== '/') {\n localizedHref += pathname;\n }\n\n return localizedHref;\n}\n\nexport function hasPathnamePrefixed(locale: string, pathname: string) {\n const prefix = `/${locale}`;\n return pathname === prefix || pathname.startsWith(`${prefix}/`);\n}\n","'use client';\n\nimport NextLink from 'next/link';\nimport {usePathname} from 'next/navigation';\nimport React, {ComponentProps, forwardRef, useEffect, useState} from 'react';\nimport useClientLocale from '../client/useClientLocale';\nimport {isLocalHref, localizeHref, prefixHref} from './utils';\n\ntype Props = Omit<ComponentProps<typeof NextLink>, 'locale'> & {\n locale: string;\n};\n\nfunction BaseLink({href, locale, prefetch, ...rest}: Props, ref: Props['ref']) {\n const pathname = usePathname();\n const defaultLocale = useClientLocale();\n const isChangingLocale = locale !== defaultLocale;\n\n const [localizedHref, setLocalizedHref] = useState<typeof href>(() =>\n isLocalHref(href) && locale\n ? // Potentially the href shouldn't be prefixed, but to determine this we\n // need a) the default locale and b) the information if we use prefixed\n // routing. During the server side render (both in RSC as well as SSR),\n // we don't have this information. Therefore we always prefix the href\n // since this will always result in a valid URL, even if it might cause\n // a redirect. This is better than pointing to a non-localized href\n // during the server render, which would potentially be wrong. The final\n // href is determined in the effect below.\n prefixHref(href, locale)\n : href\n );\n\n useEffect(() => {\n setLocalizedHref(\n localizeHref(href, locale, defaultLocale, pathname ?? undefined)\n );\n }, [defaultLocale, href, locale, pathname]);\n\n if (isChangingLocale) {\n if (prefetch && process.env.NODE_ENV !== 'production') {\n console.error(\n 'The `prefetch` prop is currently not supported when using the `locale` prop on `Link` to switch the locale.`'\n );\n }\n prefetch = false;\n }\n\n return (\n <NextLink ref={ref} href={localizedHref} prefetch={prefetch} {...rest} />\n );\n}\n\nexport default forwardRef(BaseLink);\n","import React, {ComponentProps} from 'react';\nimport useClientLocale from '../client/useClientLocale';\nimport BaseLink from '../shared/BaseLink';\n\ntype Props = Omit<ComponentProps<typeof BaseLink>, 'locale'> & {\n locale?: string;\n};\n\n/**\n * Wraps `next/link` and prefixes the `href` with the current locale if\n * necessary.\n *\n * @example\n * ```tsx\n * import {Link} from 'next-intl';\n *\n * // When the user is on `/en`, the link will point to `/en/about`\n * <Link href=\"/about\">About</Link>\n *\n * // You can override the `locale` to switch to another language\n * <Link href=\"/\" locale=\"de\">Switch to German</Link>\n * ```\n *\n * Note that when a `locale` prop is passed to switch the locale, the `prefetch`\n * prop is not supported. This is because Next.js would prefetch the page and\n * the `set-cookie` response header would cause the locale cookie on the current\n * page to be overwritten before the user even decides to change the locale.\n */\nexport default function Link({locale, ...rest}: Props) {\n const defaultLocale = useClientLocale();\n return <BaseLink locale={locale || defaultLocale} {...rest} />;\n}\n","'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","import {useRouter as useNextRouter} from 'next/navigation';\nimport {useMemo} from 'react';\nimport {localizeHref} from '../shared/utils';\nimport useClientLocale from './useClientLocale';\n\n/**\n * Returns a wrapped instance of `useRouter` from `next/navigation` that\n * will automatically localize the `href` parameters it receives.\n *\n * @example\n * ```tsx\n * 'use client';\n *\n * import {useRouter} from 'next-intl/client';\n *\n * const router = useRouter();\n *\n * // When the user is on `/en`, the router will navigate to `/en/about`\n * router.push('/about');\n * ```\n */\nexport default function useRouter() {\n const router = useNextRouter();\n const locale = useClientLocale();\n\n return useMemo(() => {\n function localize(href: string) {\n return localizeHref(href, locale, locale, window.location.pathname);\n }\n\n return {\n ...router,\n push(href: string) {\n return router.push(localize(href));\n },\n replace(href: string) {\n return router.replace(localize(href));\n },\n prefetch(href: string) {\n return router.prefetch(localize(href));\n }\n };\n }, [locale, router]);\n}\n","import useRouter from '../client/useRouter';\n\n// TODO: Only available for backwards compatibility\n// during the beta, remove for stable release\n\nlet hasWarned = false;\n\nexport default function useLocalizedRouterDeprecated() {\n if (!hasWarned) {\n console.warn(\n `\\n\\nDEPRECATION WARNING: The \\`useLocalizedRouter\\` import from \\`next-intl\\` is deprecated and will be removed in the stable release of next-intl. Please import \\`useLocalizedRouter\\` from \\`next-intl/client\\` instead. See https://next-intl-docs.vercel.app/docs/next-13/server-components\\n\\n`\n );\n hasWarned = true;\n }\n\n return useRouter();\n}\n","/**\n * This is the main entry file when non-'react-server'\n * environments import from 'next-intl'.\n *\n * Make sure this mirrors the API from 'react-server'.\n */\n\nimport Link from './Link';\n\n\nexport * from 'use-intl';\nexport {default as Link} from './Link';\nexport {default as NextIntlClientProvider} from '../shared/NextIntlClientProvider';\n\n// Legacy export (TBD if we'll deprecate this in favour of `NextIntlClientProvider`)\nexport {default as NextIntlProvider} from '../shared/NextIntlClientProvider';\n\n\n/** @deprecated Is called `Link` now. */\nexport const LocalizedLink = Link;\n\nexport {default as useLocalizedRouter} from './useLocalizedRouter';\n"],"names":["LOCALE_SEGMENT_NAME","useClientLocale","locale","params","useParams","useLocale","isRelativeHref","href","pathname","startsWith","isLocalHref","host","hostname","hasProtocol","test","localizeHref","defaultLocale","isSwitchingLocale","isPathnamePrefixed","hasPathnamePrefixed","shouldPrefix","prefixHref","prefixedHref","localizePathname","_extends","localizedHref","prefix","_excluded","BaseLink","_ref","ref","prefetch","rest","_objectWithoutPropertiesLoose","usePathname","isChangingLocale","_useState","useState","setLocalizedHref","useEffect","undefined","process","console","error","React","createElement","NextLink","forwardRef","Link","NextIntlClientProvider","children","now","router","useRouter","Date","Error","IntlProvider","useNextRouter","useMemo","localize","window","location","push","replace","hasWarned","useLocalizedRouterDeprecated","warn","LocalizedLink"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAOA;AACO,IAAMA,mBAAmB,GAAG,QAAQ;;ACJ7B,SAAUC,eAAeA,GAAA;AACrC,EAAA,IAAIC,MAAM,CAAA;AAEV,EAAA,IAAMC,MAAM,GAAGC,oBAAS,EAAE,CAAA;AAC1B,EAAA,IAAID,MAAM,CAACH,mBAAmB,CAAC,EAAE;AAC/BE,IAAAA,MAAM,GAAGC,MAAM,CAACH,mBAAmB,CAAC,CAAA;AACrC,GAAA,MAAM;AACL;IACAE,MAAM,GAAGG,iBAAS,EAAE,CAAA;AACrB,GAAA;AAED,EAAA,OAAOH,MAAM,CAAA;AACf;;ACVM,SAAUI,cAAcA,CAACC,IAAU,EAAA;EACvC,IAAMC,QAAQ,GAAG,OA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AAC,CAAA;AACtB;;ACzCA;AACA;AAEA,IAAIY,SAAS,GAAG,KAAK,CAAA;AAEP,SAAUC,4BAA4BA,GAAA;EAClD,IAAI,CAACD,SAAS,EAAE;IACdtB,OAAO,CAACwB,IAAI,CAAA,8RAC4R,CACvS,CAAA;AACDF,IAAAA,SAAS,GAAG,IAAI,CAAA;AACjB,GAAA;EAED,OAAOX,SAAS,EAAE,CAAA;AACpB;;AChBA;;;;;AAKG;AAaH;AACO,IAAMc,aAAa,GAAGnB;;;;;;;;;;;;;;"}
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;;;;;;;;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("use-intl"),t=require("react"),r=require("next/navigation"),n=require("next/link"),a=require("next/router");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=o(t),l=o(n);function i(){return i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},i.apply(this,arguments)}function c(e,t){if(null==e)return{};var r,n,a={},o=Object.keys(e);for(n=0;n<o.length;n++)t.indexOf(r=o[n])>=0||(a[r]=e[r]);return a}var f="locale";function s(){var t=r.useParams();return t[f]?t[f]:e.useLocale()}function p(e){return"object"==typeof e?null==e.host&&null==e.hostname:!/^[a-z]+:/i.test(e)}function v(e,t){var r;return"string"==typeof e?r=h(t,e):(r=i({},e),e.pathname&&(r.pathname=h(t,e.pathname))),r}function h(e,t){var r="/"+e;return"/"!==t&&(r+=t),r}var d=["href","locale","prefetch"];function y(e,n){var a=e.href,o=e.locale,f=e.prefetch,h=c(e,d),y=r.usePathname(),b=s(),x=o!==b,m=t.useState((function(){return p(a)&&o?v(a,o):a})),j=m[0],O=m[1];return t.useEffect((function(){O(function(e,t,r,n){if(void 0===r&&(r=t),!p(e)||function(e){var t="object"==typeof e?e.pathname:e;return null!=t&&!t.startsWith("/")}(e))return e;var a=t!==r,o=null==t||function(e,t){var r="/"+e;return t===r||t.startsWith(r+"/")}(t,n);return(o||a)&&null!=t?v(e,t):e}(a,o,b,null!=y?y:void 0))}),[b,a,o,y]),x&&(f=!1),u.default.createElement(l.default,i({ref:n,href:j,prefetch:f},h))}var b=t.forwardRef(y),x=["locale"],m=["children","locale","now"];function j(t){var r,n=t.children,o=t.locale,l=t.now,f=c(t,m);try{r=a.useRouter()}catch(e){}if(!o&&r&&(o=r.locale),"string"==typeof l&&(l=new Date(l)),!o)throw new Error(void 0);return u.default.createElement(e.IntlProvider,i({locale:o,now:l},f),n)}exports.Link=function(e){var t=e.locale,r=c(e,x),n=s();return u.default.createElement(b,i({locale:t||n},r))},exports.NextIntlClientProvider=j,exports.NextIntlProvider=j,Object.keys(e).forEach((function(t){"default"===t||exports.hasOwnProperty(t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));
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
2
  //# sourceMappingURL=next-intl.cjs.production.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"next-intl.cjs.production.min.js","sources":["../src/shared/constants.tsx","../src/client/useClientLocale.tsx","../src/shared/utils.tsx","../src/shared/BaseLink.tsx","../src/react-client/Link.tsx","../src/shared/NextIntlClientProvider.tsx","../src/react-client/useLocalizedRouter.tsx","../src/react-client/index.tsx","../src/client/useRouter.tsx"],"sourcesContent":["// Reuse the legacy cookie name\n// https://nextjs.org/docs/advanced-features/i18n-routing#leveraging-the-next_locale-cookie\nexport const COOKIE_LOCALE_NAME = 'NEXT_LOCALE';\n\n// Should take precedence over the cookie\nexport const HEADER_LOCALE_NAME = 'X-NEXT-INTL-LOCALE';\n\n// In a URL like \"/en-US/about\", the locale segment is \"en-US\"\nexport const LOCALE_SEGMENT_NAME = 'locale';\n","import {useParams} from 'next/navigation';\nimport {useLocale} from 'use-intl';\nimport {LOCALE_SEGMENT_NAME} from '../shared/constants';\n\nexport default function useClientLocale(): string {\n let locale;\n\n const params = useParams();\n if (params[LOCALE_SEGMENT_NAME]) {\n locale = params[LOCALE_SEGMENT_NAME];\n } else {\n // eslint-disable-next-line react-hooks/rules-of-hooks -- Reading from context conditionally is fine\n locale = useLocale();\n }\n\n return locale;\n}\n","import {UrlObject} from 'url';\nimport NextLink from 'next/link';\nimport {ComponentProps} from 'react';\n\ntype Href = ComponentProps<typeof NextLink>['href'];\n\nexport function isRelativeHref(href: Href) {\n const pathname = typeof href === 'object' ? href.pathname : href;\n return pathname != null && !pathname.startsWith('/');\n}\n\nexport function isLocalHref(href: Href) {\n if (typeof href === 'object') {\n return href.host == null && href.hostname == null;\n } else {\n const hasProtocol = /^[a-z]+:/i.test(href);\n return !hasProtocol;\n }\n}\n\nexport function localizeHref(\n href: string,\n locale: string,\n defaultLocale: string,\n pathname: string\n): string;\nexport function localizeHref(\n href: UrlObject | string,\n locale: string,\n defaultLocale: string,\n pathname: string\n): UrlObject | string;\nexport function localizeHref(\n href: UrlObject | string,\n locale: string,\n defaultLocale: string = locale,\n pathname: string\n) {\n if (!isLocalHref(href) || isRelativeHref(href)) {\n return href;\n }\n\n const isSwitchingLocale = locale !== defaultLocale;\n const isPathnamePrefixed =\n locale == null || hasPathnamePrefixed(locale, pathname);\n const shouldPrefix = isPathnamePrefixed || isSwitchingLocale;\n\n if (shouldPrefix && locale != null) {\n return prefixHref(href, locale);\n }\n\n return href;\n}\n\nexport function prefixHref(href: string, locale: string): string;\nexport function prefixHref(\n href: UrlObject | string,\n locale: string\n): UrlObject | string;\nexport function prefixHref(href: UrlObject | string, locale: string) {\n let prefixedHref;\n if (typeof href === 'string') {\n prefixedHref = localizePathname(locale, href);\n } else {\n prefixedHref = {...href};\n if (href.pathname) {\n prefixedHref.pathname = localizePathname(locale, href.pathname);\n }\n }\n\n return prefixedHref;\n}\n\nexport function unlocalizePathname(pathname: string, locale: string) {\n return pathname.replace(new RegExp(`^/${locale}`), '') || '/';\n}\n\nexport function localizePathname(locale: string, pathname: string) {\n let localizedHref = '/' + locale;\n\n if (pathname !== '/') {\n localizedHref += pathname;\n }\n\n return localizedHref;\n}\n\nexport function hasPathnamePrefixed(locale: string, pathname: string) {\n const prefix = `/${locale}`;\n return pathname === prefix || pathname.startsWith(`${prefix}/`);\n}\n","'use client';\n\nimport NextLink from 'next/link';\nimport {usePathname} from 'next/navigation';\nimport React, {ComponentProps, forwardRef, useEffect, useState} from 'react';\nimport useClientLocale from '../client/useClientLocale';\nimport {isLocalHref, localizeHref, prefixHref} from './utils';\n\ntype Props = Omit<ComponentProps<typeof NextLink>, 'locale'> & {\n locale: string;\n};\n\nfunction BaseLink({href, locale, prefetch, ...rest}: Props, ref: Props['ref']) {\n const pathname = usePathname();\n const defaultLocale = useClientLocale();\n const isChangingLocale = locale !== defaultLocale;\n\n const [localizedHref, setLocalizedHref] = useState<typeof href>(() =>\n isLocalHref(href) && locale\n ? // Potentially the href shouldn't be prefixed, but to determine this we\n // need a) the default locale and b) the information if we use prefixed\n // routing. During the server side render (both in RSC as well as SSR),\n // we don't have this information. Therefore we always prefix the href\n // since this will always result in a valid URL, even if it might cause\n // a redirect. This is better than pointing to a non-localized href\n // during the server render, which would potentially be wrong. The final\n // href is determined in the effect below.\n prefixHref(href, locale)\n : href\n );\n\n useEffect(() => {\n setLocalizedHref(\n localizeHref(href, locale, defaultLocale, pathname ?? undefined)\n );\n }, [defaultLocale, href, locale, pathname]);\n\n if (isChangingLocale) {\n if (prefetch && process.env.NODE_ENV !== 'production') {\n console.error(\n 'The `prefetch` prop is currently not supported when using the `locale` prop on `Link` to switch the locale.`'\n );\n }\n prefetch = false;\n }\n\n return (\n <NextLink ref={ref} href={localizedHref} prefetch={prefetch} {...rest} />\n );\n}\n\nexport default forwardRef(BaseLink);\n","import React, {ComponentProps} from 'react';\nimport useClientLocale from '../client/useClientLocale';\nimport BaseLink from '../shared/BaseLink';\n\ntype Props = Omit<ComponentProps<typeof BaseLink>, 'locale'> & {\n locale?: string;\n};\n\n/**\n * Wraps `next/link` and prefixes the `href` with the current locale if\n * necessary.\n *\n * @example\n * ```tsx\n * import {Link} from 'next-intl';\n *\n * // When the user is on `/en`, the link will point to `/en/about`\n * <Link href=\"/about\">About</Link>\n *\n * // You can override the `locale` to switch to another language\n * <Link href=\"/\" locale=\"de\">Switch to German</Link>\n * ```\n *\n * Note that when a `locale` prop is passed to switch the locale, the `prefetch`\n * prop is not supported. This is because Next.js would prefetch the page and\n * the `set-cookie` response header would cause the locale cookie on the current\n * page to be overwritten before the user even decides to change the locale.\n */\nexport default function Link({locale, ...rest}: Props) {\n const defaultLocale = useClientLocale();\n return <BaseLink locale={locale || defaultLocale} {...rest} />;\n}\n","'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","import useRouter from '../client/useRouter';\n\n// TODO: Only available for backwards compatibility\n// during the beta, remove for stable release\n\nlet hasWarned = false;\n\nexport default function useLocalizedRouterDeprecated() {\n if (!hasWarned) {\n console.warn(\n `\\n\\nDEPRECATION WARNING: The \\`useLocalizedRouter\\` import from \\`next-intl\\` is deprecated and will be removed in the stable release of next-intl. Please import \\`useLocalizedRouter\\` from \\`next-intl/client\\` instead. See https://next-intl-docs.vercel.app/docs/next-13/server-components\\n\\n`\n );\n hasWarned = true;\n }\n\n return useRouter();\n}\n","/**\n * This is the main entry file when non-'react-server'\n * environments import from 'next-intl'.\n *\n * Make sure this mirrors the API from 'react-server'.\n */\n\nimport Link from './Link';\n\n\nexport * from 'use-intl';\nexport {default as Link} from './Link';\nexport {default as NextIntlClientProvider} from '../shared/NextIntlClientProvider';\n\n// Legacy export (TBD if we'll deprecate this in favour of `NextIntlClientProvider`)\nexport {default as NextIntlProvider} from '../shared/NextIntlClientProvider';\n\n\n/** @deprecated Is called `Link` now. */\nexport const LocalizedLink = Link;\n\nexport {default as useLocalizedRouter} from './useLocalizedRouter';\n","import {useRouter as useNextRouter} from 'next/navigation';\nimport {useMemo} from 'react';\nimport {localizeHref} from '../shared/utils';\nimport useClientLocale from './useClientLocale';\n\n/**\n * Returns a wrapped instance of `useRouter` from `next/navigation` that\n * will automatically localize the `href` parameters it receives.\n *\n * @example\n * ```tsx\n * 'use client';\n *\n * import {useRouter} from 'next-intl/client';\n *\n * const router = useRouter();\n *\n * // When the user is on `/en`, the router will navigate to `/en/about`\n * router.push('/about');\n * ```\n */\nexport default function useRouter() {\n const router = useNextRouter();\n const locale = useClientLocale();\n\n return useMemo(() => {\n function localize(href: string) {\n return localizeHref(href, locale, locale, window.location.pathname);\n }\n\n return {\n ...router,\n push(href: string) {\n return router.push(localize(href));\n },\n replace(href: string) {\n return router.replace(localize(href));\n },\n prefetch(href: string) {\n return router.prefetch(localize(href));\n }\n };\n }, [locale, router]);\n}\n"],"names":["LOCALE_SEGMENT_NAME","useClientLocale","params","useParams","useLocale","isLocalHref","href","host","hostname","test","localizeHref","locale","defaultLocale","pathname","startsWith","isRelativeHref","isSwitchingLocale","isPathnamePrefixed","prefix","hasPathnamePrefixed","prefixHref","prefixedHref","localizePathname","_extends","localizedHref","_excluded","BaseLink","_ref","ref","prefetch","rest","_objectWithoutPropertiesLoose","usePathname","isChangingLocale","_useState","useState","setLocalizedHref","useEffect","undefined","React","createElement","NextLink","BaseLink$1","forwardRef","Link","NextIntlClientProvider","router","children","now","useRouter","error","Date","Error","IntlProvider","hasWarned","LocalizedLink","console","warn","useNextRouter","useMemo","localize","window","location","push","replace"],"mappings":"goBAQO,IAAMA,EAAsB,SCJrB,SAAUC,IACtB,IAEMC,EAASC,EAAAA,YAQf,OAPID,EAAOF,GACAE,EAAOF,GAGPI,EAASA,WAItB,CCLM,SAAUC,EAAYC,GAC1B,MAAoB,iBAATA,EACW,MAAbA,EAAKC,MAAiC,MAAjBD,EAAKE,UAEb,YAAYC,KAAKH,EAGzC,CAcM,SAAUI,EACdJ,EACAK,EACAC,EACAC,GAEA,QAHA,IAAAD,IAAAA,EAAwBD,IAGnBN,EAAYC,IAhCb,SAAyBA,GAC7B,IAAMO,EAA2B,iBAATP,EAAoBA,EAAKO,SAAWP,EAC5D,OAAmB,MAAZO,IAAqBA,EAASC,WAAW,IAClD,CA6B4BC,CAAeT,GACvC,OAAOA,EAGT,IAAMU,EAAoBL,IAAWC,EAC/BK,EACM,MAAVN,GA2CY,SAAoBA,EAAgBE,GAClD,IAAMK,MAAaP,EACnB,OAAOE,IAAaK,GAAUL,EAASC,WAAcI,EAAM,IAC7D,CA9CsBC,CAAoBR,EAAQE,GAGh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,IAAAL,EAAA,CAAA,WAAA,SAAA,OAYW,SAAAoB,EAAsBlB,GAKtC,IACFmB,EALJC,EAAQpB,EAARoB,SACApC,EAAMgB,EAANhB,OACAqC,EAAGrB,EAAHqB,IACGlB,EAAIC,EAAAJ,EAAAF,GAGP,IAGEqB,EAASG,EAASA,WACnB,CAAC,MAAOC,GACP,CAgBF,IAXKvC,GAAUmC,IACbnC,EAASmC,EAAOnC,QAMC,iBAARqC,IACTA,EAAM,IAAIG,KAAKH,KAGZrC,EACH,MAAM,IAAIyC,WAGJd,GAIR,OACEC,UAACC,cAAAa,EAAYA,aAAA9B,EAAA,CAACZ,OAAQA,EAAQqC,IAAKA,GAASlB,GACzCiB,EAGP,CChDA,IAAIO,GAAY,ECcHC,EAAgBX,gIDZf,WAQZ,OAPKU,IACHE,QAAQC,KAAI,gSAGZH,GAAY,GESF,WACZ,IAAMR,EAASY,EAAAA,YACT/C,EAASV,IAEf,OAAO0D,EAAOA,SAAC,WACb,SAASC,EAAStD,GAChB,OAAOI,EAAaJ,EAAMK,EAAQA,EAAQkD,OAAOC,SAASjD,SAC5D,CAEA,OAAAU,KACKuB,EAAM,CACTiB,KAAI,SAACzD,GACH,OAAOwC,EAAOiB,KAAKH,EAAStD,GAC7B,EACD0D,QAAO,SAAC1D,GACN,OAAOwC,EAAOkB,QAAQJ,EAAStD,GAChC,EACDuB,SAAQ,SAACvB,GACP,OAAOwC,EAAOjB,SAAS+B,EAAStD,GAClC,GAEJ,GAAG,CAACK,EAAQmC,GACd,CF5BSG,EACT"}
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,4 +1,3 @@
1
1
  export * from 'use-intl';
2
- export { default as Link } from './react-client/next-intl.esm.js';
3
2
  export { default as NextIntlClientProvider, default as NextIntlProvider } from './shared/next-intl.esm.js';
4
3
  //# sourceMappingURL=next-intl.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"next-intl.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
1
+ {"version":3,"file":"next-intl.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -2,9 +2,11 @@
2
2
  * This is the main entry file when non-'react-server'
3
3
  * environments import from 'next-intl'.
4
4
  *
5
- * Make sure this mirrors the API from 'react-server'.
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.
6
9
  */
7
10
  export * from 'use-intl';
8
- export { default as Link } from './Link';
9
11
  export { default as NextIntlClientProvider } from '../shared/NextIntlClientProvider';
10
12
  export { default as NextIntlProvider } from '../shared/NextIntlClientProvider';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,aAAa,CAAC;AACjD,OAAO,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,eAAe,CAAC;AAErD,+CAA+C;AAC/C,MAAM,CAAC,MAAM,sBAAsB,GAAG,WAAW,CAAC;AAElD,6CAA6C;AAC7C,MAAM,CAAC,MAAM,kBAAkB,GAAG,SAAS,CAAC;AAE5C,sDAAsD;AACtD,OAAO,EAAC,OAAO,IAAI,sBAAsB,EAAC,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,aAAa,CAAC;AACjD,OAAO,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,eAAe,CAAC;AAErD,sDAAsD;AACtD,OAAO,EAAC,OAAO,IAAI,sBAAsB,EAAC,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Link.js","sourceRoot":"","sources":["../../../src/link/Link.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuB,MAAM,OAAO,CAAC;AAC5C,OAAO,eAAe,MAAM,2BAA2B,CAAC;AACxD,OAAO,QAAQ,MAAM,oBAAoB,CAAC;AAM1C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAAC,MAAM,EAAE,GAAG,IAAI,EAAQ;IACnD,MAAM,aAAa,GAAG,eAAe,EAAE,CAAC;IACxC,OAAO,oBAAC,QAAQ,IAAC,MAAM,EAAE,MAAM,IAAI,aAAa,KAAM,IAAI,GAAI,CAAC;AACjE,CAAC"}
@@ -0,0 +1 @@
1
+ export { default } from './Link';
@@ -0,0 +1,2 @@
1
+ export { default } from './Link';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/link/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,QAAQ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../../src/middleware/middleware.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,YAAY,EAAC,MAAM,aAAa,CAAC;AACtD,OAAO,EAAC,kBAAkB,EAAE,kBAAkB,EAAC,MAAM,qBAAqB,CAAC;AAI3E,OAAO,4BAA4B,MAAM,gCAAgC,CAAC;AAC1E,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,yBAAyB,EAC1B,MAAM,SAAS,CAAC;AAEjB,MAAM,QAAQ,GAAG,GAAG,CAAC;AAErB,SAAS,w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;6BACnB;yBACF;6BAAM;4BACL,QAAQ,GAAG,IAAI,EAAE,CAAC;yBACnB;qBACF;iBACF;qBAAM;oBACL,QAAQ,GAAG,QAAQ,CAAC,IAAI,MAAM,GAAG,QAAQ,EAAE,CAAC,CAAC;iBAC9C;aACF;iBAAM;gBACL,IACE,uBAAuB;oBACvB,CAAC,kBAAkB,CAAC,YAAY,KAAK,WAAW;wBAC9C,kBAAkB,CAAC,OAAO,CAAC,EAC7B;oBACA,QAAQ,GAAG,OAAO,CAAC,IAAI,MAAM,GAAG,cAAc,EAAE,CAAC,CAAC;iBACnD;qBAAM;oBACL,QAAQ,GAAG,QAAQ,CAAC,IAAI,MAAM,GAAG,cAAc,EAAE,CAAC,CAAC;iBACpD;aACF;SACF;QAED,IAAI,iBAAiB,EAAE;YACrB,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;SAClD;QAED,IACE,kBAAkB,CAAC,cAAc;YACjC,kBAAkB,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EACrC;YACA,QAAQ,CAAC,OAAO,CAAC,GAAG,CAClB,MAAM,EACN,4BAA4B,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAC1D,CAAC;SACH;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC;AACJ,CAAC"}
@@ -2,9 +2,11 @@
2
2
  * This is the main entry file when non-'react-server'
3
3
  * environments import from 'next-intl'.
4
4
  *
5
- * Make sure this mirrors the API from 'react-server'.
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.
6
9
  */
7
10
  export * from 'use-intl';
8
- export { default as Link } from './Link';
9
11
  export { default as NextIntlClientProvider } from '../shared/NextIntlClientProvider';
10
12
  export { default as NextIntlProvider } from '../shared/NextIntlClientProvider';
@@ -2,10 +2,12 @@
2
2
  * This is the main entry file when non-'react-server'
3
3
  * environments import from 'next-intl'.
4
4
  *
5
- * Make sure this mirrors the API from 'react-server'.
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.
6
9
  */
7
10
  export * from 'use-intl';
8
- export { default as Link } from './Link';
9
11
  export { default as NextIntlClientProvider } from '../shared/NextIntlClientProvider';
10
12
  // Legacy export (TBD if we'll deprecate this in favour of `NextIntlClientProvider`)
11
13
  export { default as NextIntlProvider } from '../shared/NextIntlClientProvider';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react-client/index.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,IAAI,MAAM,QAAQ,CAAC;AAG1B,cAAc,UAAU,CAAC;AACzB,OAAO,EAAC,OAAO,IAAI,IAAI,EAAC,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAC,OAAO,IAAI,sBAAsB,EAAC,MAAM,kCAAkC,CAAC;AAEnF,oFAAoF;AACpF,OAAO,EAAC,OAAO,IAAI,gBAAgB,EAAC,MAAM,kCAAkC,CAAC;AAG7E,wCAAwC;AACxC,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC;AAElC,OAAO,EAAC,OAAO,IAAI,kBAAkB,EAAC,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react-client/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,cAAc,UAAU,CAAC;AACzB,OAAO,EAAC,OAAO,IAAI,sBAAsB,EAAC,MAAM,kCAAkC,CAAC;AAEnF,oFAAoF;AACpF,OAAO,EAAC,OAAO,IAAI,gBAAgB,EAAC,MAAM,kCAAkC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react-server/index.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,IAAI,MAAM,QAAQ,CAAC;AAE1B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
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/server/index.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,iBAAiB,MAAM,eAAe,CAAC;AAG9C,IAAI,4BAA4B,GAAG,KAAK,CAAC;AACzC,2HAA2H;AAC3H,MAAM,UAAU,oBAAoB,CAAC,MAAwB;IAC3D,IAAI,CAAC,4BAA4B,EAAE;QACjC,4BAA4B,GAAG,IAAI,CAAC;QACpC,OAAO,CAAC,IAAI,CACV;;;;;;;;;;;;CAYL,CACI,CAAC;KACH;IACD,OAAO,iBAAiB,CAAC;QACvB,GAAG,MAAM;QACT,mBAAmB;QACnB,QAAQ,EAAE,CAAC,4BAA4B,CAAC;KACzC,CAAC,CAAC;AACL,CAAC;AAED,OAAO,EAAC,OAAO,IAAI,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAC,OAAO,IAAI,OAAO,EAAC,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,aAAa,CAAC;AACjD,OAAO,EAAC,OAAO,IAAI,MAAM,EAAC,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,eAAe,CAAC;AACrD,OAAO,EAAC,OAAO,IAAI,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAE7D,OAAO,EAAC,OAAO,IAAI,QAAQ,EAAC,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/server/index.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,iBAAiB,MAAM,eAAe,CAAC;AAG9C,IAAI,SAAS,GAAG,KAAK,CAAC;AACtB,2HAA2H;AAC3H,MAAM,UAAU,oBAAoB,CAAC,MAAwB;IAC3D,IAAI,CAAC,SAAS,EAAE;QACd,SAAS,GAAG,IAAI,CAAC;QACjB,OAAO,CAAC,IAAI,CACV;;;;;;;;;;;;CAYL,CACI,CAAC;KACH;IACD,OAAO,iBAAiB,CAAC;QACvB,GAAG,MAAM;QACT,mBAAmB;QACnB,QAAQ,EAAE,CAAC,4BAA4B,CAAC;KACzC,CAAC,CAAC;AACL,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/shared/constants.tsx"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,2FAA2F;AAC3F,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAAC;AAEhD,yCAAyC;AACzC,MAAM,CAAC,MAAM,kBAAkB,GAAG,oBAAoB,CAAC;AAEvD,8DAA8D;AAC9D,MAAM,CAAC,MAAM,mBAAmB,GAAG,QAAQ,CAAC"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/shared/constants.tsx"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,2FAA2F;AAC3F,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAAC;AAEhD,8DAA8D;AAC9D,MAAM,CAAC,MAAM,mBAAmB,GAAG,QAAQ,CAAC"}
package/link.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {default} from './dist/src/link';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-intl",
3
- "version": "2.14.0",
3
+ "version": "2.14.1",
4
4
  "sideEffects": false,
5
5
  "author": "Jan Amann <jan@amann.work>",
6
6
  "description": "A minimal, but complete solution for internationalization in Next.js apps.",
@@ -20,6 +20,7 @@
20
20
  },
21
21
  "./server": "./dist/src/server/index.js",
22
22
  "./client": "./dist/src/client/index.js",
23
+ "./link": "./dist/src/link/index.js",
23
24
  "./middleware": "./dist/src/middleware/index.js"
24
25
  },
25
26
  "files": [
@@ -27,6 +28,7 @@
27
28
  "src",
28
29
  "server.d.ts",
29
30
  "client.d.ts",
31
+ "link.d.ts",
30
32
  "middleware.d.ts"
31
33
  ],
32
34
  "keywords": [
@@ -48,7 +50,7 @@
48
50
  "dependencies": {
49
51
  "@formatjs/intl-localematcher": "^0.2.32",
50
52
  "negotiator": "^0.6.3",
51
- "use-intl": "^2.14.0"
53
+ "use-intl": "^2.14.1"
52
54
  },
53
55
  "peerDependencies": {
54
56
  "next": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0",
@@ -0,0 +1 @@
1
+ export {default} from './Link';
@@ -2,11 +2,13 @@
2
2
  * This is the main entry file when non-'react-server'
3
3
  * environments import from 'next-intl'.
4
4
  *
5
- * Make sure this mirrors the API from 'react-server'.
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.
6
9
  */
7
10
 
8
11
  export * from 'use-intl';
9
- export {default as Link} from './Link';
10
12
  export {default as NextIntlClientProvider} from '../shared/NextIntlClientProvider';
11
13
 
12
14
  // Legacy export (TBD if we'll deprecate this in favour of `NextIntlClientProvider`)
@@ -1 +0,0 @@
1
- export default function hasPathnamePrefixed(locale: string, pathname: string): boolean;
@@ -1,4 +0,0 @@
1
- /// <reference types="node" />
2
- import { UrlObject } from 'url';
3
- export default function localizeHref(href: string, locale: string, defaultLocale?: string, pathname?: string): string;
4
- export default function localizeHref(href: UrlObject | string, locale: string, defaultLocale?: string, pathname?: string): UrlObject | string;
@@ -1,18 +0,0 @@
1
- import { useParams } from 'next/navigation';
2
- import { useLocale } from 'use-intl';
3
- import { LOCALE_SEGMENT_NAME } from '../shared/next-intl.esm4.js';
4
-
5
- function useClientLocale() {
6
- var locale;
7
- var params = useParams();
8
- if (params[LOCALE_SEGMENT_NAME]) {
9
- locale = params[LOCALE_SEGMENT_NAME];
10
- } else {
11
- // eslint-disable-next-line react-hooks/rules-of-hooks -- Reading from context conditionally is fine
12
- locale = useLocale();
13
- }
14
- return locale;
15
- }
16
-
17
- export { useClientLocale as default };
18
- //# sourceMappingURL=next-intl.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"next-intl.esm.js","sources":["../../src/client/useRouter.tsx"],"sourcesContent":["import {useRouter as useNextRouter} from 'next/navigation';\nimport {useMemo} from 'react';\nimport {localizeHref} from '../shared/utils';\nimport useClientLocale from './useClientLocale';\n\n/**\n * Returns a wrapped instance of `useRouter` from `next/navigation` that\n * will automatically localize the `href` parameters it receives.\n *\n * @example\n * ```tsx\n * 'use client';\n *\n * import {useRouter} from 'next-intl/client';\n *\n * const router = useRouter();\n *\n * // When the user is on `/en`, the router will navigate to `/en/about`\n * router.push('/about');\n * ```\n */\nexport default function useRouter() {\n const router = useNextRouter();\n const locale = useClientLocale();\n\n return useMemo(() => {\n function localize(href: string) {\n return localizeHref(href, locale, locale, window.location.pathname);\n }\n\n return {\n ...router,\n push(href: string) {\n return router.push(localize(href));\n },\n replace(href: string) {\n return router.replace(localize(href));\n },\n prefetch(href: string) {\n return router.prefetch(localize(href));\n }\n };\n }, [locale, router]);\n}\n"],"names":["useRouter","router","useNextRouter","locale","useClientLocale","useMemo","localize","href","localizeHref","window","location","pathname","_extends","push","replace","prefetch"],"mappings":";;;;;;AAKA;;;;;;;;;;;;;;;AAeG;AACW,SAAUA,SAASA,GAAA;AAC/B,EAAA,IAAMC,MAAM,GAAGC,WAAa,EAAE,CAAA;AAC9B,EAAA,IAAMC,MAAM,GAAGC,eAAe,EAAE,CAAA;EAEhC,OAAOC,OAAO,CAAC,YAAK;IAClB,SAASC,QAAQA,CAACC,IAAY,EAAA;AAC5B,MAAA,OAAOC,YAAY,CAACD,IAAI,EAAEJ,MAAM,EAAEA,MAAM,EAAEM,MAAM,CAACC,QAAQ,CAACC,QAAQ,CAAC,CAAA;AACrE,KAAA;IAEA,OAAAC,QAAA,KACKX,MAAM,EAAA;MACTY,IAAI,EAAA,SAAAA,IAACN,CAAAA,IAAY,EAAA;QACf,OAAON,MAAM,CAACY,IAAI,CAACP,QAAQ,CAACC,IAAI,CAAC,CAAC,CAAA;OACnC;MACDO,OAAO,EAAA,SAAAA,OAACP,CAAAA,IAAY,EAAA;QAClB,OAAON,MAAM,CAACa,OAAO,CAACR,QAAQ,CAACC,IAAI,CAAC,CAAC,CAAA;OACtC;MACDQ,QAAQ,EAAA,SAAAA,QAACR,CAAAA,IAAY,EAAA;QACnB,OAAON,MAAM,CAACc,QAAQ,CAACT,QAAQ,CAACC,IAAI,CAAC,CAAC,CAAA;AACxC,OAAA;AAAC,KAAA,CAAA,CAAA;AAEL,GAAC,EAAE,CAACJ,MAAM,EAAEF,MAAM,CAAC,CAAC,CAAA;AACtB;;;;"}
@@ -1,18 +0,0 @@
1
- import { useParams } from 'next/navigation';
2
- import { useLocale } from 'use-intl';
3
- import { LOCALE_SEGMENT_NAME } from '../shared/next-intl.esm4.js';
4
-
5
- function useClientLocale() {
6
- var locale;
7
- var params = useParams();
8
- if (params[LOCALE_SEGMENT_NAME]) {
9
- locale = params[LOCALE_SEGMENT_NAME];
10
- } else {
11
- // eslint-disable-next-line react-hooks/rules-of-hooks -- Reading from context conditionally is fine
12
- locale = useLocale();
13
- }
14
- return locale;
15
- }
16
-
17
- export { useClientLocale as default };
18
- //# sourceMappingURL=next-intl.esm2.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"next-intl.esm2.js","sources":["../../src/client/useClientLocale.tsx"],"sourcesContent":["import {useParams} from 'next/navigation';\nimport {useLocale} from 'use-intl';\nimport {LOCALE_SEGMENT_NAME} from '../shared/constants';\n\nexport default function useClientLocale(): string {\n let locale;\n\n const params = useParams();\n if (params[LOCALE_SEGMENT_NAME]) {\n locale = params[LOCALE_SEGMENT_NAME];\n } else {\n // eslint-disable-next-line react-hooks/rules-of-hooks -- Reading from context conditionally is fine\n locale = useLocale();\n }\n\n return locale;\n}\n"],"names":["useClientLocale","locale","params","useParams","LOCALE_SEGMENT_NAME","useLocale"],"mappings":";;;;AAIc,SAAUA,eAAeA,GAAA;AACrC,EAAA,IAAIC,MAAM,CAAA;AAEV,EAAA,IAAMC,MAAM,GAAGC,SAAS,EAAE,CAAA;AAC1B,EAAA,IAAID,MAAM,CAACE,mBAAmB,CAAC,EAAE;AAC/BH,IAAAA,MAAM,GAAGC,MAAM,CAACE,mBAAmB,CAAC,CAAA;AACrC,GAAA,MAAM;AACL;IACAH,MAAM,GAAGI,SAAS,EAAE,CAAA;AACrB,GAAA;AAED,EAAA,OAAOJ,MAAM,CAAA;AACf;;;;"}
@@ -1,37 +0,0 @@
1
- import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose, extends as _extends } from '../_virtual/next-intl.esm.js';
2
- import React from 'react';
3
- import useClientLocale from '../client/next-intl.esm.js';
4
- import BaseLink from '../shared/next-intl.esm2.js';
5
-
6
- var _excluded = ["locale"];
7
- /**
8
- * Wraps `next/link` and prefixes the `href` with the current locale if
9
- * necessary.
10
- *
11
- * @example
12
- * ```tsx
13
- * import {Link} from 'next-intl';
14
- *
15
- * // When the user is on `/en`, the link will point to `/en/about`
16
- * <Link href="/about">About</Link>
17
- *
18
- * // You can override the `locale` to switch to another language
19
- * <Link href="/" locale="de">Switch to German</Link>
20
- * ```
21
- *
22
- * Note that when a `locale` prop is passed to switch the locale, the `prefetch`
23
- * prop is not supported. This is because Next.js would prefetch the page and
24
- * the `set-cookie` response header would cause the locale cookie on the current
25
- * page to be overwritten before the user even decides to change the locale.
26
- */
27
- function Link(_ref) {
28
- var locale = _ref.locale,
29
- rest = _objectWithoutPropertiesLoose(_ref, _excluded);
30
- var defaultLocale = useClientLocale();
31
- return React.createElement(BaseLink, _extends({
32
- locale: locale || defaultLocale
33
- }, rest));
34
- }
35
-
36
- export { Link as default };
37
- //# sourceMappingURL=next-intl.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"next-intl.esm.js","sources":["../../src/react-client/index.tsx"],"sourcesContent":["/**\n * This is the main entry file when non-'react-server'\n * environments import from 'next-intl'.\n *\n * Make sure this mirrors the API from 'react-server'.\n */\n\nimport Link from './Link';\n\n\nexport * from 'use-intl';\nexport {default as Link} from './Link';\nexport {default as NextIntlClientProvider} from '../shared/NextIntlClientProvider';\n\n// Legacy export (TBD if we'll deprecate this in favour of `NextIntlClientProvider`)\nexport {default as NextIntlProvider} from '../shared/NextIntlClientProvider';\n\n\n/** @deprecated Is called `Link` now. */\nexport const LocalizedLink = Link;\n\nexport {default as useLocalizedRouter} from './useLocalizedRouter';\n"],"names":["LocalizedLink","Link"],"mappings":";;;;;;;AAAA;;;;;AAKG;AAaH;AACO,IAAMA,aAAa,GAAGC;;;;"}