MCPcopy Create free account
hub / github.com/adobe/react-spectrum / getLocale

Function getLocale

packages/react-stately/src/datepicker/utils.ts:32–45  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

30const dictionary = new LocalizedStringDictionary(i18nMessages);
31
32function getLocale() {
33 // Match browser language setting here, NOT react-aria's I18nProvider, so that we match other browser-provided
34 // validation messages, which to not respect our provider's language.
35 let locale =
36 // @ts-ignore
37 (typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage)) || 'en-US';
38
39 try {
40 Intl.DateTimeFormat.supportedLocalesOf([locale]);
41 } catch {
42 locale = 'en-US';
43 }
44 return locale;
45}
46
47export function getValidationResult(
48 value: DateValue | null,

Callers 2

getValidationResultFunction · 0.85
getRangeValidationResultFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected