feat(config): add shared browser cookie policy
Quality / quality (ubuntu-latest) (push) Failing after 9m46s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
2026-08-12 21:53:07 +05:30
parent a0dab308f0
commit 5de792f359
15 changed files with 198 additions and 22 deletions
+5 -1
View File
@@ -1,5 +1,5 @@
import { test, expect } from "bun:test";
import { resolveI18n, makeT, resolveLang, translateHtml } from "../src/index.ts";
import { I18N_RUNTIME, resolveI18n, makeT, resolveLang, translateHtml } from "../src/index.ts";
const i18n = resolveI18n(
{
@@ -27,6 +27,10 @@ test("resolveLang: cookie → Accept-Language → default", () => {
expect(resolveLang(i18n, "xx", "de")).toBe("en"); // invalid cookie + unsupported header
});
test("language changes use the shared browser cookie helper", () => {
expect(I18N_RUNTIME).toContain('window.wrnCookies.set(cookieName, lang, "language", cookie)');
});
test("translateHtml resolves data-t text and t:attr attributes", () => {
const t = makeT(i18n, "en");
const out = translateHtml('<input t:placeholder="ph"><span data-t="nav.home"></span>', t);