diff --git a/press.config.tsx b/press.config.tsx index 9734315bd..6a7ff2e0d 100644 --- a/press.config.tsx +++ b/press.config.tsx @@ -5,6 +5,7 @@ import { flexsearchPlugin } from "fumapress/plugins/flexsearch"; import { openapiPlugin } from "fumapress/plugins/openapi"; import { robotsPlugin } from "fumapress/plugins/robots"; import { update } from "fumadocs-core/source"; +import { uiTranslations } from "fumadocs-ui/i18n"; import { defineDocs } from "fumadocs-mdx/macro"; import { createOpenAPI, type OpenAPIServer } from "fumadocs-openapi/server"; import { readdirSync } from "node:fs"; @@ -17,7 +18,13 @@ const HREFLANG = { en: "en", zh: "zh-CN", ja: "ja" } as const; const mintlifyDocs = readMintlifyDocs(); const translations = defineMintlifyI18n(mintlifyDocs, { localeMap: { en: "en", cn: "zh", jp: "ja" }, -}).translations(); +}).translations() + .extend(uiTranslations()) + .add({ + en: { displayName: "English" }, + zh: { displayName: "简体中文" }, + ja: { displayName: "日本語" }, + }); // Locale-only files must not inherit the English storage and create indexed // pages in locales where no canonical source translation exists. translations.config.fallbackLanguage = null; diff --git a/tests/fumapress-static-build.test.mjs b/tests/fumapress-static-build.test.mjs index baa6324aa..4d7047d70 100644 --- a/tests/fumapress-static-build.test.mjs +++ b/tests/fumapress-static-build.test.mjs @@ -129,6 +129,9 @@ test("rendered navbar uses each locale's docs.json labels and hrefs", async () = for (const locale of locales) { const html = await readFile(path.join(publicRoot, locale, "insight/guide/index.html"), "utf8"); for (const value of expected[locale]) assert.ok(html.includes(value), `${locale} navbar missing ${value}`); + for (const languageName of ["English", "简体中文", "日本語"]) { + assert.ok(html.includes(languageName), `${locale} language selector missing ${languageName}`); + } for (const other of locales.filter((item) => item !== locale)) { assert.ok(!html.includes(expected[other][1]), `${locale} navbar includes ${other} home link`); }