fix: label documentation locales correctly

This commit is contained in:
dadachann
2026-09-04 11:35:18 +00:00
parent 3422d22808
commit 289ac19a22
2 changed files with 11 additions and 1 deletions
+8 -1
View File
@@ -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;
+3
View File
@@ -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`);
}