@equinor/eds-core-react
Version:
The React implementation of the Equinor Design System
16 lines (13 loc) • 409 B
JavaScript
import { useLocale } from 'react-aria';
const useGetLocale = locale => {
const {
locale: currentLocale
} = useLocale();
// Priority:
// 1. Explicitly passed locale prop
// 2. Locale from I18nProvider
// 3. Fallback to browser's default
const browserLocale = new Intl.DateTimeFormat().resolvedOptions().locale;
return locale ?? currentLocale ?? browserLocale;
};
export { useGetLocale };