next-intl 4.0.0-beta-77949ef → 4.0.0-beta-9e73cbe
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/dist/esm/development/routing/defineRouting.js +0 -5
- package/dist/esm/development/server/react-server/getConfig.js +4 -0
- package/dist/esm/development/server/react-server/validateLocale.js +12 -0
- package/dist/types/server/react-server/getServerFormatter.d.ts +4 -1
- package/dist/types/server/react-server/validateLocale.d.ts +1 -0
- package/package.json +3 -3
- package/dist/esm/development/routing/validateLocales.js +0 -14
- package/dist/types/routing/validateLocales.d.ts +0 -2
|
@@ -2,6 +2,7 @@ import { cache } from 'react';
|
|
|
2
2
|
import { _createIntlFormatters, _createCache, initializeConfig } from 'use-intl/core';
|
|
3
3
|
import { getRequestLocale } from './RequestLocale.js';
|
|
4
4
|
import getRuntimeConfig from 'next-intl/config';
|
|
5
|
+
import validateLocale from './validateLocale.js';
|
|
5
6
|
|
|
6
7
|
// This is automatically inherited by `NextIntlClientProvider` if
|
|
7
8
|
// the component is rendered from a Server Component
|
|
@@ -36,6 +37,9 @@ See also: https://next-intl.dev/docs/usage/configuration#i18n-request
|
|
|
36
37
|
if (!result.locale) {
|
|
37
38
|
throw new Error('No locale was returned from `getRequestConfig`.\n\nSee https://next-intl.dev/docs/usage/configuration#i18n-request');
|
|
38
39
|
}
|
|
40
|
+
{
|
|
41
|
+
validateLocale(result.locale);
|
|
42
|
+
}
|
|
39
43
|
return result;
|
|
40
44
|
}
|
|
41
45
|
const receiveRuntimeConfig = cache(receiveRuntimeConfigImpl);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
function validateLocale(locale) {
|
|
2
|
+
try {
|
|
3
|
+
const constructed = new Intl.Locale(locale);
|
|
4
|
+
if (!constructed.language) {
|
|
5
|
+
throw new Error('Language is required');
|
|
6
|
+
}
|
|
7
|
+
} catch {
|
|
8
|
+
console.error(`An invalid locale was provided: "${locale}"\nPlease ensure you're using a valid Unicode locale identifier (e.g. "en-US").`);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { validateLocale as default };
|
|
@@ -8,7 +8,10 @@ declare function getFormatterCachedImpl(config: Parameters<typeof createFormatte
|
|
|
8
8
|
(value: number | bigint, options?: import("use-intl/core").NumberFormatOptions): string;
|
|
9
9
|
(value: number | bigint, format?: string, options?: import("use-intl/core").NumberFormatOptions): string;
|
|
10
10
|
};
|
|
11
|
-
relativeTime:
|
|
11
|
+
relativeTime: {
|
|
12
|
+
(date: number | Date, now?: import("use-intl/core").RelativeTimeFormatOptions["now"]): string;
|
|
13
|
+
(date: number | Date, options?: import("use-intl/core").RelativeTimeFormatOptions): string;
|
|
14
|
+
};
|
|
12
15
|
list: {
|
|
13
16
|
<Value extends string | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>>(value: Iterable<Value>, options?: Intl.ListFormatOptions): Value extends string ? string : Iterable<import("react").ReactElement>;
|
|
14
17
|
<Value extends string | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>>(value: Iterable<Value>, format?: string, options?: Intl.ListFormatOptions): Value extends string ? string : Iterable<import("react").ReactElement>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function validateLocale(locale: string): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intl",
|
|
3
|
-
"version": "4.0.0-beta-
|
|
3
|
+
"version": "4.0.0-beta-9e73cbe",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.work>",
|
|
6
6
|
"funding": [
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
"dependencies": {
|
|
113
113
|
"@formatjs/intl-localematcher": "^0.5.4",
|
|
114
114
|
"negotiator": "^1.0.0",
|
|
115
|
-
"use-intl": "4.0.0-beta-
|
|
115
|
+
"use-intl": "4.0.0-beta-9e73cbe"
|
|
116
116
|
},
|
|
117
117
|
"peerDependencies": {
|
|
118
118
|
"next": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0",
|
|
@@ -124,5 +124,5 @@
|
|
|
124
124
|
"optional": true
|
|
125
125
|
}
|
|
126
126
|
},
|
|
127
|
-
"gitHead": "
|
|
127
|
+
"gitHead": "31d0b2dfc66357f02a07f0b434f85dc8f0a7dad3"
|
|
128
128
|
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
function validateLocales(locales) {
|
|
2
|
-
for (const locale of locales) {
|
|
3
|
-
try {
|
|
4
|
-
const constructed = new Intl.Locale(locale);
|
|
5
|
-
if (!constructed.language) {
|
|
6
|
-
throw new Error('Language is required');
|
|
7
|
-
}
|
|
8
|
-
} catch {
|
|
9
|
-
console.error(`Found invalid locale within provided \`locales\`: "${locale}"\nPlease ensure you're using a valid Unicode locale identifier (e.g. "en-US").`);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export { validateLocales as default };
|