feat(inspirations): 灵感库 - 将内置英文提示词统一为中文 (#763)
* feat(inspirations): 灵感库 - 统一中文正文入口并校验译文版本 * feat(inspirations): 灵感库 - 发布完整中文提示词并阻止旧译文覆盖 统一 1319 条外部提示词和 329 条画廊引用,保留来源与模板参数;校验全部原文摘要,防止上游更新后误用过期中文。 验证:Bun 1.3.9 全量 2261 项测试通过,前端构建与 lint 通过,目录身份及媒体元数据对比无变化。
This commit is contained in:
1 parent
26dfb8d91b
commit
88de4ce422
12 files changed
+6673
-1705
No files matched your search
@@ -13,6 +13,7 @@
|
||||
*/
|
||||
import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
||||
import { dirname, join, resolve } from "node:path";
|
||||
import { localizeInspirationEntries } from "./inspiration-localization.mjs";
|
||||
|
||||
const WEB_DIR = resolve(import.meta.dir, "..");
|
||||
const PUBLIC_DIR = join(WEB_DIR, "public", "inspirations");
|
||||
@@ -487,6 +488,14 @@ async function main() {
|
||||
const selected = SOURCE_PIPELINES.filter((pipeline) => !options.only || options.only === pipeline.name);
|
||||
if (!selected.length) throw new Error(`--only 不认识的来源: ${options.only}`);
|
||||
|
||||
const translations = JSON.parse(readFileSync(join(WEB_DIR, "scripts", "data", "inspiration-prompts-zh.json"), "utf8"));
|
||||
const localizedSources = new Map();
|
||||
// 先检查所有选中来源的中文覆盖,再下载封面或写目录,避免半批更新后才发现缺译。
|
||||
for (const pipeline of selected) {
|
||||
const loaded = await pipeline.load(options);
|
||||
localizedSources.set(pipeline.name, { ...loaded, entries: localizeInspirationEntries(loaded.entries, translations) });
|
||||
}
|
||||
|
||||
mkdirSync(PUBLIC_DIR, { recursive: true });
|
||||
const revisions = {};
|
||||
const counts = {};
|
||||
@@ -508,7 +517,7 @@ async function main() {
|
||||
continue;
|
||||
}
|
||||
|
||||
const loaded = await pipeline.load(options);
|
||||
const loaded = localizedSources.get(pipeline.name);
|
||||
const { entries } = loaded;
|
||||
if (!entries.length) throw new Error(`${pipeline.name} 没有解析出任何条目`);
|
||||
revisions[pipeline.name] = loaded.revision;
|
||||
|
||||
Reference in new issue
Block a user