use-intl 4.0.0-beta-9ea117c → 4.0.0-beta-5a7f7be
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.
|
@@ -58,24 +58,9 @@ function createTranslator({
|
|
|
58
58
|
/**
|
|
59
59
|
* Checks if a locale exists in a list of locales.
|
|
60
60
|
*
|
|
61
|
-
* Additionally, in development, the provided locales are validated to
|
|
62
|
-
* ensure they follow the Unicode language identifier standard.
|
|
63
|
-
*
|
|
64
61
|
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale
|
|
65
62
|
*/
|
|
66
63
|
function hasLocale(locales, candidate) {
|
|
67
|
-
{
|
|
68
|
-
for (const locale of locales) {
|
|
69
|
-
try {
|
|
70
|
-
const constructed = new Intl.Locale(locale);
|
|
71
|
-
if (!constructed.language) {
|
|
72
|
-
throw new Error('Language is required');
|
|
73
|
-
}
|
|
74
|
-
} catch {
|
|
75
|
-
console.error(`Found invalid locale within provided \`locales\`: "${locale}"\nPlease ensure you're using a valid Unicode locale identifier (e.g. "en-US").`);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
64
|
return locales.includes(candidate);
|
|
80
65
|
}
|
|
81
66
|
|
|
@@ -2,9 +2,6 @@ import type { Locale } from './AppConfig.tsx';
|
|
|
2
2
|
/**
|
|
3
3
|
* Checks if a locale exists in a list of locales.
|
|
4
4
|
*
|
|
5
|
-
* Additionally, in development, the provided locales are validated to
|
|
6
|
-
* ensure they follow the Unicode language identifier standard.
|
|
7
|
-
*
|
|
8
5
|
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale
|
|
9
6
|
*/
|
|
10
7
|
export default function hasLocale<LocaleType extends Locale>(locales: ReadonlyArray<LocaleType>, candidate?: string | null): candidate is LocaleType;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "use-intl",
|
|
3
|
-
"version": "4.0.0-beta-
|
|
3
|
+
"version": "4.0.0-beta-5a7f7be",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.work>",
|
|
6
6
|
"description": "Internationalization (i18n) for React",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"react": "^17.0.0 || ^18.0.0 || >=19.0.0-rc <19.0.0"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "909c2b718d71f4318999b31f783332615f4e59f8"
|
|
68
68
|
}
|