okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Trial2 merge f-0291-pr-nv (97b3d614f)1306424be

main
631 B14 linesraw
1import { LANGUAGES, type Language } from './i18n';
2
3/**
4 * The first start (nothing saved yet) opens in the language of the computer (#3723): the first of the browser's preferred languages that
5 * Strata has. "pt-BR" is Portuguese, "zh-TW" is Chinese (the app has one Chinese, Simplified). Null when none of them is offered.
6 */
7export function detectLanguage(tags: readonly string[] | null | undefined): Language | null {
8  for (const raw of tags ?? []) {
9    const base = String(raw).toLowerCase().split(/[-_]/)[0];
10    const found = LANGUAGES.find(l => l.value === base);
11    if (found) return found.value;
12  }
13  return null;
14}