Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 332x 332x 331x 331x 331x 331x | export type Locale = string & {
__flavor?: "locale";
};
export const VALID_LOCALES = Intl.getCanonicalLocales();
// TODO: this is needed to be refined
// Real-life locale contains multiple sections (date & time, number formatting etc.)
export const getValidLocale = (input: string): Locale | undefined => {
try {
const locales = Intl.getCanonicalLocales([input]);
Eif (locales.length === 1) {
// oxlint-disable-next-line typescript/no-non-null-assertion
return locales[0]!;
}
} catch (error) {
if (error instanceof TypeError) {
return input;
}
}
};
|