()
| 22 | * Gets the locale setting of the browser. |
| 23 | */ |
| 24 | export function getDefaultLocale(): Locale { |
| 25 | let locale = |
| 26 | (typeof window !== 'undefined' && window[localeSymbol]) || |
| 27 | // @ts-ignore |
| 28 | (typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage)) || |
| 29 | 'en-US'; |
| 30 | |
| 31 | try { |
| 32 | Intl.DateTimeFormat.supportedLocalesOf([locale]); |
| 33 | } catch { |
| 34 | locale = 'en-US'; |
| 35 | } |
| 36 | return { |
| 37 | locale, |
| 38 | direction: isRTL(locale) ? 'rtl' : 'ltr' |
| 39 | }; |
| 40 | } |
| 41 | |
| 42 | let currentLocale = getDefaultLocale(); |
| 43 | let listeners = new Set<(locale: Locale) => void>(); |
no test coverage detected