mirror of
https://github.com/XTLS/Xray-docs-next.git
synced 2026-09-28 18:08:01 +03:00
VitePress: 修复翻译页缺失功能无效问题
This commit is contained in:
@@ -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 }}
|
||||
</span>
|
||||
<span v-else>
|
||||
This page is not translated yet. Please refer to the Chinese original.
|
||||
{{ text.missing }}
|
||||
</span>
|
||||
<br />
|
||||
<a :href="info.zhRoute" class="link">
|
||||
<a
|
||||
:href="info.zhRoute"
|
||||
class="link"
|
||||
target="_blank"
|
||||
rel="noreferrer noopener"
|
||||
>
|
||||
{{ text.go }}
|
||||
</a>
|
||||
</p>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user