feat(i18n): add localized navigation and news translations

This commit is contained in:
2026-02-12 21:29:15 +01:00
parent 618319dbc2
commit a7895e4dd9
12 changed files with 687 additions and 164 deletions

View File

@@ -24,6 +24,9 @@ const { mockDb } = vi.hoisted(() => ({
update: vi.fn(),
delete: vi.fn(),
},
navigationItemTranslation: {
upsert: vi.fn(),
},
},
}))
@@ -38,6 +41,7 @@ import {
getPublishedPageBySlugForLocale,
listPublicNavigation,
updatePage,
upsertNavigationItemTranslation,
upsertPageTranslation,
} from "./pages-navigation"
@@ -112,22 +116,33 @@ describe("pages-navigation service", () => {
slug: "home",
status: "published",
},
translations: [{ locale: "de", label: "Startseite" }],
},
],
})
const navigation = await listPublicNavigation("header")
const navigation = await listPublicNavigation("header", "de")
expect(navigation).toEqual([
{
id: "item-1",
label: "Home",
label: "Startseite",
href: "/",
children: [],
},
])
})
it("validates locale when upserting navigation item translation", async () => {
await expect(() =>
upsertNavigationItemTranslation({
navigationItemId: "550e8400-e29b-41d4-a716-446655440001",
locale: "it",
label: "Home",
}),
).rejects.toThrow()
})
it("validates locale when upserting page translation", async () => {
await expect(() =>
upsertPageTranslation({