Files
blitzkit/packages/website/src/core/i18n/getBestLocale.ts
T

11 lines
359 B
TypeScript
Raw Normal View History

2024-12-27 13:43:25 -06:00
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;
}