next-intl 2.14.0-beta.3 → 2.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/_virtual/next-intl.esm.js +1 -7
- package/dist/_virtual/next-intl.esm.js.map +1 -1
- package/dist/client/NextIntlClientProvider.d.ts +4 -0
- package/dist/client/index.d.ts +2 -10
- package/dist/client/localizeHref.d.ts +2 -2
- package/dist/client/next-intl.esm.js +13 -32
- package/dist/client/next-intl.esm.js.map +1 -1
- package/dist/client/next-intl.esm2.js +14 -20
- package/dist/client/next-intl.esm2.js.map +1 -1
- package/dist/client/useClientLocale.d.ts +1 -0
- package/dist/client/usePathname.d.ts +9 -6
- package/dist/client/useRouter.d.ts +16 -0
- package/dist/index.d.ts +6 -43
- package/dist/middleware/NextIntlMiddlewareConfig.d.ts +5 -23
- package/dist/middleware/index.d.ts +3 -0
- package/dist/next-intl.cjs.development.js +123 -181
- 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 +2 -14
- package/dist/next-intl.esm.js.map +1 -1
- package/dist/react-client/Link.d.ts +27 -0
- package/dist/react-client/index.d.ts +10 -0
- package/dist/react-client/next-intl.esm.js +33 -12
- package/dist/react-client/next-intl.esm.js.map +1 -1
- package/dist/react-client/next-intl.esm2.js +37 -0
- package/dist/react-client/next-intl.esm2.js.map +1 -0
- package/dist/react-client/next-intl.esm3.js +15 -0
- package/dist/react-client/next-intl.esm3.js.map +1 -0
- package/dist/react-server/Link.d.ts +7 -0
- package/dist/react-server/index.d.ts +14 -44
- package/dist/server/getFormatter.d.ts +1 -1
- package/dist/server/getIntl.d.ts +1 -1
- package/dist/server/getRequestConfig.d.ts +2 -2
- package/dist/server/index.d.ts +4 -11
- package/dist/shared/BaseLink.d.ts +7 -0
- package/dist/shared/NextIntlClientProvider.d.ts +1 -1
- package/dist/shared/constants.d.ts +1 -1
- package/dist/shared/isLocalUrl.d.ts +1 -1
- package/dist/shared/next-intl.esm.js +36 -71
- package/dist/shared/next-intl.esm.js.map +1 -1
- package/dist/shared/next-intl.esm2.js +44 -41
- package/dist/shared/next-intl.esm2.js.map +1 -1
- package/dist/shared/next-intl.esm3.js +49 -5
- package/dist/shared/next-intl.esm3.js.map +1 -1
- package/dist/shared/next-intl.esm4.js +4 -10
- package/dist/shared/next-intl.esm4.js.map +1 -1
- package/dist/shared/prefixHref.d.ts +4 -0
- package/dist/shared/unlocalizePathname.d.ts +1 -0
- package/dist/shared/utils.d.ts +15 -0
- 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 +2 -10
- package/dist/src/client/index.js +3 -10
- package/dist/src/client/index.js.map +1 -1
- package/dist/src/client/localizeHref.d.ts +2 -2
- package/dist/src/client/localizeHref.js +8 -23
- package/dist/src/client/localizeHref.js.map +1 -1
- package/dist/src/client/useClientLocale.d.ts +1 -0
- package/dist/src/client/useClientLocale.js +16 -0
- package/dist/src/client/useClientLocale.js.map +1 -0
- package/dist/src/client/usePathname.d.ts +9 -6
- package/dist/src/client/usePathname.js +19 -29
- package/dist/src/client/usePathname.js.map +1 -1
- package/dist/src/client/useRouter.d.ts +16 -0
- package/dist/src/client/useRouter.js +35 -12
- package/dist/src/client/useRouter.js.map +1 -1
- package/dist/src/index.d.ts +6 -43
- package/dist/src/index.js +6 -11
- package/dist/src/index.js.map +1 -1
- package/dist/src/middleware/NextIntlMiddlewareConfig.d.ts +5 -23
- package/dist/src/middleware/index.d.ts +3 -0
- package/dist/src/middleware/index.js +3 -0
- package/dist/src/middleware/index.js.map +1 -1
- package/dist/src/middleware/middleware.js +3 -50
- package/dist/src/react-client/Link.d.ts +27 -0
- package/dist/src/react-client/Link.js +28 -0
- package/dist/src/react-client/Link.js.map +1 -0
- package/dist/src/react-client/index.d.ts +10 -0
- package/dist/src/react-client/index.js +12 -0
- package/dist/src/react-client/index.js.map +1 -0
- package/dist/src/react-server/Link.d.ts +7 -0
- package/dist/src/react-server/Link.js +8 -0
- package/dist/src/react-server/Link.js.map +1 -0
- package/dist/src/react-server/index.d.ts +14 -44
- package/dist/src/react-server/index.js +21 -16
- package/dist/src/react-server/index.js.map +1 -1
- package/dist/src/server/getFormatter.d.ts +1 -1
- package/dist/src/server/getIntl.d.ts +1 -1
- package/dist/src/server/getRequestConfig.d.ts +2 -2
- package/dist/src/server/index.d.ts +4 -11
- package/dist/src/server/index.js +16 -14
- package/dist/src/server/index.js.map +1 -1
- package/dist/src/shared/BaseLink.d.ts +7 -0
- package/dist/src/shared/BaseLink.js +34 -0
- package/dist/src/shared/BaseLink.js.map +1 -0
- package/dist/src/shared/NextIntlClientProvider.d.ts +1 -1
- package/dist/src/shared/constants.d.ts +1 -1
- package/dist/src/shared/constants.js +2 -2
- package/dist/src/shared/constants.js.map +1 -1
- package/dist/src/shared/isLocalUrl.d.ts +1 -1
- package/dist/src/shared/prefixHref.d.ts +4 -0
- package/dist/src/shared/prefixHref.js +15 -0
- package/dist/src/shared/prefixHref.js.map +1 -0
- package/dist/src/shared/unlocalizePathname.d.ts +1 -0
- package/dist/src/shared/unlocalizePathname.js +4 -0
- package/dist/src/shared/unlocalizePathname.js.map +1 -0
- package/dist/src/shared/utils.d.ts +15 -0
- package/dist/src/shared/utils.js +53 -0
- package/dist/src/shared/utils.js.map +1 -0
- package/package.json +25 -33
- package/src/client/NextIntlClientProvider.tsx +18 -0
- package/src/client/index.tsx +3 -13
- package/src/client/useClientLocale.tsx +17 -0
- package/src/client/usePathname.tsx +20 -35
- package/src/client/useRouter.tsx +30 -9
- package/src/index.tsx +6 -16
- package/src/middleware/NextIntlMiddlewareConfig.tsx +0 -21
- package/src/middleware/index.tsx +4 -0
- package/src/middleware/middleware.tsx +3 -61
- package/src/react-client/Link.tsx +32 -0
- package/src/react-client/index.tsx +13 -0
- package/src/react-server/index.tsx +23 -19
- package/src/server/index.tsx +20 -18
- package/src/shared/BaseLink.tsx +52 -0
- package/src/shared/constants.tsx +2 -2
- package/src/shared/utils.tsx +91 -0
- package/CHANGELOG.md +0 -573
- package/config.js +0 -3
- package/dist/client/getCookieLocale.d.ts +0 -1
- package/dist/client/next-intl.esm3.js +0 -7
- package/dist/client/next-intl.esm3.js.map +0 -1
- package/dist/client/next-intl.esm4.js +0 -23
- package/dist/client/next-intl.esm4.js.map +0 -1
- package/dist/shared/Link.d.ts +0 -7
- package/dist/shared/next-intl.esm5.js +0 -6
- package/dist/shared/next-intl.esm5.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/shared/Link.d.ts +0 -7
- package/dist/src/shared/Link.js +0 -51
- package/dist/src/shared/Link.js.map +0 -1
- package/plugin.d.ts +0 -3
- package/plugin.js +0 -65
- package/src/.DS_Store +0 -0
- package/src/client/getCookieLocale.tsx +0 -19
- package/src/client/hasPathnamePrefixed.tsx +0 -7
- package/src/client/localizeHref.tsx +0 -46
- 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/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 -18
- 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 -67
- package/src/shared/isLocalUrl.tsx +0 -13
- 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.
|
|
@@ -1,33 +1,27 @@
|
|
|
1
1
|
function _extends() {
|
|
2
|
-
_extends = Object.assign
|
|
2
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
3
3
|
for (var i = 1; i < arguments.length; i++) {
|
|
4
4
|
var source = arguments[i];
|
|
5
|
-
|
|
6
5
|
for (var key in source) {
|
|
7
6
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
8
7
|
target[key] = source[key];
|
|
9
8
|
}
|
|
10
9
|
}
|
|
11
10
|
}
|
|
12
|
-
|
|
13
11
|
return target;
|
|
14
12
|
};
|
|
15
|
-
|
|
16
13
|
return _extends.apply(this, arguments);
|
|
17
14
|
}
|
|
18
|
-
|
|
19
15
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
20
16
|
if (source == null) return {};
|
|
21
17
|
var target = {};
|
|
22
18
|
var sourceKeys = Object.keys(source);
|
|
23
19
|
var key, i;
|
|
24
|
-
|
|
25
20
|
for (i = 0; i < sourceKeys.length; i++) {
|
|
26
21
|
key = sourceKeys[i];
|
|
27
22
|
if (excluded.indexOf(key) >= 0) continue;
|
|
28
23
|
target[key] = source[key];
|
|
29
24
|
}
|
|
30
|
-
|
|
31
25
|
return target;
|
|
32
26
|
}
|
|
33
27
|
|
|
@@ -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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -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,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Client-only APIs
|
|
2
|
+
* Client-only APIs available via `next-intl/client`.
|
|
3
3
|
*/
|
|
4
|
-
import NextIntlClientProvider_ from '../shared/NextIntlClientProvider';
|
|
5
|
-
import usePathname from './usePathname';
|
|
6
|
-
import useRouter from './useRouter';
|
|
7
4
|
export { default as useRouter } from './useRouter';
|
|
8
5
|
export { default as usePathname } from './usePathname';
|
|
9
|
-
|
|
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_;
|
|
6
|
+
export { default as NextIntlClientProvider } from './NextIntlClientProvider';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { UrlObject } from 'url';
|
|
3
|
-
export default function localizeHref(href: string, locale?: string, pathname?: string): string;
|
|
4
|
-
export default function localizeHref(href: UrlObject | string, locale?: string, pathname?: string): UrlObject | string;
|
|
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,37 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
if (
|
|
9
|
-
|
|
10
|
-
if (!pathname) {
|
|
11
|
-
pathname = window.location.pathname;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
var isSwitchingLocale = locale !== cookieLocale;
|
|
15
|
-
var isPathnamePrefixed = hasPathnamePrefixed(locale, pathname);
|
|
16
|
-
|
|
17
|
-
if (isPathnamePrefixed || isSwitchingLocale) {
|
|
18
|
-
var prefixedHref;
|
|
19
|
-
|
|
20
|
-
if (typeof href === 'string') {
|
|
21
|
-
prefixedHref = localizePathname(locale, href);
|
|
22
|
-
} else {
|
|
23
|
-
prefixedHref = _extends({}, href);
|
|
24
|
-
|
|
25
|
-
if (href.pathname) {
|
|
26
|
-
prefixedHref.pathname = localizePathname(locale, href.pathname);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return prefixedHref;
|
|
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];
|
|
31
10
|
} else {
|
|
32
|
-
|
|
11
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks -- Reading from context conditionally is fine
|
|
12
|
+
locale = useLocale();
|
|
33
13
|
}
|
|
14
|
+
return locale;
|
|
34
15
|
}
|
|
35
16
|
|
|
36
|
-
export {
|
|
17
|
+
export { useClientLocale as default };
|
|
37
18
|
//# sourceMappingURL=next-intl.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next-intl.esm.js","sources":["../../src/client/
|
|
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,24 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import localizeHref from './next-intl.esm.js';
|
|
1
|
+
import { useParams } from 'next/navigation';
|
|
2
|
+
import { useLocale } from 'use-intl';
|
|
3
|
+
import { LOCALE_SEGMENT_NAME } from '../shared/next-intl.esm4.js';
|
|
5
4
|
|
|
6
|
-
function
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
prefetch: function prefetch(href) {
|
|
17
|
-
return router.prefetch(localizeHref(href));
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
}, [router]);
|
|
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;
|
|
21
15
|
}
|
|
22
16
|
|
|
23
|
-
export {
|
|
17
|
+
export { useClientLocale as default };
|
|
24
18
|
//# sourceMappingURL=next-intl.esm2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next-intl.esm2.js","sources":["../../src/client/
|
|
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;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function useClientLocale(): string;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
export declare function unlocalizePathname(pathname: string): string;
|
|
2
1
|
/**
|
|
3
2
|
* Returns the pathname without a potential locale prefix.
|
|
4
3
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```tsx
|
|
6
|
+
* 'use client';
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* import {usePathname} from 'next-intl/client';
|
|
9
|
+
*
|
|
10
|
+
* // When the user is on `/en`, this will be `/`
|
|
11
|
+
* const pathname = usePathname();
|
|
12
|
+
* ```
|
|
10
13
|
*/
|
|
11
|
-
export default function usePathname(): string
|
|
14
|
+
export default function usePathname(): string;
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a wrapped instance of `useRouter` from `next/navigation` that
|
|
3
|
+
* will automatically localize the `href` parameters it receives.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```tsx
|
|
7
|
+
* 'use client';
|
|
8
|
+
*
|
|
9
|
+
* import {useRouter} from 'next-intl/client';
|
|
10
|
+
*
|
|
11
|
+
* const router = useRouter();
|
|
12
|
+
*
|
|
13
|
+
* // When the user is on `/en`, the router will navigate to `/en/about`
|
|
14
|
+
* router.push('/about');
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
1
17
|
export default function useRouter(): {
|
|
2
18
|
push(href: string): void;
|
|
3
19
|
replace(href: string): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,45 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This is the
|
|
3
|
-
*
|
|
2
|
+
* This is the default entry file when consumers import from
|
|
3
|
+
* 'next-intl'. We use the client APIs in this case.
|
|
4
|
+
*
|
|
5
|
+
* Note that the `react-server` environment (i.e. RSC) imports
|
|
6
|
+
* from `./react-server` instead.
|
|
4
7
|
*/
|
|
5
|
-
|
|
6
|
-
/// <reference types="node" />
|
|
7
|
-
export * from 'use-intl';
|
|
8
|
-
export { default as useLocalizedRouter } from './react-client/useLocalizedRouter';
|
|
9
|
-
export { default as Link } from './shared/Link';
|
|
10
|
-
/** @deprecated Is called `Link` now. */
|
|
11
|
-
export declare const LocalizedLink: import("react").ForwardRefExoticComponent<Pick<Omit<Omit<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, keyof {
|
|
12
|
-
href: string | import("url").UrlObject;
|
|
13
|
-
/** @deprecated Is called `Link` now. */
|
|
14
|
-
as?: (string | import("url").UrlObject) | undefined;
|
|
15
|
-
replace?: boolean | undefined;
|
|
16
|
-
scroll?: boolean | undefined;
|
|
17
|
-
shallow?: boolean | undefined;
|
|
18
|
-
passHref?: boolean | undefined;
|
|
19
|
-
prefetch?: boolean | undefined;
|
|
20
|
-
locale?: string | false | undefined;
|
|
21
|
-
legacyBehavior?: boolean | undefined;
|
|
22
|
-
onMouseEnter?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
23
|
-
onTouchStart?: import("react").TouchEventHandler<HTMLAnchorElement> | undefined;
|
|
24
|
-
onClick?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
25
|
-
}> & {
|
|
26
|
-
href: string | import("url").UrlObject;
|
|
27
|
-
/** @deprecated Is called `Link` now. */
|
|
28
|
-
as?: (string | import("url").UrlObject) | undefined;
|
|
29
|
-
replace?: boolean | undefined;
|
|
30
|
-
scroll?: boolean | undefined;
|
|
31
|
-
shallow?: boolean | undefined;
|
|
32
|
-
passHref?: boolean | undefined;
|
|
33
|
-
prefetch?: boolean | undefined;
|
|
34
|
-
locale?: string | false | undefined;
|
|
35
|
-
legacyBehavior?: boolean | undefined;
|
|
36
|
-
onMouseEnter?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
37
|
-
onTouchStart?: import("react").TouchEventHandler<HTMLAnchorElement> | undefined;
|
|
38
|
-
onClick?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
39
|
-
} & {
|
|
40
|
-
children?: import("react").ReactNode;
|
|
41
|
-
} & import("react").RefAttributes<HTMLAnchorElement>, "locale"> & {
|
|
42
|
-
locale?: string | undefined;
|
|
43
|
-
}, "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" | "tw" | "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>>;
|
|
44
|
-
export { default as NextIntlClientProvider } from './shared/NextIntlClientProvider';
|
|
45
|
-
export { default as NextIntlProvider } from './shared/NextIntlClientProvider';
|
|
8
|
+
export * from './react-client';
|
|
@@ -1,19 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
declare type LocalePrefix = 'as-needed' | 'always';
|
|
16
|
-
declare type RoutingBaseConfig = {
|
|
1
|
+
type LocalePrefix = 'as-needed' | 'always';
|
|
2
|
+
type RoutingBaseConfig = {
|
|
17
3
|
/** A list of all locales that are supported. */
|
|
18
4
|
locales: Array<string>;
|
|
19
5
|
defaultLocale: string;
|
|
@@ -21,24 +7,20 @@ declare type RoutingBaseConfig = {
|
|
|
21
7
|
*/
|
|
22
8
|
localePrefix?: LocalePrefix;
|
|
23
9
|
};
|
|
24
|
-
export
|
|
10
|
+
export type DomainConfig = Omit<RoutingBaseConfig, 'locales' | 'localePrefix'> & {
|
|
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
|
+
type MiddlewareConfig = RoutingBaseConfig & {
|
|
32
16
|
/** Can be used to change the locale handling per domain. */
|
|
33
17
|
domains?: Array<DomainConfig>;
|
|
34
18
|
/** By setting this to `false`, the `accept-language` header will no longer be used for locale detection. */
|
|
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
|
-
export
|
|
23
|
+
export type MiddlewareConfigWithDefaults = MiddlewareConfig & {
|
|
42
24
|
alternateLinks: boolean;
|
|
43
25
|
localePrefix: LocalePrefix;
|
|
44
26
|
localeDetection: boolean;
|