UNPKG

scrabble-solver

Version:

Scrabble Solver 2 - Free, open-source, cross-platform, multi-language analysis tool for Scrabble, Scrabble Duel, Super Scrabble, Letter League, Literaki, and Kelimelik. Quickly find the top-scoring words using the given board and tiles.

21 lines (15 loc) 509 B
import { Locale } from '@scrabble-solver/types'; export const guessLocale = (): Locale => { if (!globalThis.navigator) { return Locale.EN_US; } const locales = Object.values(Locale); const exactMatch = locales.find((locale) => globalThis.navigator.language === String(locale)); if (exactMatch) { return exactMatch; } const partialMatch = locales.find((locale) => { return globalThis.navigator.language === locale.substring(0, 2); }); return partialMatch || Locale.EN_US; };