next-intl 2.13.0-beta.2 → 2.13.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.
- package/LICENSE +21 -0
- package/README.md +12 -3
- package/dist/client/NextIntlClientProvider.d.ts +4 -0
- package/dist/client/index.d.ts +1 -14
- package/dist/index.d.ts +1 -43
- package/dist/middleware/NextIntlMiddlewareConfig.d.ts +0 -18
- package/dist/middleware/middleware.d.ts +1 -1
- package/dist/next-intl.cjs.development.js +3 -180
- package/dist/next-intl.cjs.development.js.map +1 -1
- package/dist/next-intl.cjs.production.min.js +1 -1
- package/dist/next-intl.cjs.production.min.js.map +1 -1
- package/dist/next-intl.esm.js +1 -18
- package/dist/next-intl.esm.js.map +1 -1
- package/dist/react-server/index.d.ts +8 -46
- package/dist/server/index.d.ts +3 -13
- package/dist/shared/constants.d.ts +0 -1
- package/dist/shared/next-intl.esm.js +31 -55
- package/dist/shared/next-intl.esm.js.map +1 -1
- package/dist/src/client/NextIntlClientProvider.d.ts +4 -0
- package/dist/src/client/NextIntlClientProvider.js +16 -0
- package/dist/src/client/NextIntlClientProvider.js.map +1 -0
- package/dist/src/client/index.d.ts +1 -14
- package/dist/src/client/index.js +1 -14
- package/dist/src/client/index.js.map +1 -1
- package/dist/src/index.d.ts +1 -43
- package/dist/src/index.js +2 -12
- package/dist/src/index.js.map +1 -1
- package/dist/src/middleware/NextIntlMiddlewareConfig.d.ts +0 -18
- package/dist/src/middleware/middleware.d.ts +1 -1
- package/dist/src/middleware/middleware.js +11 -51
- package/dist/src/middleware/middleware.js.map +1 -1
- package/dist/src/react-server/index.d.ts +8 -46
- package/dist/src/react-server/index.js +13 -18
- package/dist/src/react-server/index.js.map +1 -1
- package/dist/src/server/index.d.ts +3 -13
- package/dist/src/server/index.js +25 -14
- package/dist/src/server/index.js.map +1 -1
- package/dist/src/shared/NextIntlClientProvider.js +0 -1
- package/dist/src/shared/NextIntlClientProvider.js.map +1 -1
- package/dist/src/shared/constants.d.ts +0 -1
- package/dist/src/shared/constants.js +0 -2
- package/dist/src/shared/constants.js.map +1 -1
- package/package.json +7 -15
- package/src/client/NextIntlClientProvider.tsx +18 -0
- package/src/client/index.tsx +1 -19
- package/src/index.tsx +2 -15
- package/src/middleware/NextIntlMiddlewareConfig.tsx +0 -21
- package/src/middleware/middleware.tsx +13 -62
- package/src/react-server/index.tsx +15 -22
- package/src/server/index.tsx +27 -17
- package/src/shared/NextIntlClientProvider.tsx +0 -2
- package/src/shared/constants.tsx +0 -3
- package/CHANGELOG.md +0 -551
- package/config.js +0 -3
- package/dist/client/getCookieLocale.d.ts +0 -1
- package/dist/client/hasPathnamePrefixed.d.ts +0 -1
- package/dist/client/localizeHref.d.ts +0 -4
- package/dist/client/next-intl.esm.js +0 -37
- package/dist/client/next-intl.esm.js.map +0 -1
- package/dist/client/next-intl.esm2.js +0 -24
- package/dist/client/next-intl.esm2.js.map +0 -1
- package/dist/client/next-intl.esm3.js +0 -23
- package/dist/client/next-intl.esm3.js.map +0 -1
- package/dist/client/next-intl.esm4.js +0 -7
- package/dist/client/next-intl.esm4.js.map +0 -1
- package/dist/client/usePathname.d.ts +0 -11
- package/dist/client/useRouter.d.ts +0 -8
- package/dist/react-client/next-intl.esm.js +0 -16
- package/dist/react-client/next-intl.esm.js.map +0 -1
- package/dist/react-client/useLocalizedRouter.d.ts +0 -8
- package/dist/react-server/useFormatter.d.ts +0 -2
- package/dist/react-server/useHook.d.ts +0 -1
- package/dist/react-server/useIntl.d.ts +0 -5
- package/dist/react-server/useLocale.d.ts +0 -2
- package/dist/react-server/useNow.d.ts +0 -2
- package/dist/react-server/useTimeZone.d.ts +0 -2
- package/dist/react-server/useTranslations.d.ts +0 -2
- package/dist/server/NextIntlConfig.d.ts +0 -6
- package/dist/server/createRequestConfig.d.ts +0 -4
- package/dist/server/getConfig.d.ts +0 -23
- package/dist/server/getFormatter.d.ts +0 -6
- package/dist/server/getIntl.d.ts +0 -7
- package/dist/server/getLocale.d.ts +0 -2
- package/dist/server/getNow.d.ts +0 -2
- package/dist/server/getRequestConfig.d.ts +0 -5
- package/dist/server/getTimeZone.d.ts +0 -2
- package/dist/server/getTranslations.d.ts +0 -38
- package/dist/server/redirect.d.ts +0 -1
- package/dist/shared/Link.d.ts +0 -7
- package/dist/shared/LocalizedLink.d.ts +0 -7
- package/dist/shared/localizePathname.d.ts +0 -1
- package/dist/shared/next-intl.esm2.js +0 -47
- package/dist/shared/next-intl.esm2.js.map +0 -1
- package/dist/shared/next-intl.esm3.js +0 -12
- package/dist/shared/next-intl.esm3.js.map +0 -1
- package/dist/shared/next-intl.esm4.js +0 -6
- package/dist/shared/next-intl.esm4.js.map +0 -1
- package/dist/src/client/getCookieLocale.d.ts +0 -1
- package/dist/src/client/getCookieLocale.js +0 -17
- package/dist/src/client/getCookieLocale.js.map +0 -1
- package/dist/src/client/hasPathnamePrefixed.d.ts +0 -1
- package/dist/src/client/hasPathnamePrefixed.js +0 -6
- package/dist/src/client/hasPathnamePrefixed.js.map +0 -1
- package/dist/src/client/localizeHref.d.ts +0 -4
- package/dist/src/client/localizeHref.js +0 -30
- package/dist/src/client/localizeHref.js.map +0 -1
- package/dist/src/client/usePathname.d.ts +0 -11
- package/dist/src/client/usePathname.js +0 -40
- package/dist/src/client/usePathname.js.map +0 -1
- package/dist/src/client/useRouter.d.ts +0 -8
- package/dist/src/client/useRouter.js +0 -19
- package/dist/src/client/useRouter.js.map +0 -1
- package/dist/src/react-client/useLocalizedRouter.d.ts +0 -8
- package/dist/src/react-client/useLocalizedRouter.js +0 -12
- package/dist/src/react-client/useLocalizedRouter.js.map +0 -1
- package/dist/src/react-server/useFormatter.d.ts +0 -2
- package/dist/src/react-server/useFormatter.js +0 -8
- package/dist/src/react-server/useFormatter.js.map +0 -1
- package/dist/src/react-server/useHook.d.ts +0 -1
- package/dist/src/react-server/useHook.js +0 -24
- package/dist/src/react-server/useHook.js.map +0 -1
- package/dist/src/react-server/useIntl.d.ts +0 -5
- package/dist/src/react-server/useIntl.js +0 -11
- package/dist/src/react-server/useIntl.js.map +0 -1
- package/dist/src/react-server/useLocale.d.ts +0 -2
- package/dist/src/react-server/useLocale.js +0 -7
- package/dist/src/react-server/useLocale.js.map +0 -1
- package/dist/src/react-server/useNow.d.ts +0 -2
- package/dist/src/react-server/useNow.js +0 -9
- package/dist/src/react-server/useNow.js.map +0 -1
- package/dist/src/react-server/useTimeZone.d.ts +0 -2
- package/dist/src/react-server/useTimeZone.js +0 -8
- package/dist/src/react-server/useTimeZone.js.map +0 -1
- package/dist/src/react-server/useTranslations.d.ts +0 -2
- package/dist/src/react-server/useTranslations.js +0 -9
- package/dist/src/react-server/useTranslations.js.map +0 -1
- package/dist/src/server/NextIntlConfig.d.ts +0 -6
- package/dist/src/server/NextIntlConfig.js +0 -2
- package/dist/src/server/NextIntlConfig.js.map +0 -1
- package/dist/src/server/createRequestConfig.d.ts +0 -4
- package/dist/src/server/createRequestConfig.js +0 -5
- package/dist/src/server/createRequestConfig.js.map +0 -1
- package/dist/src/server/getConfig.d.ts +0 -23
- package/dist/src/server/getConfig.js +0 -23
- package/dist/src/server/getConfig.js.map +0 -1
- package/dist/src/server/getFormatter.d.ts +0 -6
- package/dist/src/server/getFormatter.js +0 -9
- package/dist/src/server/getFormatter.js.map +0 -1
- package/dist/src/server/getIntl.d.ts +0 -7
- package/dist/src/server/getIntl.js +0 -15
- package/dist/src/server/getIntl.js.map +0 -1
- package/dist/src/server/getLocale.d.ts +0 -2
- package/dist/src/server/getLocale.js +0 -33
- package/dist/src/server/getLocale.js.map +0 -1
- package/dist/src/server/getNow.d.ts +0 -2
- package/dist/src/server/getNow.js +0 -8
- package/dist/src/server/getNow.js.map +0 -1
- package/dist/src/server/getRequestConfig.d.ts +0 -5
- package/dist/src/server/getRequestConfig.js +0 -4
- package/dist/src/server/getRequestConfig.js.map +0 -1
- package/dist/src/server/getTimeZone.d.ts +0 -2
- package/dist/src/server/getTimeZone.js +0 -8
- package/dist/src/server/getTimeZone.js.map +0 -1
- package/dist/src/server/getTranslations.d.ts +0 -38
- package/dist/src/server/getTranslations.js +0 -23
- package/dist/src/server/getTranslations.js.map +0 -1
- package/dist/src/server/redirect.d.ts +0 -1
- package/dist/src/server/redirect.js +0 -9
- package/dist/src/server/redirect.js.map +0 -1
- package/dist/src/shared/Link.d.ts +0 -7
- package/dist/src/shared/Link.js +0 -45
- package/dist/src/shared/Link.js.map +0 -1
- package/dist/src/shared/LocalizedLink.d.ts +0 -7
- package/dist/src/shared/LocalizedLink.js +0 -18
- package/dist/src/shared/LocalizedLink.js.map +0 -1
- package/dist/src/shared/localizePathname.d.ts +0 -1
- package/dist/src/shared/localizePathname.js +0 -8
- package/dist/src/shared/localizePathname.js.map +0 -1
- package/plugin.d.ts +0 -3
- package/plugin.js +0 -65
- package/src/client/getCookieLocale.tsx +0 -19
- package/src/client/hasPathnamePrefixed.tsx +0 -7
- package/src/client/localizeHref.tsx +0 -46
- package/src/client/usePathname.tsx +0 -48
- package/src/client/useRouter.tsx +0 -23
- package/src/react-client/useLocalizedRouter.tsx +0 -17
- package/src/react-server/useFormatter.tsx +0 -10
- package/src/react-server/useHook.tsx +0 -30
- package/src/react-server/useIntl.tsx +0 -15
- package/src/react-server/useLocale.tsx +0 -9
- package/src/react-server/useNow.tsx +0 -15
- package/src/react-server/useTimeZone.tsx +0 -10
- package/src/react-server/useTranslations.tsx +0 -13
- package/src/server/NextIntlConfig.tsx +0 -16
- package/src/server/createRequestConfig.tsx +0 -9
- package/src/server/getConfig.tsx +0 -27
- package/src/server/getFormatter.tsx +0 -10
- package/src/server/getIntl.tsx +0 -20
- package/src/server/getLocale.tsx +0 -40
- package/src/server/getNow.tsx +0 -9
- package/src/server/getRequestConfig.tsx +0 -13
- package/src/server/getTimeZone.tsx +0 -9
- package/src/server/getTranslations.tsx +0 -102
- package/src/server/redirect.tsx +0 -10
- package/src/shared/Link.tsx +0 -61
- package/src/shared/LocalizedLink.tsx +0 -26
- package/src/shared/localizePathname.tsx +0 -9
- package/withNextIntl.d.ts +0 -5
- package/withNextIntl.js +0 -13
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Jan Amann
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
<h1 align="center">
|
|
2
2
|
<br>
|
|
3
3
|
<br>
|
|
4
|
-
|
|
4
|
+
<a href="https://next-intl-docs.vercel.app/">
|
|
5
|
+
<img width="400" src="media/logo.svg" alt="next-intl">
|
|
6
|
+
</a>
|
|
5
7
|
<br>
|
|
6
8
|
<br>
|
|
7
9
|
<br>
|
|
8
10
|
</h1>
|
|
9
11
|
|
|
10
|
-
> Internationalization for Next.js that gets out of your way.
|
|
12
|
+
> Internationalization (i18n) for Next.js that gets out of your way.
|
|
11
13
|
|
|
12
14
|
  [<img src="https://img.shields.io/npm/dw/next-intl.svg" />](https://www.npmjs.com/package/next-intl)
|
|
13
15
|
|
|
14
16
|
<hr />
|
|
15
17
|
|
|
16
|
-
📣 [Support for Next.js 13
|
|
18
|
+
📣 [Support for Server Components in Next.js 13 is coming →](https://next-intl-docs.vercel.app/docs/next-13)
|
|
17
19
|
|
|
18
20
|
<hr />
|
|
19
21
|
|
|
@@ -68,3 +70,10 @@ function UserDetails({user}) {
|
|
|
68
70
|
```
|
|
69
71
|
|
|
70
72
|
### [→ Read the docs](https://next-intl-docs.vercel.app/)
|
|
73
|
+
|
|
74
|
+
<div align="center">
|
|
75
|
+
<a href="https://next-intl-docs.vercel.app/redirect?href=https://crowdin.com" target="_blank">
|
|
76
|
+
<img width="350" src="media/partner.svg" alt="Crowdin logo">
|
|
77
|
+
</a>
|
|
78
|
+
<br>
|
|
79
|
+
</div>
|
|
@@ -0,0 +1,4 @@
|
|
|
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;
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,14 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Client-only APIs.
|
|
3
|
-
*/
|
|
4
|
-
import NextIntlClientProvider_ from '../shared/NextIntlClientProvider';
|
|
5
|
-
import usePathname from './usePathname';
|
|
6
|
-
import useRouter from './useRouter';
|
|
7
|
-
export { default as useRouter } from './useRouter';
|
|
8
|
-
export { default as usePathname } from './usePathname';
|
|
9
|
-
/** @deprecated Is called `usePathname` now. */
|
|
10
|
-
export declare const useUnlocalizedPathname: typeof usePathname;
|
|
11
|
-
/** @deprecated Is called `useRouter` now. */
|
|
12
|
-
export declare const useLocalizedRouter: typeof useRouter;
|
|
13
|
-
/** @deprecated Should be imported from `next-intl`, not `next-intl/client`. */
|
|
14
|
-
export declare const NextIntlClientProvider: typeof NextIntlClientProvider_;
|
|
1
|
+
export { default as NextIntlClientProvider } from './NextIntlClientProvider';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,45 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This is the main entry file when non-'react-server' environments import
|
|
3
|
-
* from 'next-intl'. Make sure this mirrors the API from 'react-server'.
|
|
4
|
-
*/
|
|
5
|
-
/// <reference types="react" />
|
|
6
|
-
/// <reference types="node" />
|
|
7
|
-
import NextIntlClientProvider from './shared/NextIntlClientProvider';
|
|
8
1
|
export * from 'use-intl';
|
|
9
|
-
export { default as useLocalizedRouter } from './react-client/useLocalizedRouter';
|
|
10
|
-
export { default as Link } from './shared/Link';
|
|
11
2
|
export { default as NextIntlClientProvider } from './shared/NextIntlClientProvider';
|
|
12
|
-
|
|
13
|
-
export declare const NextIntlProvider: typeof NextIntlClientProvider;
|
|
14
|
-
/** @deprecated Is called `Link` now. */
|
|
15
|
-
export declare const LocalizedLink: import("react").ForwardRefExoticComponent<Pick<Omit<Omit<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, keyof {
|
|
16
|
-
href: string | import("url").UrlObject;
|
|
17
|
-
as?: (string | import("url").UrlObject) | undefined;
|
|
18
|
-
replace?: boolean | undefined;
|
|
19
|
-
scroll?: boolean | undefined;
|
|
20
|
-
shallow?: boolean | undefined;
|
|
21
|
-
passHref?: boolean | undefined;
|
|
22
|
-
prefetch?: boolean | undefined;
|
|
23
|
-
locale?: string | false | undefined;
|
|
24
|
-
legacyBehavior?: boolean | undefined;
|
|
25
|
-
onMouseEnter?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
26
|
-
onTouchStart?: import("react").TouchEventHandler<HTMLAnchorElement> | undefined;
|
|
27
|
-
onClick?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
28
|
-
}> & {
|
|
29
|
-
href: string | import("url").UrlObject;
|
|
30
|
-
as?: (string | import("url").UrlObject) | undefined;
|
|
31
|
-
replace?: boolean | undefined;
|
|
32
|
-
scroll?: boolean | undefined;
|
|
33
|
-
shallow?: boolean | undefined;
|
|
34
|
-
passHref?: boolean | undefined;
|
|
35
|
-
prefetch?: boolean | undefined;
|
|
36
|
-
locale?: string | false | undefined;
|
|
37
|
-
legacyBehavior?: boolean | undefined;
|
|
38
|
-
onMouseEnter?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
39
|
-
onTouchStart?: import("react").TouchEventHandler<HTMLAnchorElement> | undefined;
|
|
40
|
-
onClick?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
41
|
-
} & {
|
|
42
|
-
children?: import("react").ReactNode;
|
|
43
|
-
} & import("react").RefAttributes<HTMLAnchorElement>, "locale"> & {
|
|
44
|
-
locale?: string | undefined;
|
|
45
|
-
}, "href" | "as" | "replace" | "scroll" | "shallow" | "passHref" | "prefetch" | "locale" | "legacyBehavior" | "onMouseEnter" | "onTouchStart" | "onClick" | "download" | "hrefLang" | "media" | "ping" | "rel" | "target" | "type" | "referrerPolicy" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "nonce" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "key"> & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
3
|
+
export { default as NextIntlProvider } from './shared/NextIntlClientProvider';
|
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
declare type RoutingConfigPrefix = {
|
|
2
|
-
type: 'prefix';
|
|
3
|
-
/** 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`.
|
|
4
|
-
*/
|
|
5
|
-
prefix?: 'as-needed' | 'always';
|
|
6
|
-
};
|
|
7
|
-
declare type RoutingConfigDomain = {
|
|
8
|
-
type: 'domain';
|
|
9
|
-
/** Provide a list of mappings between domains and locales. Note that the `x-forwarded-host` or alternatively the `host` header will be used to determine the requested domain. */
|
|
10
|
-
domains: Array<{
|
|
11
|
-
domain: string;
|
|
12
|
-
locale: string;
|
|
13
|
-
}>;
|
|
14
|
-
};
|
|
15
1
|
declare type LocalePrefix = 'as-needed' | 'always';
|
|
16
2
|
declare type RoutingBaseConfig = {
|
|
17
3
|
/** A list of all locales that are supported. */
|
|
@@ -25,8 +11,6 @@ export declare type DomainConfig = Omit<RoutingBaseConfig, 'locales' | 'localePr
|
|
|
25
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. */
|
|
26
12
|
domain: string;
|
|
27
13
|
locales?: RoutingBaseConfig['locales'];
|
|
28
|
-
/** @deprecated Use `defaultLocale` instead. */
|
|
29
|
-
locale?: string;
|
|
30
14
|
};
|
|
31
15
|
declare type MiddlewareConfig = RoutingBaseConfig & {
|
|
32
16
|
/** Can be used to change the locale handling per domain. */
|
|
@@ -35,8 +19,6 @@ declare type MiddlewareConfig = RoutingBaseConfig & {
|
|
|
35
19
|
localeDetection?: boolean;
|
|
36
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 */
|
|
37
21
|
alternateLinks?: boolean;
|
|
38
|
-
/** @deprecated Deprecated in favor of `localePrefix` and `domains`. */
|
|
39
|
-
routing?: RoutingConfigPrefix | RoutingConfigDomain;
|
|
40
22
|
};
|
|
41
23
|
export declare type MiddlewareConfigWithDefaults = MiddlewareConfig & {
|
|
42
24
|
alternateLinks: boolean;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { NextRequest, NextResponse } from 'next/server';
|
|
2
2
|
import MiddlewareConfig from './NextIntlMiddlewareConfig';
|
|
3
|
-
export default function
|
|
3
|
+
export default function createMiddleware(config: MiddlewareConfig): (request: NextRequest) => NextResponse;
|
|
@@ -2,15 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var NextLink = require('next/link');
|
|
6
|
-
var navigation = require('next/navigation');
|
|
7
|
-
var React = require('react');
|
|
8
|
-
var router = require('next/router');
|
|
9
5
|
var useIntl = require('use-intl');
|
|
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
|
-
var NextLink__default = /*#__PURE__*/_interopDefaultLegacy(NextLink);
|
|
14
11
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
15
12
|
|
|
16
13
|
function _extends() {
|
|
@@ -46,138 +43,7 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
46
43
|
return target;
|
|
47
44
|
}
|
|
48
45
|
|
|
49
|
-
function localizePathname(locale, pathname) {
|
|
50
|
-
var localizedHref = '/' + locale;
|
|
51
|
-
|
|
52
|
-
if (pathname !== '/') {
|
|
53
|
-
localizedHref += pathname;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return localizedHref;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Reuse the legacy cookie name
|
|
60
|
-
// https://nextjs.org/docs/advanced-features/i18n-routing#leveraging-the-next_locale-cookie
|
|
61
|
-
var COOKIE_LOCALE_NAME = 'NEXT_LOCALE'; // Should take precedence over the cookie
|
|
62
|
-
|
|
63
|
-
function getCookieValueByName(name) {
|
|
64
|
-
// https://stackoverflow.com/a/15724300/343045
|
|
65
|
-
var value = "; " + document.cookie;
|
|
66
|
-
var parts = value.split("; " + name + "=");
|
|
67
|
-
|
|
68
|
-
if (parts.length === 2) {
|
|
69
|
-
var _parts$pop;
|
|
70
|
-
|
|
71
|
-
var part = (_parts$pop = parts.pop()) == null ? void 0 : _parts$pop.split(';').shift();
|
|
72
|
-
if (part) return part;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
throw new Error("Unable to find next-intl cookie, have you configured the middleware?");
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function getCookieLocale() {
|
|
79
|
-
return getCookieValueByName(COOKIE_LOCALE_NAME);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function hasPathnamePrefixed(locale, pathname) {
|
|
83
|
-
var prefix = "/" + locale;
|
|
84
|
-
return pathname === prefix || pathname.startsWith(prefix + "/") && pathname.length > prefix.length;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function localizeHref(href, locale, pathname) {
|
|
88
|
-
var cookieLocale = getCookieLocale();
|
|
89
|
-
if (!locale) locale = cookieLocale;
|
|
90
|
-
|
|
91
|
-
if (!pathname) {
|
|
92
|
-
pathname = window.location.pathname;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
var isSwitchingLocale = locale !== cookieLocale;
|
|
96
|
-
var isPathnamePrefixed = hasPathnamePrefixed(locale, pathname);
|
|
97
|
-
|
|
98
|
-
if (isPathnamePrefixed || isSwitchingLocale) {
|
|
99
|
-
var prefixedHref;
|
|
100
|
-
|
|
101
|
-
if (typeof href === 'string') {
|
|
102
|
-
prefixedHref = localizePathname(locale, href);
|
|
103
|
-
} else {
|
|
104
|
-
prefixedHref = _extends({}, href);
|
|
105
|
-
|
|
106
|
-
if (href.pathname) {
|
|
107
|
-
prefixedHref.pathname = localizePathname(locale, href.pathname);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return prefixedHref;
|
|
112
|
-
} else {
|
|
113
|
-
return href;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
var _excluded$1 = ["href", "locale", "prefetch"];
|
|
118
|
-
/**
|
|
119
|
-
* Wraps `next/link` and prefixes the `href` with the current locale.
|
|
120
|
-
*
|
|
121
|
-
* Note that when a `locale` prop is passed, two de-optimizations are made:
|
|
122
|
-
*
|
|
123
|
-
* 1. The `prefetch` prop is not supported. This is because Next.js prefetches
|
|
124
|
-
* the page and the `set-cookie` response header will cause the locale cookie
|
|
125
|
-
* on the current page to be overwritten.
|
|
126
|
-
* 2. A regular anchor tag is used instead of `next/link`. This is to avoid a
|
|
127
|
-
* bug with Server Components where the markup wouldn't be updated correctly
|
|
128
|
-
* otherwise.
|
|
129
|
-
*/
|
|
130
|
-
|
|
131
|
-
function Link(_ref, ref) {
|
|
132
|
-
var href = _ref.href,
|
|
133
|
-
locale = _ref.locale,
|
|
134
|
-
prefetch = _ref.prefetch,
|
|
135
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
136
|
-
|
|
137
|
-
var _useState = React.useState(href),
|
|
138
|
-
localizedHref = _useState[0],
|
|
139
|
-
setLocalizedHref = _useState[1];
|
|
140
|
-
|
|
141
|
-
var pathname = navigation.usePathname();
|
|
142
|
-
React.useEffect(function () {
|
|
143
|
-
setLocalizedHref(localizeHref(href, locale, pathname != null ? pathname : undefined));
|
|
144
|
-
}, [href, locale, pathname]);
|
|
145
|
-
|
|
146
|
-
if (locale !== undefined) {
|
|
147
|
-
// If Next.js fixes the bug where the markup isn't updated correctly when
|
|
148
|
-
// the locale changes, we can remove this check. Note however that we still
|
|
149
|
-
// need to disable prefetching (see comment above).
|
|
150
|
-
if (prefetch && "development" !== 'production') {
|
|
151
|
-
console.error('The `prefetch` prop is currently not supported when using the `locale` prop on `Link`.`');
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
var localizedHrefString;
|
|
155
|
-
|
|
156
|
-
if (typeof localizedHref === 'string') {
|
|
157
|
-
localizedHrefString = localizedHref;
|
|
158
|
-
} else if (localizedHref) {
|
|
159
|
-
localizedHrefString = localizedHref.toString();
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
return (// eslint-disable-next-line jsx-a11y/anchor-has-content
|
|
163
|
-
React__default["default"].createElement("a", _extends({
|
|
164
|
-
ref: ref,
|
|
165
|
-
href: localizedHrefString
|
|
166
|
-
}, rest))
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
return React__default["default"].createElement(NextLink__default["default"], _extends({
|
|
171
|
-
ref: ref,
|
|
172
|
-
href: localizedHref,
|
|
173
|
-
prefetch: prefetch
|
|
174
|
-
}, rest));
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
var Link$1 = /*#__PURE__*/React.forwardRef(Link);
|
|
178
|
-
|
|
179
46
|
var _excluded = ["children", "locale", "now"];
|
|
180
|
-
|
|
181
47
|
function NextIntlClientProvider(_ref) {
|
|
182
48
|
var children = _ref.children,
|
|
183
49
|
locale = _ref.locale,
|
|
@@ -216,51 +82,8 @@ function NextIntlClientProvider(_ref) {
|
|
|
216
82
|
}, rest), children);
|
|
217
83
|
}
|
|
218
84
|
|
|
219
|
-
function useRouter() {
|
|
220
|
-
var router = navigation.useRouter();
|
|
221
|
-
return React.useMemo(function () {
|
|
222
|
-
return _extends({}, router, {
|
|
223
|
-
push: function push(href) {
|
|
224
|
-
return router.push(localizeHref(href));
|
|
225
|
-
},
|
|
226
|
-
replace: function replace(href) {
|
|
227
|
-
return router.replace(localizeHref(href));
|
|
228
|
-
},
|
|
229
|
-
prefetch: function prefetch(href) {
|
|
230
|
-
return router.prefetch(localizeHref(href));
|
|
231
|
-
}
|
|
232
|
-
});
|
|
233
|
-
}, [router]);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// during the beta, remove for stable release
|
|
237
|
-
|
|
238
|
-
var hasWarned = false;
|
|
239
|
-
function useLocalizedRouterDeprecated() {
|
|
240
|
-
if (!hasWarned) {
|
|
241
|
-
console.warn("\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");
|
|
242
|
-
hasWarned = true;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
return useRouter();
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* This is the main entry file when non-'react-server' environments import
|
|
250
|
-
* from 'next-intl'. Make sure this mirrors the API from 'react-server'.
|
|
251
|
-
*/
|
|
252
|
-
/** @deprecated Is called `NextIntlClientProvider` now. */
|
|
253
|
-
|
|
254
|
-
var NextIntlProvider = NextIntlClientProvider;
|
|
255
|
-
/** @deprecated Is called `Link` now. */
|
|
256
|
-
|
|
257
|
-
var LocalizedLink = Link$1;
|
|
258
|
-
|
|
259
|
-
exports.Link = Link$1;
|
|
260
|
-
exports.LocalizedLink = LocalizedLink;
|
|
261
85
|
exports.NextIntlClientProvider = NextIntlClientProvider;
|
|
262
|
-
exports.NextIntlProvider =
|
|
263
|
-
exports.useLocalizedRouter = useLocalizedRouterDeprecated;
|
|
86
|
+
exports.NextIntlProvider = NextIntlClientProvider;
|
|
264
87
|
Object.keys(useIntl).forEach(function (k) {
|
|
265
88
|
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
|
|
266
89
|
enumerable: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next-intl.cjs.development.js","sources":["../src/shared/localizePathname.tsx","../src/shared/constants.tsx","../src/client/getCookieLocale.tsx","../src/client/hasPathnamePrefixed.tsx","../src/client/localizeHref.tsx","../src/shared/Link.tsx","../src/shared/NextIntlClientProvider.tsx","../src/client/useRouter.tsx","../src/react-client/useLocalizedRouter.tsx","../src/index.tsx"],"sourcesContent":["export default function localizePathname(locale: string, pathname: string) {\n let localizedHref = '/' + locale;\n\n if (pathname !== '/') {\n localizedHref += pathname;\n }\n\n return localizedHref;\n}\n","// 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","import {COOKIE_LOCALE_NAME} from '../shared/constants';\n\nfunction getCookieValueByName(name: string) {\n // https://stackoverflow.com/a/15724300/343045\n const value = `; ${document.cookie}`;\n const parts = value.split(`; ${name}=`);\n if (parts.length === 2) {\n const part = parts.pop()?.split(';').shift();\n if (part) return part;\n }\n\n throw new Error(\n `Unable to find next-intl cookie, have you configured the middleware?`\n );\n}\n\nexport default function getCookieLocale() {\n return getCookieValueByName(COOKIE_LOCALE_NAME);\n}\n","export default function hasPathnamePrefixed(locale: string, pathname: string) {\n const prefix = `/${locale}`;\n return (\n pathname === prefix ||\n (pathname.startsWith(`${prefix}/`) && pathname.length > prefix.length)\n );\n}\n","import {UrlObject} from 'url';\nimport localizePathname from '../shared/localizePathname';\nimport getCookieLocale from './getCookieLocale';\nimport hasPathnamePrefixed from './hasPathnamePrefixed';\n\nexport default function localizeHref(\n href: string,\n locale?: string,\n pathname?: string\n): string;\nexport default function localizeHref(\n href: UrlObject | string,\n locale?: string,\n pathname?: string\n): UrlObject | string;\nexport default function localizeHref(\n href: UrlObject | string,\n locale?: string,\n pathname?: string\n) {\n const cookieLocale = getCookieLocale();\n if (!locale) locale = cookieLocale;\n\n if (!pathname) {\n pathname = window.location.pathname;\n }\n\n const isSwitchingLocale = locale !== cookieLocale;\n const isPathnamePrefixed = hasPathnamePrefixed(locale, pathname);\n\n if (isPathnamePrefixed || isSwitchingLocale) {\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 } else {\n return href;\n }\n}\n","'use client';\n\nimport NextLink from 'next/link';\nimport {usePathname} from 'next/navigation';\nimport React, {ComponentProps, forwardRef, useEffect, useState} from 'react';\nimport localizeHref from '../client/localizeHref';\n\ntype Props = Omit<ComponentProps<typeof NextLink>, 'locale'> & {\n locale?: string;\n};\n\n/**\n * Wraps `next/link` and prefixes the `href` with the current locale.\n *\n * Note that when a `locale` prop is passed, two de-optimizations are made:\n *\n * 1. The `prefetch` prop is not supported. This is because Next.js prefetches\n * the page and the `set-cookie` response header will cause the locale cookie\n * on the current page to be overwritten.\n * 2. A regular anchor tag is used instead of `next/link`. This is to avoid a\n * bug with Server Components where the markup wouldn't be updated correctly\n * otherwise.\n */\nfunction Link({href, locale, prefetch, ...rest}: Props, ref: Props['ref']) {\n const [localizedHref, setLocalizedHref] = useState<typeof href>(href);\n const pathname = usePathname();\n\n useEffect(() => {\n setLocalizedHref(localizeHref(href, locale, pathname ?? undefined));\n }, [href, locale, pathname]);\n\n if (locale !== undefined) {\n // If Next.js fixes the bug where the markup isn't updated correctly when\n // the locale changes, we can remove this check. Note however that we still\n // need to disable prefetching (see comment above).\n\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`.`'\n );\n }\n\n let localizedHrefString;\n if (typeof localizedHref === 'string') {\n localizedHrefString = localizedHref;\n } else if (localizedHref) {\n localizedHrefString = localizedHref.toString();\n }\n\n return (\n // eslint-disable-next-line jsx-a11y/anchor-has-content\n <a ref={ref} href={localizedHrefString} {...rest} />\n );\n }\n\n return (\n <NextLink ref={ref} href={localizedHref} prefetch={prefetch} {...rest} />\n );\n}\n\nexport default forwardRef(Link);\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\n// Move this from /client to default\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 './localizeHref';\n\nexport default function useRouter() {\n const router = useNextRouter();\n\n return useMemo(\n () => ({\n ...router,\n push(href: string) {\n return router.push(localizeHref(href));\n },\n replace(href: string) {\n return router.replace(localizeHref(href));\n },\n prefetch(href: string) {\n return router.prefetch(localizeHref(href));\n }\n }),\n [router]\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' environments import\n * from 'next-intl'. Make sure this mirrors the API from 'react-server'.\n */\n\nimport Link from './shared/Link';\nimport NextIntlClientProvider from './shared/NextIntlClientProvider';\n\nexport * from 'use-intl';\n\nexport {default as useLocalizedRouter} from './react-client/useLocalizedRouter';\nexport {default as Link} from './shared/Link';\nexport {default as NextIntlClientProvider} from './shared/NextIntlClientProvider';\n\n/** @deprecated Is called `NextIntlClientProvider` now. */\nexport const NextIntlProvider = NextIntlClientProvider;\n\n/** @deprecated Is called `Link` now. */\nexport const LocalizedLink = Link;\n"],"names":["localizePathname","locale","pathname","localizedHref","COOKIE_LOCALE_NAME","getCookieValueByName","name","value","document","cookie","parts","split","length","part","pop","shift","Error","getCookieLocale","hasPathnamePrefixed","prefix","startsWith","localizeHref","href","cookieLocale","window","location","isSwitchingLocale","isPathnamePrefixed","prefixedHref","Link","ref","prefetch","rest","_excluded","useState","setLocalizedHref","usePathname","useEffect","undefined","process","console","error","localizedHrefString","toString","React","createElement","NextLink","forwardRef","NextIntlClientProvider","children","now","router","useRouter","Date","IntlProvider","useNextRouter","useMemo","push","replace","hasWarned","useLocalizedRouterDeprecated","warn","NextIntlProvider","LocalizedLink"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAc,SAAUA,gBAAV,CAA2BC,MAA3B,EAA2CC,QAA3C,EAA2D;AACvE,EAAIC,IAAAA,aAAa,GAAG,GAAA,GAAMF,MAA1B,CAAA;;AAEA,EAAIC,IAAAA,QAAQ,KAAK,GAAjB,EAAsB;AACpBC,IAAAA,aAAa,IAAID,QAAjB,CAAA;AACD,GAAA;;AAED,EAAA,OAAOC,aAAP,CAAA;AACD;;ACRD;AACA;AACO,IAAMC,kBAAkB,GAAG,aAA3B;;ACAP,SAASC,oBAAT,CAA8BC,IAA9B,EAA0C;AACx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,CAAxB,CAAP,CAAA;AACD,OAJH;AAKEoC,MAAAA,OALF,EAKUpC,SAAAA,OAAAA,CAAAA,IALV,EAKsB;AAClB,QAAO6B,OAAAA,MAAM,CAACO,OAAP,CAAerC,YAAY,CAACC,IAAD,CAA3B,CAAP,CAAA;AACD,OAPH;AAQES,MAAAA,QARF,EAQWT,SAAAA,QAAAA,CAAAA,IARX,EAQuB;AACnB,QAAO6B,OAAAA,MAAM,CAACpB,QAAP,CAAgBV,YAAY,CAACC,IAAD,CAA5B,CAAP,CAAA;AACD,OAAA;AAVH,KAAA,CAAA,CAAA;AAAA,GADY,EAaZ,CAAC6B,MAAD,CAbY,CAAd,CAAA;AAeD;;ACnBD;;AAEA,IAAIQ,SAAS,GAAG,KAAhB,CAAA;AAEc,SAAUC,4BAAV,GAAsC;AAClD,EAAI,IAAA,CAACD,SAAL,EAAgB;AACdnB,IAAAA,OAAO,CAACqB,IAAR,CAAA,8RAAA,CAAA,CAAA;AAGAF,IAAAA,SAAS,GAAG,IAAZ,CAAA;AACD,GAAA;;AAED,EAAA,OAAOP,SAAS,EAAhB,CAAA;AACD;;AChBD;;;AAGG;AAWH;;AACO,IAAMU,gBAAgB,GAAGd,uBAAzB;AAEP;;AACO,IAAMe,aAAa,GAAGlC;;;;;;;;;;;;;;"}
|
|
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":["NextIntlClientProvider","children","locale","now","rest","router","useRouter","error","Date","Error","React","createElement","IntlProvider"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYwB,SAAAA,sBAAA,CAKhB,IAAA,EAAA;AAAA,EAJNC,IAAAA,QAIM,QAJNA,QAIM;AAAA,MAHNC,MAGM,QAHNA,MAGM;AAAA,MAFNC,GAEM,QAFNA,GAEM;AAAA,MADHC,IACG,GAAA,6BAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AACN,EAAA,IAAIC,QAAJ,CAAA;;AACA,EAAI,IAAA;AACF;AACA;AACAA,IAAAA,QAAM,GAAGC,gBAAS,EAAlB,CAAA;AACD,GAJD,CAIE,OAAOC,KAAP,EAAc;AAEf,GARK;AAWN;;;AACA,EAAA,IAAI,CAACL,MAAD,IAAWG,QAAf,EAAuB;AACrBH,IAAAA,MAAM,GAAGG,QAAM,CAACH,MAAhB,CAAA;AACD,GAdK;AAiBN;AACA;;;AACA,EAAA,IAAI,OAAOC,GAAP,KAAe,QAAnB,EAA6B;AAC3BA,IAAAA,GAAG,GAAG,IAAIK,IAAJ,CAASL,GAAT,CAAN,CAAA;AACD,GAAA;;AAED,EAAI,IAAA,CAACD,MAAL,EAAa;AACX,IAAA,MAAM,IAAIO,KAAJ,CAEA,+MADJ,CADI,CAAN,CAAA;AAKD,GAAA;;AAED,EAAA,OACEC,yBAAC,CAAAC,aAAD,CAACC,oBAAD,EAAA,QAAA,CAAA;AAAcV,IAAAA,MAAM,EAAEA,MAAtB;AAA8BC,IAAAA,GAAG,EAAEA,GAAAA;AAAnC,GAA4CC,EAAAA,IAA5C,CACGH,EAAAA,QADH,CADF,CAAA;AAKD;;;;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("
|
|
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||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 l=["children","locale","now"];function u(t){var u,i=t.children,a=t.locale,c=t.now,f=function(e,r){if(null==e)return{};var t,n,o={},l=Object.keys(e);for(n=0;n<l.length;n++)r.indexOf(t=l[n])>=0||(o[t]=e[t]);return o}(t,l);try{u=r.useRouter()}catch(e){}if(!a&&u&&(a=u.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),i)}exports.NextIntlClientProvider=u,exports.NextIntlProvider=u,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/localizePathname.tsx","../src/client/localizeHref.tsx","../src/client/getCookieLocale.tsx","../src/client/hasPathnamePrefixed.tsx","../src/shared/Link.tsx","../src/shared/NextIntlClientProvider.tsx","../src/react-client/useLocalizedRouter.tsx","../src/index.tsx","../src/client/useRouter.tsx"],"sourcesContent":["export default function localizePathname(locale: string, pathname: string) {\n let localizedHref = '/' + locale;\n\n if (pathname !== '/') {\n localizedHref += pathname;\n }\n\n return localizedHref;\n}\n","import {UrlObject} from 'url';\nimport localizePathname from '../shared/localizePathname';\nimport getCookieLocale from './getCookieLocale';\nimport hasPathnamePrefixed from './hasPathnamePrefixed';\n\nexport default function localizeHref(\n href: string,\n locale?: string,\n pathname?: string\n): string;\nexport default function localizeHref(\n href: UrlObject | string,\n locale?: string,\n pathname?: string\n): UrlObject | string;\nexport default function localizeHref(\n href: UrlObject | string,\n locale?: string,\n pathname?: string\n) {\n const cookieLocale = getCookieLocale();\n if (!locale) locale = cookieLocale;\n\n if (!pathname) {\n pathname = window.location.pathname;\n }\n\n const isSwitchingLocale = locale !== cookieLocale;\n const isPathnamePrefixed = hasPathnamePrefixed(locale, pathname);\n\n if (isPathnamePrefixed || isSwitchingLocale) {\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 } else {\n return href;\n }\n}\n","import {COOKIE_LOCALE_NAME} from '../shared/constants';\n\nfunction getCookieValueByName(name: string) {\n // https://stackoverflow.com/a/15724300/343045\n const value = `; ${document.cookie}`;\n const parts = value.split(`; ${name}=`);\n if (parts.length === 2) {\n const part = parts.pop()?.split(';').shift();\n if (part) return part;\n }\n\n throw new Error(\n `Unable to find next-intl cookie, have you configured the middleware?`\n );\n}\n\nexport default function getCookieLocale() {\n return getCookieValueByName(COOKIE_LOCALE_NAME);\n}\n","export default function hasPathnamePrefixed(locale: string, pathname: string) {\n const prefix = `/${locale}`;\n return (\n pathname === prefix ||\n (pathname.startsWith(`${prefix}/`) && pathname.length > prefix.length)\n );\n}\n","'use client';\n\nimport NextLink from 'next/link';\nimport {usePathname} from 'next/navigation';\nimport React, {ComponentProps, forwardRef, useEffect, useState} from 'react';\nimport localizeHref from '../client/localizeHref';\n\ntype Props = Omit<ComponentProps<typeof NextLink>, 'locale'> & {\n locale?: string;\n};\n\n/**\n * Wraps `next/link` and prefixes the `href` with the current locale.\n *\n * Note that when a `locale` prop is passed, two de-optimizations are made:\n *\n * 1. The `prefetch` prop is not supported. This is because Next.js prefetches\n * the page and the `set-cookie` response header will cause the locale cookie\n * on the current page to be overwritten.\n * 2. A regular anchor tag is used instead of `next/link`. This is to avoid a\n * bug with Server Components where the markup wouldn't be updated correctly\n * otherwise.\n */\nfunction Link({href, locale, prefetch, ...rest}: Props, ref: Props['ref']) {\n const [localizedHref, setLocalizedHref] = useState<typeof href>(href);\n const pathname = usePathname();\n\n useEffect(() => {\n setLocalizedHref(localizeHref(href, locale, pathname ?? undefined));\n }, [href, locale, pathname]);\n\n if (locale !== undefined) {\n // If Next.js fixes the bug where the markup isn't updated correctly when\n // the locale changes, we can remove this check. Note however that we still\n // need to disable prefetching (see comment above).\n\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`.`'\n );\n }\n\n let localizedHrefString;\n if (typeof localizedHref === 'string') {\n localizedHrefString = localizedHref;\n } else if (localizedHref) {\n localizedHrefString = localizedHref.toString();\n }\n\n return (\n // eslint-disable-next-line jsx-a11y/anchor-has-content\n <a ref={ref} href={localizedHrefString} {...rest} />\n );\n }\n\n return (\n <NextLink ref={ref} href={localizedHref} prefetch={prefetch} {...rest} />\n );\n}\n\nexport default forwardRef(Link);\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\n// Move this from /client to default\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' environments import\n * from 'next-intl'. Make sure this mirrors the API from 'react-server'.\n */\n\nimport Link from './shared/Link';\nimport NextIntlClientProvider from './shared/NextIntlClientProvider';\n\nexport * from 'use-intl';\n\nexport {default as useLocalizedRouter} from './react-client/useLocalizedRouter';\nexport {default as Link} from './shared/Link';\nexport {default as NextIntlClientProvider} from './shared/NextIntlClientProvider';\n\n/** @deprecated Is called `NextIntlClientProvider` now. */\nexport const NextIntlProvider = NextIntlClientProvider;\n\n/** @deprecated Is called `Link` now. */\nexport const LocalizedLink = Link;\n","import {useRouter as useNextRouter} from 'next/navigation';\nimport {useMemo} from 'react';\nimport localizeHref from './localizeHref';\n\nexport default function useRouter() {\n const router = useNextRouter();\n\n return useMemo(\n () => ({\n ...router,\n push(href: string) {\n return router.push(localizeHref(href));\n },\n replace(href: string) {\n return router.replace(localizeHref(href));\n },\n prefetch(href: string) {\n return router.prefetch(localizeHref(href));\n }\n }),\n [router]\n );\n}\n"],"names":["localizePathname","locale","pathname","localizedHref","localizeHref","href","cookieLocale","name","parts","document","cookie","split","length","_parts$pop","part","pop","shift","Error","getCookieValueByName","window","location","prefixedHref","isSwitchingLocale","isPathnamePrefixed","prefix","startsWith","hasPathnamePrefixed","Link","ref","localizedHrefString","prefetch","rest","_objectWithoutPropertiesLoose","_ref","_excluded","useState","_useState","setLocalizedHref","usePathname","useEffect","undefined","toString","React","createElement","_extends","NextLink","Link$1","forwardRef","NextIntlClientProvider","children","router","now","useRouter","error","Date","IntlProvider","hasWarned","NextIntlProvider","LocalizedLink","console","warn","useNextRouter","useMemo","push","replace"],"mappings":"4mBAAc,SAAUA,EAAiBC,EAAgBC,GACnDC,IAAAA,EAAgB,IAAMF,EAM1B,MAJiB,MAAbC,IACFC,GAAiBD,GAGZC,ECQe,SAAAC,EACtBC,EACAJ,EACAC,GAEMI,IAAAA,EClBR,SAA8BC,GAE5B,IACMC,GADK,KAAQC,SAASC,QACRC,MAAN,kBACd,GAAqB,IAAjBH,EAAMI,OAAc,CAAA,IAAAC,EAChBC,EAAO,OAAHD,EAAGL,EAAMO,YAAN,EAAAF,EAAaF,MAAM,KAAKK,QACjCF,GAAAA,EAAM,OAAOA,EAGb,MAAA,IAAIG,MAAV,wEAMOC,GDIFjB,IAAQA,EAASK,GAEjBJ,IACHA,EAAWiB,OAAOC,SAASlB,UAG7B,IAIMm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AAIG,KAAKH,KAGZlD,EACH,MAAM,IAAIgB,WAGJuB,GAIR,OACEE,UAACC,cAAAY,EAADA,aAAAX,EAAA,CAAc3C,OAAQA,EAAQkD,IAAKA,GAASpB,GACzCkB,GC/CP,IAAIO,GAAY,ECUHC,EAAmBT,EAGnBU,EAAgB/B,gIDXf,WAQZ,OAPK6B,IACHG,QAAQC,KAAR,gSAGAJ,GAAY,GERF,WACNN,IAAAA,EAASW,EAAAA,YAEf,OAAOC,EAAOA,SACZ,WAAA,OAAAlB,EAAA,GACKM,EADL,CAEEa,KAAK1D,SAAAA,GACI6C,OAAAA,EAAOa,KAAK3D,EAAaC,KAElC2D,QAAQ3D,SAAAA,GACC6C,OAAAA,EAAOc,QAAQ5D,EAAaC,KAErCyB,SAASzB,SAAAA,GACA6C,OAAAA,EAAOpB,SAAS1B,EAAaC,SAGxC,CAAC6C,IFLIE"}
|
|
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":["NextIntlClientProvider","_ref","children","router","locale","now","rest","_objectWithoutPropertiesLoose","_excluded","useRouter","error","Date","Error","undefined","React","createElement","IntlProvider","_extends"],"mappings":"2cAYwB,SAAAA,EAKhBC,GAJNC,IAKIC,EALJD,IAAAA,SACAE,IAAAA,OACAC,IAAAA,IACGC,oIACGC,CAAAN,EAAAO,GAEF,IAGFL,EAASM,EAASA,YAClB,MAAOC,IAiBL,IAXCN,GAAUD,IACbC,EAASD,EAAOC,QAMC,iBAARC,IACTA,EAAM,IAAIM,KAAKN,KAGZD,EACH,MAAM,IAAIQ,WAGJC,GAIR,OACEC,UAACC,cAAAC,EAADA,aAAAC,EAAA,CAAcb,OAAQA,EAAQC,IAAKA,GAASC,GACzCJ"}
|
package/dist/next-intl.esm.js
CHANGED
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
import Link from './shared/next-intl.esm.js';
|
|
2
|
-
export { default as Link } from './shared/next-intl.esm.js';
|
|
3
|
-
import NextIntlClientProvider from './shared/next-intl.esm2.js';
|
|
4
|
-
export { default as NextIntlClientProvider } from './shared/next-intl.esm2.js';
|
|
5
1
|
export * from 'use-intl';
|
|
6
|
-
export { default as
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* This is the main entry file when non-'react-server' environments import
|
|
10
|
-
* from 'next-intl'. Make sure this mirrors the API from 'react-server'.
|
|
11
|
-
*/
|
|
12
|
-
/** @deprecated Is called `NextIntlClientProvider` now. */
|
|
13
|
-
|
|
14
|
-
var NextIntlProvider = NextIntlClientProvider;
|
|
15
|
-
/** @deprecated Is called `Link` now. */
|
|
16
|
-
|
|
17
|
-
var LocalizedLink = Link;
|
|
18
|
-
|
|
19
|
-
export { LocalizedLink, NextIntlProvider };
|
|
2
|
+
export { default as NextIntlClientProvider, default as NextIntlProvider } from './shared/next-intl.esm.js';
|
|
20
3
|
//# sourceMappingURL=next-intl.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next-intl.esm.js","sources":[
|
|
1
|
+
{"version":3,"file":"next-intl.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1,47 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This is the main entry file when the 'react-server' environment imports
|
|
3
|
-
* from 'next-intl'. Make sure this mirrors the API from the main entry.
|
|
4
|
-
*/
|
|
5
|
-
/// <reference types="react" />
|
|
6
|
-
/// <reference types="node" />
|
|
7
|
-
export { default as useLocale } from './useLocale';
|
|
8
|
-
export { default as useTranslations } from './useTranslations';
|
|
9
|
-
export { default as useIntl } from './useIntl';
|
|
10
|
-
export { default as useFormatter } from './useFormatter';
|
|
11
|
-
export { default as useNow } from './useNow';
|
|
12
|
-
export { default as useTimeZone } from './useTimeZone';
|
|
13
|
-
export { default as Link } from '../shared/Link';
|
|
14
|
-
export { default as NextIntlClientProvider } from '../shared/NextIntlClientProvider';
|
|
15
1
|
export * from 'use-intl/dist/src/core';
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
prefetch?: boolean | undefined;
|
|
25
|
-
locale?: string | false | undefined;
|
|
26
|
-
legacyBehavior?: boolean | undefined;
|
|
27
|
-
onMouseEnter?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
28
|
-
onTouchStart?: import("react").TouchEventHandler<HTMLAnchorElement> | undefined;
|
|
29
|
-
onClick?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
30
|
-
}> & {
|
|
31
|
-
href: string | import("url").UrlObject;
|
|
32
|
-
as?: (string | import("url").UrlObject) | undefined;
|
|
33
|
-
replace?: boolean | undefined;
|
|
34
|
-
scroll?: boolean | undefined;
|
|
35
|
-
shallow?: boolean | undefined;
|
|
36
|
-
passHref?: boolean | undefined;
|
|
37
|
-
prefetch?: boolean | undefined;
|
|
38
|
-
locale?: string | false | undefined;
|
|
39
|
-
legacyBehavior?: boolean | undefined;
|
|
40
|
-
onMouseEnter?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
41
|
-
onTouchStart?: import("react").TouchEventHandler<HTMLAnchorElement> | undefined;
|
|
42
|
-
onClick?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
43
|
-
} & {
|
|
44
|
-
children?: import("react").ReactNode;
|
|
45
|
-
} & import("react").RefAttributes<HTMLAnchorElement>, "locale"> & {
|
|
46
|
-
locale?: string | undefined;
|
|
47
|
-
}, "href" | "as" | "replace" | "scroll" | "shallow" | "passHref" | "prefetch" | "locale" | "legacyBehavior" | "onMouseEnter" | "onTouchStart" | "onClick" | "download" | "hrefLang" | "media" | "ping" | "rel" | "target" | "type" | "referrerPolicy" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "nonce" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "key"> & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
2
|
+
export { default as NextIntlClientProvider } from '../shared/NextIntlClientProvider';
|
|
3
|
+
declare function notSupported(): void;
|
|
4
|
+
export declare const IntlProvider: typeof notSupported;
|
|
5
|
+
export declare const useTranslations: typeof notSupported;
|
|
6
|
+
export declare const useIntl: typeof notSupported;
|
|
7
|
+
export declare const useLocale: typeof notSupported;
|
|
8
|
+
export declare const useNow: typeof notSupported;
|
|
9
|
+
export declare const useTimeZone: typeof notSupported;
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
/** @deprecated */
|
|
5
|
-
export declare function createIntlMiddleware(): void;
|
|
6
|
-
export { default as getRequestConfig } from './getRequestConfig';
|
|
7
|
-
export { default as getIntl } from './getIntl';
|
|
8
|
-
export { default as getFormatter } from './getFormatter';
|
|
9
|
-
export { default as getLocale } from './getLocale';
|
|
10
|
-
export { default as getNow } from './getNow';
|
|
11
|
-
export { default as getTimeZone } from './getTimeZone';
|
|
12
|
-
export { default as getTranslations } from './getTranslations';
|
|
13
|
-
export { default as redirect } from './redirect';
|
|
1
|
+
import MiddlewareConfig from '../middleware/NextIntlMiddlewareConfig';
|
|
2
|
+
/** @deprecated Should be imported as `import createMiddleware from 'next-intl/middleware', not from `next-intl/server`. */
|
|
3
|
+
export declare function createIntlMiddleware(config: MiddlewareConfig): (request: import("next/server").NextRequest) => import("next/server").NextResponse;
|