From 531a851a26e32d70b34e041c4f1c21ec8dea3cda Mon Sep 17 00:00:00 2001 From: Meow <197331664+Meo597@users.noreply.github.com> Date: Mon, 19 Jan 2026 19:41:01 +0800 Subject: [PATCH] =?UTF-8?q?VitePress:=20=E4=BF=AE=E5=A4=8D=E7=BF=BB?= =?UTF-8?q?=E8=AF=91=E9=A1=B5=E7=BC=BA=E5=A4=B1=E5=8A=9F=E8=83=BD=E6=97=A0?= =?UTF-8?q?=E6=95=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vitepress/theme/components/TranslationNotice.vue | 13 +++++++++++-- scripts/gen-i18n-stale.mjs | 9 +++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.vitepress/theme/components/TranslationNotice.vue b/.vitepress/theme/components/TranslationNotice.vue index f25d4f32..a2824884 100644 --- a/.vitepress/theme/components/TranslationNotice.vue +++ b/.vitepress/theme/components/TranslationNotice.vue @@ -29,11 +29,15 @@ const text = computed(() => { en: { title: "Translation notice", body: "This translation may be outdated. Please refer to the Chinese original.", + missing: + "This page is not translated yet. Please refer to the Chinese original.", go: "View Chinese original", }, ru: { title: "Уведомление о переводе", body: "Этот перевод может быть устаревшим. Пожалуйста, обратитесь к оригинальной китайской версии.", + missing: + "Эта страница ещё не переведена. Пожалуйста, обратитесь к оригинальной версии на китайском языке.", go: "Посмотреть оригинальную китайскую версию", }, }; @@ -55,10 +59,15 @@ const text = computed(() => { {{ text.body }} - This page is not translated yet. Please refer to the Chinese original. + {{ text.missing }}
- + {{ text.go }}

diff --git a/scripts/gen-i18n-stale.mjs b/scripts/gen-i18n-stale.mjs index 4893ce2c..c62e5f39 100644 --- a/scripts/gen-i18n-stale.mjs +++ b/scripts/gen-i18n-stale.mjs @@ -38,6 +38,14 @@ function toRouteFromDocsRel(relToDocs) { return route; } +function ensureEmptyPlaceholder(locale, relNoLocale) { + const tAbs = path.join(DOCS_DIR, locale, relNoLocale); // docs/en/xxx.md + if (fs.existsSync(tAbs)) return; + + fs.mkdirSync(path.dirname(tAbs), { recursive: true }); + fs.writeFileSync(tAbs, "", "utf8"); +} + const zhFiles = walk(DOCS_DIR).filter((p) => { const rel = path.relative(DOCS_DIR, p).replaceAll("\\", "/"); return !LOCALES.some((l) => rel.startsWith(l + "/")); @@ -96,6 +104,7 @@ for (const [zhRel, zhAbs] of zhByRel.entries()) { tLastUpdated: null, zhLastUpdated: zhISO, }; + ensureEmptyPlaceholder(locale, zhRel); } } }