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:
parent
aa3afeeaec
commit
e2460374de
2 changed files with 17 additions and 0 deletions
16
packages/i18n/src/client.test.ts
Normal file
16
packages/i18n/src/client.test.ts
Normal 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");
|
||||
});
|
||||
});
|
||||
|
|
@ -64,6 +64,7 @@ export function initI18nClient() {
|
|||
...commonOptions,
|
||||
detection: {
|
||||
order: ["htmlTag", "navigator"],
|
||||
convertDetectedLanguage: (lng: string) => matchSupportedLng(lng),
|
||||
caches: [],
|
||||
},
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue