mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-10-29 20:05:25 +08:00
fix: label documentation locales correctly
This commit is contained in:
+8
-1
@@ -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;
|
||||
|
||||
@@ -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`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user