fix(i18n): normalize html language tags in client detection

Agent-Logs-Url: https://github.com/trails-cool/trails/sessions/7546ba18-5628-4f50-bc8b-104fa7ba6afe

Co-authored-by: stigi <13815+stigi@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-05-25 13:24:11 +00:00 committed by GitHub
parent aa3afeeaec
commit e2460374de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 0 deletions

View file

@ -0,0 +1,16 @@
/**
* @vitest-environment jsdom
*/
import { describe, expect, it } from "vitest";
import { i18n, initI18nClient } from "./index.ts";
describe("initI18nClient", () => {
it("normalizes regional html lang tags to supported languages", () => {
document.documentElement.lang = "de-DE";
initI18nClient();
expect(i18n.language).toBe("de");
expect(i18n.t("journal:nav.login")).toBe("Anmelden");
});
});

View file

@ -64,6 +64,7 @@ export function initI18nClient() {
...commonOptions,
detection: {
order: ["htmlTag", "navigator"],
convertDetectedLanguage: (lng: string) => matchSupportedLng(lng),
caches: [],
},
});