mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-15 05:36:11 +01:00
11 lines
359 B
TypeScript
11 lines
359 B
TypeScript
import { DEFAULT_LOCALE, SUPPORTED_LOCALES } from '@blitzkit/core';
|
|||
|
|
|
||
|
|
export function getBestLocale() {
|
||
|
|
const desiredLocale = navigator.language.split('-')[0];
|
||
|
|
const isSupported = SUPPORTED_LOCALES.includes(desiredLocale);
|
||
|
|
const isDefault = desiredLocale === DEFAULT_LOCALE;
|
||
|
|
|
||
|
|
if (!isSupported || isDefault) return undefined;
|
||
|
|
|
||
|
|
return desiredLocale;
|
||
|
|
}
|