next-intl 3.0.0-beta.4 → 3.0.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/next-intl.esm.js +2 -2
- package/dist/react-client/next-intl.esm.js +2 -2
- package/dist/react-client/next-intl.esm2.js +5 -8
- package/dist/react-client/next-intl.esm2.js.map +1 -1
- package/dist/react-client/next-intl.esm3.js +8 -5
- package/dist/react-client/next-intl.esm3.js.map +1 -1
- package/dist/server/getFormatter.d.ts +2 -2
- package/dist/server/getNow.d.ts +2 -2
- package/dist/server/getTimeZone.d.ts +2 -2
- package/dist/server/getTranslator.d.ts +2 -2
- package/dist/src/react-server/useFormatter.js +1 -1
- package/dist/src/react-server/useFormatter.js.map +1 -1
- package/dist/src/react-server/useNow.js +1 -1
- package/dist/src/react-server/useNow.js.map +1 -1
- package/dist/src/react-server/useTimeZone.js +1 -1
- package/dist/src/react-server/useTimeZone.js.map +1 -1
- package/dist/src/react-server/useTranslations.js +1 -1
- package/dist/src/react-server/useTranslations.js.map +1 -1
- package/dist/src/server/getFormatter.d.ts +2 -2
- package/dist/src/server/getFormatter.js +27 -7
- package/dist/src/server/getFormatter.js.map +1 -1
- package/dist/src/server/getNow.d.ts +2 -2
- package/dist/src/server/getNow.js +27 -7
- package/dist/src/server/getNow.js.map +1 -1
- package/dist/src/server/getTimeZone.d.ts +2 -2
- package/dist/src/server/getTimeZone.js +27 -7
- package/dist/src/server/getTimeZone.js.map +1 -1
- package/dist/src/server/getTranslator.d.ts +2 -2
- package/dist/src/server/getTranslator.js +24 -4
- package/dist/src/server/getTranslator.js.map +1 -1
- package/package.json +1 -1
- package/src/react-server/useFormatter.tsx +1 -1
- package/src/react-server/useNow.tsx +1 -1
- package/src/react-server/useTimeZone.tsx +1 -1
- package/src/react-server/useTranslations.tsx +1 -1
- package/src/server/getFormatter.tsx +30 -7
- package/src/server/getNow.tsx +30 -7
- package/src/server/getTimeZone.tsx +30 -7
- package/src/server/getTranslator.tsx +36 -7
package/README.md
CHANGED
package/dist/next-intl.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { LocalizedLink } from './react-client/next-intl.esm.js';
|
|
2
2
|
export { default as NextIntlClientProvider, default as NextIntlProvider } from './shared/next-intl.esm.js';
|
|
3
|
-
export { default as Link } from './react-client/next-intl.
|
|
4
|
-
export { default as useLocalizedRouter } from './react-client/next-intl.
|
|
3
|
+
export { default as Link } from './react-client/next-intl.esm3.js';
|
|
4
|
+
export { default as useLocalizedRouter } from './react-client/next-intl.esm2.js';
|
|
5
5
|
export * from 'use-intl';
|
|
6
6
|
//# sourceMappingURL=next-intl.esm.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import LinkDeprecated from './next-intl.
|
|
2
|
-
export { default as Link } from './next-intl.
|
|
1
|
+
import LinkDeprecated from './next-intl.esm3.js';
|
|
2
|
+
export { default as Link } from './next-intl.esm3.js';
|
|
3
3
|
export * from 'use-intl';
|
|
4
4
|
import 'next/router';
|
|
5
5
|
import 'react';
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import Link from '../link/next-intl.esm.js';
|
|
1
|
+
import useRouter from '../client/next-intl.esm.js';
|
|
4
2
|
|
|
5
3
|
// TODO: Only available for backwards compatibility
|
|
6
4
|
// during the beta, remove for stable release
|
|
7
5
|
var hasWarned = false;
|
|
8
|
-
|
|
9
|
-
function LinkDeprecated(props) {
|
|
6
|
+
function useLocalizedRouterDeprecated() {
|
|
10
7
|
if (!hasWarned) {
|
|
11
|
-
console.warn("\n\nDEPRECATION WARNING: The
|
|
8
|
+
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");
|
|
12
9
|
hasWarned = true;
|
|
13
10
|
}
|
|
14
|
-
return
|
|
11
|
+
return useRouter();
|
|
15
12
|
}
|
|
16
13
|
|
|
17
|
-
export {
|
|
14
|
+
export { useLocalizedRouterDeprecated as default };
|
|
18
15
|
//# sourceMappingURL=next-intl.esm2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next-intl.esm2.js","sources":["../../src/react-client/
|
|
1
|
+
{"version":3,"file":"next-intl.esm2.js","sources":["../../src/react-client/useLocalizedRouter.tsx"],"sourcesContent":["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"],"names":["hasWarned","useLocalizedRouterDeprecated","console","warn","useRouter"],"mappings":";;AAEA;AACA;AAEA,IAAIA,SAAS,GAAG,KAAK,CAAA;AAEP,SAAUC,4BAA4BA,GAAA;EAClD,IAAI,CAACD,SAAS,EAAE;IACdE,OAAO,CAACC,IAAI,CAAA,8RAC4R,CACvS,CAAA;AACDH,IAAAA,SAAS,GAAG,IAAI,CAAA;AACjB,GAAA;EAED,OAAOI,SAAS,EAAE,CAAA;AACpB;;;;"}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { extends as _extends } from '../_virtual/next-intl.esm.js';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import Link from '../link/next-intl.esm.js';
|
|
2
4
|
|
|
3
5
|
// TODO: Only available for backwards compatibility
|
|
4
6
|
// during the beta, remove for stable release
|
|
5
7
|
var hasWarned = false;
|
|
6
|
-
|
|
8
|
+
/** @deprecated Is available as `import Link from 'next-intl/link'` now. */
|
|
9
|
+
function LinkDeprecated(props) {
|
|
7
10
|
if (!hasWarned) {
|
|
8
|
-
console.warn("\n\nDEPRECATION WARNING: The `
|
|
11
|
+
console.warn("\n\nDEPRECATION WARNING: The import for `Link` from next-intl has changed.\n\nPreviously: import {Link} from 'next-intl';\nNow: import Link from 'next-intl/link';\n\nPlease upgrade your import accordingly. See also https://next-intl-docs.vercel.app/docs/next-13/navigation#link\n\n");
|
|
9
12
|
hasWarned = true;
|
|
10
13
|
}
|
|
11
|
-
return
|
|
14
|
+
return React.createElement(Link, _extends({}, props));
|
|
12
15
|
}
|
|
13
16
|
|
|
14
|
-
export {
|
|
17
|
+
export { LinkDeprecated as default };
|
|
15
18
|
//# sourceMappingURL=next-intl.esm3.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next-intl.esm3.js","sources":["../../src/react-client/
|
|
1
|
+
{"version":3,"file":"next-intl.esm3.js","sources":["../../src/react-client/Link.tsx"],"sourcesContent":["import React, {ComponentProps} from 'react';\nimport Link from '../link';\n\n// TODO: Only available for backwards compatibility\n// during the beta, remove for stable release\n\nlet hasWarned = false;\n\n/** @deprecated Is available as `import Link from 'next-intl/link'` now. */\nexport default function LinkDeprecated(props: ComponentProps<typeof Link>) {\n if (!hasWarned) {\n console.warn(\n `\\n\\nDEPRECATION WARNING: The import for \\`Link\\` from next-intl has changed.\n\nPreviously: import {Link} from 'next-intl';\nNow: import Link from 'next-intl/link';\n\nPlease upgrade your import accordingly. See also https://next-intl-docs.vercel.app/docs/next-13/navigation#link\\n\\n`\n );\n hasWarned = true;\n }\n\n return <Link {...props} />;\n}\n"],"names":["hasWarned","LinkDeprecated","props","console","warn","React","createElement","Link","_extends"],"mappings":";;;;AAGA;AACA;AAEA,IAAIA,SAAS,GAAG,KAAK,CAAA;AAErB;AACwB,SAAAC,cAAcA,CAACC,KAAkC,EAAA;EACvE,IAAI,CAACF,SAAS,EAAE;IACdG,OAAO,CAACC,IAAI,CAAA,kSAMoG,CAC/G,CAAA;AACDJ,IAAAA,SAAS,GAAG,IAAI,CAAA;AACjB,GAAA;EAED,OAAOK,KAAC,CAAAC,aAAA,CAAAC,IAAI,EAAAC,QAAA,CAAA,EAAA,EAAKN,KAAK,EAAI,CAAA;AAC5B;;;;"}
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* The formatter automatically receives the request config, but
|
|
5
5
|
* you can override it by passing in additional options.
|
|
6
6
|
*/
|
|
7
|
-
declare const getFormatter: (
|
|
7
|
+
declare const getFormatter: (locale?: string | {
|
|
8
8
|
locale: string;
|
|
9
|
-
}) => Promise<{
|
|
9
|
+
} | undefined) => Promise<{
|
|
10
10
|
dateTime: (value: number | Date, formatOrOptions?: string | import("use-intl/dist/src/core/DateTimeFormatOptions").default | undefined) => string;
|
|
11
11
|
number: (value: number | bigint, formatOrOptions?: string | import("use-intl/dist/src/core").NumberFormatOptions | undefined) => string;
|
|
12
12
|
relativeTime: (date: number | Date, now?: number | Date | undefined) => string;
|
package/dist/server/getNow.d.ts
CHANGED
|
@@ -5,10 +5,10 @@ import MessageKeys from 'use-intl/dist/src/core/utils/MessageKeys';
|
|
|
5
5
|
import NamespaceKeys from 'use-intl/dist/src/core/utils/NamespaceKeys';
|
|
6
6
|
import NestedKeyOf from 'use-intl/dist/src/core/utils/NestedKeyOf';
|
|
7
7
|
import NestedValueOf from 'use-intl/dist/src/core/utils/NestedValueOf';
|
|
8
|
-
declare function getTranslatorImpl<NestedKey extends NamespaceKeys<IntlMessages, NestedKeyOf<IntlMessages>> = never>(
|
|
8
|
+
declare function getTranslatorImpl<NestedKey extends NamespaceKeys<IntlMessages, NestedKeyOf<IntlMessages>> = never>(locale: string | {
|
|
9
9
|
namespace?: NestedKey;
|
|
10
10
|
locale: string;
|
|
11
|
-
}): Promise<{
|
|
11
|
+
}, namespace?: NestedKey): Promise<{
|
|
12
12
|
<TargetKey extends MessageKeys<NestedValueOf<{
|
|
13
13
|
'!': IntlMessages;
|
|
14
14
|
}, [
|
|
@@ -5,6 +5,6 @@ export default function useFormatter(
|
|
|
5
5
|
// eslint-disable-next-line no-empty-pattern
|
|
6
6
|
...[]) {
|
|
7
7
|
const locale = useLocale();
|
|
8
|
-
return useHook('useFormatter', getFormatter(
|
|
8
|
+
return useHook('useFormatter', getFormatter(locale));
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=useFormatter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormatter.js","sourceRoot":"","sources":["../../../src/react-server/useFormatter.tsx"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,wBAAwB,CAAC;AAClD,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,MAAM,CAAC,OAAO,UAAU,YAAY;AAClC,4CAA4C;AAC5C,GAAG,EAAuC;IAE1C,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,OAAO,OAAO,CAAC,cAAc,EAAE,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"useFormatter.js","sourceRoot":"","sources":["../../../src/react-server/useFormatter.tsx"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,wBAAwB,CAAC;AAClD,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,MAAM,CAAC,OAAO,UAAU,YAAY;AAClC,4CAA4C;AAC5C,GAAG,EAAuC;IAE1C,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,OAAO,OAAO,CAAC,cAAc,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;AACvD,CAAC"}
|
|
@@ -6,6 +6,6 @@ export default function useNow(...[options]) {
|
|
|
6
6
|
console.error("`useNow` doesn't support the `updateInterval` option in Server Components, the value will be ignored. If you need the value to update, you can convert the component to a Client Component.");
|
|
7
7
|
}
|
|
8
8
|
const locale = useLocale();
|
|
9
|
-
return useHook('useNow', getNow(
|
|
9
|
+
return useHook('useNow', getNow(locale));
|
|
10
10
|
}
|
|
11
11
|
//# sourceMappingURL=useNow.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNow.js","sourceRoot":"","sources":["../../../src/react-server/useNow.tsx"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,MAAM,CAAC,OAAO,UAAU,MAAM,CAC5B,GAAG,CAAC,OAAO,CAAgC;IAE3C,IAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,cAAc,KAAI,IAAI,EAAE;QACnC,OAAO,CAAC,KAAK,CACX,6LAA6L,CAC9L,CAAC;KACH;IAED,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,OAAO,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"useNow.js","sourceRoot":"","sources":["../../../src/react-server/useNow.tsx"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,MAAM,CAAC,OAAO,UAAU,MAAM,CAC5B,GAAG,CAAC,OAAO,CAAgC;IAE3C,IAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,cAAc,KAAI,IAAI,EAAE;QACnC,OAAO,CAAC,KAAK,CACX,6LAA6L,CAC9L,CAAC;KACH;IAED,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,OAAO,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -5,6 +5,6 @@ export default function useTimeZone(
|
|
|
5
5
|
// eslint-disable-next-line no-empty-pattern
|
|
6
6
|
...[]) {
|
|
7
7
|
const locale = useLocale();
|
|
8
|
-
return useHook('useTimeZone', getTimeZone(
|
|
8
|
+
return useHook('useTimeZone', getTimeZone(locale));
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=useTimeZone.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTimeZone.js","sourceRoot":"","sources":["../../../src/react-server/useTimeZone.tsx"],"names":[],"mappings":"AACA,OAAO,WAAW,MAAM,uBAAuB,CAAC;AAChD,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,MAAM,CAAC,OAAO,UAAU,WAAW;AACjC,4CAA4C;AAC5C,GAAG,EAAsC;IAEzC,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,OAAO,OAAO,CAAC,aAAa,EAAE,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"useTimeZone.js","sourceRoot":"","sources":["../../../src/react-server/useTimeZone.tsx"],"names":[],"mappings":"AACA,OAAO,WAAW,MAAM,uBAAuB,CAAC;AAChD,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,MAAM,CAAC,OAAO,UAAU,WAAW;AACjC,4CAA4C;AAC5C,GAAG,EAAsC;IAEzC,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,OAAO,OAAO,CAAC,aAAa,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -3,7 +3,7 @@ import useHook from './useHook';
|
|
|
3
3
|
import useLocale from './useLocale';
|
|
4
4
|
export default function useTranslations(...[namespace]) {
|
|
5
5
|
const locale = useLocale();
|
|
6
|
-
const result = useHook('useTranslations', getTranslator(
|
|
6
|
+
const result = useHook('useTranslations', getTranslator(locale, namespace));
|
|
7
7
|
// The types are slightly off here and indicate that rich text formatting
|
|
8
8
|
// doesn't integrate with React - this is not the case.
|
|
9
9
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTranslations.js","sourceRoot":"","sources":["../../../src/react-server/useTranslations.tsx"],"names":[],"mappings":"AACA,OAAO,aAAa,MAAM,yBAAyB,CAAC;AACpD,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,GAAG,CAAC,SAAS,CAAyC;IAEtD,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,MAAM,GAAG,OAAO,CAAC,iBAAiB,EAAE,aAAa,CAAC,
|
|
1
|
+
{"version":3,"file":"useTranslations.js","sourceRoot":"","sources":["../../../src/react-server/useTranslations.tsx"],"names":[],"mappings":"AACA,OAAO,aAAa,MAAM,yBAAyB,CAAC;AACpD,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,GAAG,CAAC,SAAS,CAAyC;IAEtD,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,MAAM,GAAG,OAAO,CAAC,iBAAiB,EAAE,aAAa,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;IAE5E,yEAAyE;IACzE,uDAAuD;IACvD,OAAO,MAAa,CAAC;AACvB,CAAC"}
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* The formatter automatically receives the request config, but
|
|
5
5
|
* you can override it by passing in additional options.
|
|
6
6
|
*/
|
|
7
|
-
declare const getFormatter: (
|
|
7
|
+
declare const getFormatter: (locale?: string | {
|
|
8
8
|
locale: string;
|
|
9
|
-
}) => Promise<{
|
|
9
|
+
} | undefined) => Promise<{
|
|
10
10
|
dateTime: (value: number | Date, formatOrOptions?: string | import("use-intl/dist/src/core/DateTimeFormatOptions").default | undefined) => string;
|
|
11
11
|
number: (value: number | bigint, formatOrOptions?: string | import("use-intl/dist/src/core").NumberFormatOptions | undefined) => string;
|
|
12
12
|
relativeTime: (date: number | Date, now?: number | Date | undefined) => string;
|
|
@@ -2,17 +2,37 @@ import { cache } from 'react';
|
|
|
2
2
|
import { createFormatter } from 'use-intl/dist/src/core';
|
|
3
3
|
import getConfig from './getConfig';
|
|
4
4
|
import getLocaleFromHeader from './getLocaleFromHeader';
|
|
5
|
-
let
|
|
5
|
+
let hasWarnedForMissingLocale = false;
|
|
6
|
+
let hasWarnedForObjectArgument = false;
|
|
6
7
|
/**
|
|
7
8
|
* Returns a formatter based on the given locale.
|
|
8
9
|
*
|
|
9
10
|
* The formatter automatically receives the request config, but
|
|
10
11
|
* you can override it by passing in additional options.
|
|
11
12
|
*/
|
|
12
|
-
const getFormatter = cache(async (
|
|
13
|
-
if (
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
const getFormatter = cache(async (locale) => {
|
|
14
|
+
if (typeof locale === 'object') {
|
|
15
|
+
locale = locale.locale;
|
|
16
|
+
if (!hasWarnedForObjectArgument) {
|
|
17
|
+
hasWarnedForObjectArgument = true;
|
|
18
|
+
console.warn(`
|
|
19
|
+
DEPRECATION WARNING: Calling \`getFormatter\` with an object argument is deprecated, please update your call site accordingly.
|
|
20
|
+
|
|
21
|
+
// Previously
|
|
22
|
+
getFormatter({locale: 'en'});
|
|
23
|
+
|
|
24
|
+
// Now
|
|
25
|
+
getFormatter('en');
|
|
26
|
+
|
|
27
|
+
See also https://next-intl-docs.vercel.app/docs/next-13/server-components#using-internationalization-outside-of-components
|
|
28
|
+
`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (!locale) {
|
|
32
|
+
locale = getLocaleFromHeader();
|
|
33
|
+
if (!hasWarnedForMissingLocale) {
|
|
34
|
+
hasWarnedForMissingLocale = true;
|
|
35
|
+
console.warn(`
|
|
16
36
|
Calling \`getFormatter\` without a locale is deprecated, please update the call:
|
|
17
37
|
|
|
18
38
|
// app/[locale]/layout.tsx
|
|
@@ -24,10 +44,10 @@ export async function generateMetadata({params}) {
|
|
|
24
44
|
|
|
25
45
|
Learn more: https://next-intl-docs.vercel.app/docs/next-13/server-components#using-internationalization-outside-of-components
|
|
26
46
|
`);
|
|
47
|
+
}
|
|
27
48
|
}
|
|
28
|
-
const locale = (opts === null || opts === void 0 ? void 0 : opts.locale) || getLocaleFromHeader();
|
|
29
49
|
const config = await getConfig(locale);
|
|
30
|
-
return createFormatter(
|
|
50
|
+
return createFormatter(config);
|
|
31
51
|
});
|
|
32
52
|
export default getFormatter;
|
|
33
53
|
//# sourceMappingURL=getFormatter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFormatter.js","sourceRoot":"","sources":["../../../src/server/getFormatter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AACvD,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AAExD,IAAI,
|
|
1
|
+
{"version":3,"file":"getFormatter.js","sourceRoot":"","sources":["../../../src/server/getFormatter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AACvD,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AAExD,IAAI,yBAAyB,GAAG,KAAK,CAAC;AACtC,IAAI,0BAA0B,GAAG,KAAK,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,YAAY,GAAG,KAAK,CAAC,KAAK,EAAE,MAAkC,EAAE,EAAE;IACtE,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAC9B,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QACvB,IAAI,CAAC,0BAA0B,EAAE;YAC/B,0BAA0B,GAAG,IAAI,CAAC;YAClC,OAAO,CAAC,IAAI,CACV;;;;;;;;;;CAUP,CACM,CAAC;SACH;KACF;IAED,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,GAAG,mBAAmB,EAAE,CAAC;QAC/B,IAAI,CAAC,yBAAyB,EAAE;YAC9B,yBAAyB,GAAG,IAAI,CAAC;YACjC,OAAO,CAAC,IAAI,CAAC;;;;;;;;;;;CAWlB,CAAC,CAAC;SACE;KACF;IAED,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,MAAM,CAAC,CAAC;IACvC,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC;AACjC,CAAC,CAAC,CAAC;AAEH,eAAe,YAAY,CAAC"}
|
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
import { cache } from 'react';
|
|
2
2
|
import getConfig from './getConfig';
|
|
3
3
|
import getLocaleFromHeader from './getLocaleFromHeader';
|
|
4
|
-
let
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
let hasWarnedForMissingLocale = false;
|
|
5
|
+
let hasWarnedForObjectArgument = false;
|
|
6
|
+
const getNow = cache(async (locale) => {
|
|
7
|
+
if (typeof locale === 'object') {
|
|
8
|
+
locale = locale.locale;
|
|
9
|
+
if (!hasWarnedForObjectArgument) {
|
|
10
|
+
hasWarnedForObjectArgument = true;
|
|
11
|
+
console.warn(`
|
|
12
|
+
DEPRECATION WARNING: Calling \`getNow\` with an object argument is deprecated, please update your call site accordingly.
|
|
13
|
+
|
|
14
|
+
// Previously
|
|
15
|
+
getNow({locale: 'en'});
|
|
16
|
+
|
|
17
|
+
// Now
|
|
18
|
+
getNow('en');
|
|
19
|
+
|
|
20
|
+
See also https://next-intl-docs.vercel.app/docs/next-13/server-components#using-internationalization-outside-of-components
|
|
21
|
+
`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (!locale) {
|
|
25
|
+
locale = getLocaleFromHeader();
|
|
26
|
+
if (!hasWarnedForMissingLocale) {
|
|
27
|
+
hasWarnedForMissingLocale = true;
|
|
28
|
+
console.warn(`
|
|
29
|
+
Calling \`getNow\` without a locale is deprecated, please update the call:
|
|
10
30
|
|
|
11
31
|
// app/[locale]/layout.tsx
|
|
12
32
|
export async function generateMetadata({params}) {
|
|
@@ -17,8 +37,8 @@ export async function generateMetadata({params}) {
|
|
|
17
37
|
|
|
18
38
|
Learn more: https://next-intl-docs.vercel.app/docs/next-13/server-components#using-internationalization-outside-of-components
|
|
19
39
|
`);
|
|
40
|
+
}
|
|
20
41
|
}
|
|
21
|
-
const locale = (opts === null || opts === void 0 ? void 0 : opts.locale) || getLocaleFromHeader();
|
|
22
42
|
const config = await getConfig(locale);
|
|
23
43
|
return config.now;
|
|
24
44
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getNow.js","sourceRoot":"","sources":["../../../src/server/getNow.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,OAAO,CAAC;AAC5B,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AAExD,IAAI,
|
|
1
|
+
{"version":3,"file":"getNow.js","sourceRoot":"","sources":["../../../src/server/getNow.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,OAAO,CAAC;AAC5B,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AAExD,IAAI,yBAAyB,GAAG,KAAK,CAAC;AACtC,IAAI,0BAA0B,GAAG,KAAK,CAAC;AAEvC,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,EAAE,MAAkC,EAAE,EAAE;IAChE,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAC9B,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QACvB,IAAI,CAAC,0BAA0B,EAAE;YAC/B,0BAA0B,GAAG,IAAI,CAAC;YAClC,OAAO,CAAC,IAAI,CACV;;;;;;;;;;CAUP,CACM,CAAC;SACH;KACF;IAED,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,GAAG,mBAAmB,EAAE,CAAC;QAC/B,IAAI,CAAC,yBAAyB,EAAE;YAC9B,yBAAyB,GAAG,IAAI,CAAC;YACjC,OAAO,CAAC,IAAI,CAAC;;;;;;;;;;;CAWlB,CAAC,CAAC;SACE;KACF;IAED,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,MAAM,CAAC,CAAC;IACvC,OAAO,MAAM,CAAC,GAAG,CAAC;AACpB,CAAC,CAAC,CAAC;AAEH,eAAe,MAAM,CAAC"}
|
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
import { cache } from 'react';
|
|
2
2
|
import getConfig from './getConfig';
|
|
3
3
|
import getLocaleFromHeader from './getLocaleFromHeader';
|
|
4
|
-
let
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
let hasWarnedForMissingLocale = false;
|
|
5
|
+
let hasWarnedForObjectArgument = false;
|
|
6
|
+
const getTimeZone = cache(async (locale) => {
|
|
7
|
+
if (typeof locale === 'object') {
|
|
8
|
+
locale = locale.locale;
|
|
9
|
+
if (!hasWarnedForObjectArgument) {
|
|
10
|
+
hasWarnedForObjectArgument = true;
|
|
11
|
+
console.warn(`
|
|
12
|
+
DEPRECATION WARNING: Calling \`getTimeZone\` with an object argument is deprecated, please update your call site accordingly.
|
|
13
|
+
|
|
14
|
+
// Previously
|
|
15
|
+
getTimeZone({locale: 'en'});
|
|
16
|
+
|
|
17
|
+
// Now
|
|
18
|
+
getTimeZone('en');
|
|
19
|
+
|
|
20
|
+
See also https://next-intl-docs.vercel.app/docs/next-13/server-components#using-internationalization-outside-of-components
|
|
21
|
+
`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (!locale) {
|
|
25
|
+
locale = getLocaleFromHeader();
|
|
26
|
+
if (!hasWarnedForMissingLocale) {
|
|
27
|
+
hasWarnedForMissingLocale = true;
|
|
28
|
+
console.warn(`
|
|
29
|
+
Calling \`getTimeZone\` without a locale is deprecated, please update the call:
|
|
10
30
|
|
|
11
31
|
// app/[locale]/layout.tsx
|
|
12
32
|
export async function generateMetadata({params}) {
|
|
@@ -17,8 +37,8 @@ export async function generateMetadata({params}) {
|
|
|
17
37
|
|
|
18
38
|
Learn more: https://next-intl-docs.vercel.app/docs/next-13/server-components#using-internationalization-outside-of-components
|
|
19
39
|
`);
|
|
40
|
+
}
|
|
20
41
|
}
|
|
21
|
-
const locale = (opts === null || opts === void 0 ? void 0 : opts.locale) || getLocaleFromHeader();
|
|
22
42
|
const config = await getConfig(locale);
|
|
23
43
|
return config.timeZone;
|
|
24
44
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTimeZone.js","sourceRoot":"","sources":["../../../src/server/getTimeZone.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,OAAO,CAAC;AAC5B,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AAExD,IAAI,
|
|
1
|
+
{"version":3,"file":"getTimeZone.js","sourceRoot":"","sources":["../../../src/server/getTimeZone.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,OAAO,CAAC;AAC5B,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AAExD,IAAI,yBAAyB,GAAG,KAAK,CAAC;AACtC,IAAI,0BAA0B,GAAG,KAAK,CAAC;AAEvC,MAAM,WAAW,GAAG,KAAK,CAAC,KAAK,EAAE,MAAkC,EAAE,EAAE;IACrE,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAC9B,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QACvB,IAAI,CAAC,0BAA0B,EAAE;YAC/B,0BAA0B,GAAG,IAAI,CAAC;YAClC,OAAO,CAAC,IAAI,CACV;;;;;;;;;;CAUP,CACM,CAAC;SACH;KACF;IAED,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,GAAG,mBAAmB,EAAE,CAAC;QAC/B,IAAI,CAAC,yBAAyB,EAAE;YAC9B,yBAAyB,GAAG,IAAI,CAAC;YACjC,OAAO,CAAC,IAAI,CAAC;;;;;;;;;;;CAWlB,CAAC,CAAC;SACE;KACF;IAED,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,MAAM,CAAC,CAAC;IACvC,OAAO,MAAM,CAAC,QAAQ,CAAC;AACzB,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC"}
|
|
@@ -5,10 +5,10 @@ import MessageKeys from 'use-intl/dist/src/core/utils/MessageKeys';
|
|
|
5
5
|
import NamespaceKeys from 'use-intl/dist/src/core/utils/NamespaceKeys';
|
|
6
6
|
import NestedKeyOf from 'use-intl/dist/src/core/utils/NestedKeyOf';
|
|
7
7
|
import NestedValueOf from 'use-intl/dist/src/core/utils/NestedValueOf';
|
|
8
|
-
declare function getTranslatorImpl<NestedKey extends NamespaceKeys<IntlMessages, NestedKeyOf<IntlMessages>> = never>(
|
|
8
|
+
declare function getTranslatorImpl<NestedKey extends NamespaceKeys<IntlMessages, NestedKeyOf<IntlMessages>> = never>(locale: string | {
|
|
9
9
|
namespace?: NestedKey;
|
|
10
10
|
locale: string;
|
|
11
|
-
}): Promise<{
|
|
11
|
+
}, namespace?: NestedKey): Promise<{
|
|
12
12
|
<TargetKey extends MessageKeys<NestedValueOf<{
|
|
13
13
|
'!': IntlMessages;
|
|
14
14
|
}, [
|
|
@@ -2,11 +2,31 @@
|
|
|
2
2
|
import { cache } from 'react';
|
|
3
3
|
import createBaseTranslator, { getMessagesOrError } from 'use-intl/dist/src/core/createBaseTranslator';
|
|
4
4
|
import getConfig from './getConfig';
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
let hasWarned = false;
|
|
6
|
+
async function getTranslatorImpl(locale, namespace) {
|
|
7
|
+
if (typeof locale === 'object') {
|
|
8
|
+
const opts = locale;
|
|
9
|
+
namespace = opts.namespace;
|
|
10
|
+
locale = opts.locale;
|
|
11
|
+
if (!hasWarned) {
|
|
12
|
+
console.warn(`
|
|
13
|
+
DEPRECATION WARNING: Calling \`getTranslator\` with an object argument is deprecated, please update your call site accordingly.
|
|
14
|
+
|
|
15
|
+
// Previously
|
|
16
|
+
getTranslator({locale: 'en', namespace: 'About'});
|
|
17
|
+
|
|
18
|
+
// Now
|
|
19
|
+
getTranslator('en', 'About');
|
|
20
|
+
|
|
21
|
+
See also https://next-intl-docs.vercel.app/docs/next-13/server-components#using-internationalization-outside-of-components
|
|
22
|
+
`);
|
|
23
|
+
hasWarned = true;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const config = await getConfig(locale);
|
|
7
27
|
const messagesOrError = getMessagesOrError({
|
|
8
28
|
messages: config.messages,
|
|
9
|
-
namespace
|
|
29
|
+
namespace,
|
|
10
30
|
onError: config.onError
|
|
11
31
|
});
|
|
12
32
|
// We allow to resolve rich text formatting here, but the types forbid it when
|
|
@@ -15,7 +35,7 @@ async function getTranslatorImpl(opts) {
|
|
|
15
35
|
// @ts-ignore
|
|
16
36
|
return createBaseTranslator({
|
|
17
37
|
...config,
|
|
18
|
-
|
|
38
|
+
namespace,
|
|
19
39
|
messagesOrError
|
|
20
40
|
});
|
|
21
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTranslator.js","sourceRoot":"","sources":["../../../src/server/getTranslator.tsx"],"names":[],"mappings":"AAAA,mCAAmC;AAEnC,OAAO,EAAC,KAAK,EAAC,MAAM,OAAO,CAAC;AAG5B,OAAO,oBAAoB,EAAE,EAC3B,kBAAkB,EACnB,MAAM,6CAA6C,CAAC;AAMrD,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,KAAK,UAAU,iBAAiB,
|
|
1
|
+
{"version":3,"file":"getTranslator.js","sourceRoot":"","sources":["../../../src/server/getTranslator.tsx"],"names":[],"mappings":"AAAA,mCAAmC;AAEnC,OAAO,EAAC,KAAK,EAAC,MAAM,OAAO,CAAC;AAG5B,OAAO,oBAAoB,EAAE,EAC3B,kBAAkB,EACnB,MAAM,6CAA6C,CAAC;AAMrD,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,IAAI,SAAS,GAAG,KAAK,CAAC;AAEtB,KAAK,UAAU,iBAAiB,CAM9B,MAKK,EACL,SAAqB;IA6DrB,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAC9B,MAAM,IAAI,GAAG,MAAM,CAAC;QACpB,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAC3B,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,EAAE;YACd,OAAO,CAAC,IAAI,CACV;;;;;;;;;;CAUP,CACM,CAAC;YACF,SAAS,GAAG,IAAI,CAAC;SAClB;KACF;IAED,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,MAAM,CAAC,CAAC;IAEvC,MAAM,eAAe,GAAG,kBAAkB,CAAC;QACzC,QAAQ,EAAE,MAAM,CAAC,QAAe;QAChC,SAAS;QACT,OAAO,EAAE,MAAM,CAAC,OAAO;KACxB,CAAC,CAAC;IAEH,8EAA8E;IAC9E,6EAA6E;IAC7E,4DAA4D;IAC5D,aAAa;IACb,OAAO,oBAAoB,CAAC;QAC1B,GAAG,MAAM;QACT,SAAS;QACT,eAAe;KAChB,CAAC,CAAC;AACL,CAAC;AAED,eAAe,KAAK,CAAC,iBAAiB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -8,5 +8,5 @@ export default function useFormatter(
|
|
|
8
8
|
...[]: Parameters<typeof useFormatterType>
|
|
9
9
|
): ReturnType<typeof useFormatterType> {
|
|
10
10
|
const locale = useLocale();
|
|
11
|
-
return useHook('useFormatter', getFormatter(
|
|
11
|
+
return useHook('useFormatter', getFormatter(locale));
|
|
12
12
|
}
|
|
@@ -8,5 +8,5 @@ export default function useTimeZone(
|
|
|
8
8
|
...[]: Parameters<typeof useTimeZoneType>
|
|
9
9
|
): ReturnType<typeof useTimeZoneType> {
|
|
10
10
|
const locale = useLocale();
|
|
11
|
-
return useHook('useTimeZone', getTimeZone(
|
|
11
|
+
return useHook('useTimeZone', getTimeZone(locale));
|
|
12
12
|
}
|
|
@@ -7,7 +7,7 @@ export default function useTranslations(
|
|
|
7
7
|
...[namespace]: Parameters<typeof useTranslationsType>
|
|
8
8
|
): ReturnType<typeof useTranslationsType> {
|
|
9
9
|
const locale = useLocale();
|
|
10
|
-
const result = useHook('useTranslations', getTranslator(
|
|
10
|
+
const result = useHook('useTranslations', getTranslator(locale, namespace));
|
|
11
11
|
|
|
12
12
|
// The types are slightly off here and indicate that rich text formatting
|
|
13
13
|
// doesn't integrate with React - this is not the case.
|
|
@@ -3,7 +3,8 @@ import {createFormatter} from 'use-intl/dist/src/core';
|
|
|
3
3
|
import getConfig from './getConfig';
|
|
4
4
|
import getLocaleFromHeader from './getLocaleFromHeader';
|
|
5
5
|
|
|
6
|
-
let
|
|
6
|
+
let hasWarnedForMissingLocale = false;
|
|
7
|
+
let hasWarnedForObjectArgument = false;
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Returns a formatter based on the given locale.
|
|
@@ -11,10 +12,32 @@ let hasWarned = false;
|
|
|
11
12
|
* The formatter automatically receives the request config, but
|
|
12
13
|
* you can override it by passing in additional options.
|
|
13
14
|
*/
|
|
14
|
-
const getFormatter = cache(async (
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const getFormatter = cache(async (locale?: string | {locale: string}) => {
|
|
16
|
+
if (typeof locale === 'object') {
|
|
17
|
+
locale = locale.locale;
|
|
18
|
+
if (!hasWarnedForObjectArgument) {
|
|
19
|
+
hasWarnedForObjectArgument = true;
|
|
20
|
+
console.warn(
|
|
21
|
+
`
|
|
22
|
+
DEPRECATION WARNING: Calling \`getFormatter\` with an object argument is deprecated, please update your call site accordingly.
|
|
23
|
+
|
|
24
|
+
// Previously
|
|
25
|
+
getFormatter({locale: 'en'});
|
|
26
|
+
|
|
27
|
+
// Now
|
|
28
|
+
getFormatter('en');
|
|
29
|
+
|
|
30
|
+
See also https://next-intl-docs.vercel.app/docs/next-13/server-components#using-internationalization-outside-of-components
|
|
31
|
+
`
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (!locale) {
|
|
37
|
+
locale = getLocaleFromHeader();
|
|
38
|
+
if (!hasWarnedForMissingLocale) {
|
|
39
|
+
hasWarnedForMissingLocale = true;
|
|
40
|
+
console.warn(`
|
|
18
41
|
Calling \`getFormatter\` without a locale is deprecated, please update the call:
|
|
19
42
|
|
|
20
43
|
// app/[locale]/layout.tsx
|
|
@@ -26,11 +49,11 @@ export async function generateMetadata({params}) {
|
|
|
26
49
|
|
|
27
50
|
Learn more: https://next-intl-docs.vercel.app/docs/next-13/server-components#using-internationalization-outside-of-components
|
|
28
51
|
`);
|
|
52
|
+
}
|
|
29
53
|
}
|
|
30
54
|
|
|
31
|
-
const locale = opts?.locale || getLocaleFromHeader();
|
|
32
55
|
const config = await getConfig(locale);
|
|
33
|
-
return createFormatter(
|
|
56
|
+
return createFormatter(config);
|
|
34
57
|
});
|
|
35
58
|
|
|
36
59
|
export default getFormatter;
|
package/src/server/getNow.tsx
CHANGED
|
@@ -2,13 +2,36 @@ import {cache} from 'react';
|
|
|
2
2
|
import getConfig from './getConfig';
|
|
3
3
|
import getLocaleFromHeader from './getLocaleFromHeader';
|
|
4
4
|
|
|
5
|
-
let
|
|
5
|
+
let hasWarnedForMissingLocale = false;
|
|
6
|
+
let hasWarnedForObjectArgument = false;
|
|
6
7
|
|
|
7
|
-
const getNow = cache(async (
|
|
8
|
-
if (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const getNow = cache(async (locale?: string | {locale: string}) => {
|
|
9
|
+
if (typeof locale === 'object') {
|
|
10
|
+
locale = locale.locale;
|
|
11
|
+
if (!hasWarnedForObjectArgument) {
|
|
12
|
+
hasWarnedForObjectArgument = true;
|
|
13
|
+
console.warn(
|
|
14
|
+
`
|
|
15
|
+
DEPRECATION WARNING: Calling \`getNow\` with an object argument is deprecated, please update your call site accordingly.
|
|
16
|
+
|
|
17
|
+
// Previously
|
|
18
|
+
getNow({locale: 'en'});
|
|
19
|
+
|
|
20
|
+
// Now
|
|
21
|
+
getNow('en');
|
|
22
|
+
|
|
23
|
+
See also https://next-intl-docs.vercel.app/docs/next-13/server-components#using-internationalization-outside-of-components
|
|
24
|
+
`
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (!locale) {
|
|
30
|
+
locale = getLocaleFromHeader();
|
|
31
|
+
if (!hasWarnedForMissingLocale) {
|
|
32
|
+
hasWarnedForMissingLocale = true;
|
|
33
|
+
console.warn(`
|
|
34
|
+
Calling \`getNow\` without a locale is deprecated, please update the call:
|
|
12
35
|
|
|
13
36
|
// app/[locale]/layout.tsx
|
|
14
37
|
export async function generateMetadata({params}) {
|
|
@@ -19,9 +42,9 @@ export async function generateMetadata({params}) {
|
|
|
19
42
|
|
|
20
43
|
Learn more: https://next-intl-docs.vercel.app/docs/next-13/server-components#using-internationalization-outside-of-components
|
|
21
44
|
`);
|
|
45
|
+
}
|
|
22
46
|
}
|
|
23
47
|
|
|
24
|
-
const locale = opts?.locale || getLocaleFromHeader();
|
|
25
48
|
const config = await getConfig(locale);
|
|
26
49
|
return config.now;
|
|
27
50
|
});
|
|
@@ -2,13 +2,36 @@ import {cache} from 'react';
|
|
|
2
2
|
import getConfig from './getConfig';
|
|
3
3
|
import getLocaleFromHeader from './getLocaleFromHeader';
|
|
4
4
|
|
|
5
|
-
let
|
|
5
|
+
let hasWarnedForMissingLocale = false;
|
|
6
|
+
let hasWarnedForObjectArgument = false;
|
|
6
7
|
|
|
7
|
-
const getTimeZone = cache(async (
|
|
8
|
-
if (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const getTimeZone = cache(async (locale?: string | {locale: string}) => {
|
|
9
|
+
if (typeof locale === 'object') {
|
|
10
|
+
locale = locale.locale;
|
|
11
|
+
if (!hasWarnedForObjectArgument) {
|
|
12
|
+
hasWarnedForObjectArgument = true;
|
|
13
|
+
console.warn(
|
|
14
|
+
`
|
|
15
|
+
DEPRECATION WARNING: Calling \`getTimeZone\` with an object argument is deprecated, please update your call site accordingly.
|
|
16
|
+
|
|
17
|
+
// Previously
|
|
18
|
+
getTimeZone({locale: 'en'});
|
|
19
|
+
|
|
20
|
+
// Now
|
|
21
|
+
getTimeZone('en');
|
|
22
|
+
|
|
23
|
+
See also https://next-intl-docs.vercel.app/docs/next-13/server-components#using-internationalization-outside-of-components
|
|
24
|
+
`
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (!locale) {
|
|
30
|
+
locale = getLocaleFromHeader();
|
|
31
|
+
if (!hasWarnedForMissingLocale) {
|
|
32
|
+
hasWarnedForMissingLocale = true;
|
|
33
|
+
console.warn(`
|
|
34
|
+
Calling \`getTimeZone\` without a locale is deprecated, please update the call:
|
|
12
35
|
|
|
13
36
|
// app/[locale]/layout.tsx
|
|
14
37
|
export async function generateMetadata({params}) {
|
|
@@ -19,9 +42,9 @@ export async function generateMetadata({params}) {
|
|
|
19
42
|
|
|
20
43
|
Learn more: https://next-intl-docs.vercel.app/docs/next-13/server-components#using-internationalization-outside-of-components
|
|
21
44
|
`);
|
|
45
|
+
}
|
|
22
46
|
}
|
|
23
47
|
|
|
24
|
-
const locale = opts?.locale || getLocaleFromHeader();
|
|
25
48
|
const config = await getConfig(locale);
|
|
26
49
|
return config.timeZone;
|
|
27
50
|
});
|
|
@@ -13,15 +13,22 @@ import NestedKeyOf from 'use-intl/dist/src/core/utils/NestedKeyOf';
|
|
|
13
13
|
import NestedValueOf from 'use-intl/dist/src/core/utils/NestedValueOf';
|
|
14
14
|
import getConfig from './getConfig';
|
|
15
15
|
|
|
16
|
+
let hasWarned = false;
|
|
17
|
+
|
|
16
18
|
async function getTranslatorImpl<
|
|
17
19
|
NestedKey extends NamespaceKeys<
|
|
18
20
|
IntlMessages,
|
|
19
21
|
NestedKeyOf<IntlMessages>
|
|
20
22
|
> = never
|
|
21
|
-
>(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
>(
|
|
24
|
+
locale:
|
|
25
|
+
| string
|
|
26
|
+
| {
|
|
27
|
+
namespace?: NestedKey;
|
|
28
|
+
locale: string;
|
|
29
|
+
},
|
|
30
|
+
namespace?: NestedKey
|
|
31
|
+
): // Explicitly defining the return type is necessary as TypeScript would get it wrong
|
|
25
32
|
Promise<{
|
|
26
33
|
// Default invocation
|
|
27
34
|
<
|
|
@@ -81,11 +88,33 @@ Promise<{
|
|
|
81
88
|
key: TargetKey
|
|
82
89
|
): any;
|
|
83
90
|
}> {
|
|
84
|
-
|
|
91
|
+
if (typeof locale === 'object') {
|
|
92
|
+
const opts = locale;
|
|
93
|
+
namespace = opts.namespace;
|
|
94
|
+
locale = opts.locale;
|
|
95
|
+
if (!hasWarned) {
|
|
96
|
+
console.warn(
|
|
97
|
+
`
|
|
98
|
+
DEPRECATION WARNING: Calling \`getTranslator\` with an object argument is deprecated, please update your call site accordingly.
|
|
99
|
+
|
|
100
|
+
// Previously
|
|
101
|
+
getTranslator({locale: 'en', namespace: 'About'});
|
|
102
|
+
|
|
103
|
+
// Now
|
|
104
|
+
getTranslator('en', 'About');
|
|
105
|
+
|
|
106
|
+
See also https://next-intl-docs.vercel.app/docs/next-13/server-components#using-internationalization-outside-of-components
|
|
107
|
+
`
|
|
108
|
+
);
|
|
109
|
+
hasWarned = true;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const config = await getConfig(locale);
|
|
85
114
|
|
|
86
115
|
const messagesOrError = getMessagesOrError({
|
|
87
116
|
messages: config.messages as any,
|
|
88
|
-
namespace
|
|
117
|
+
namespace,
|
|
89
118
|
onError: config.onError
|
|
90
119
|
});
|
|
91
120
|
|
|
@@ -95,7 +124,7 @@ Promise<{
|
|
|
95
124
|
// @ts-ignore
|
|
96
125
|
return createBaseTranslator({
|
|
97
126
|
...config,
|
|
98
|
-
|
|
127
|
+
namespace,
|
|
99
128
|
messagesOrError
|
|
100
129
|
});
|
|
101
130
|
}
|