Minecraft-Mod-Translator/extract_lang.js.txt
2024-12-09 05:29:37 +08:00

22 lines
876 B
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

按照此伪代码编写一个Node.js脚本要求
1. 尽量不使用第三方库
2. 使用双引号代替单引号
3. 使用引号
伪代码:
遍历读取 ./mods/*.jar (*.jar等同于*.zip压缩包) {
const modId = JSON.parse(读取 *.jar/fabric.mod.json).id;
const enLang = JSON.parse(读取 `*.jar/assets/${modId}/lang/en_us.json`);
const zhLang = () => {'
if (存在 `*.jar/assets/${modId}/lang/zh_cn.json`) {
return JSON.parse(读取 `*.jar/assets/${modId}/lang/zh_cn.json`)
} else if (存在 `./i18n/${modId}/lang/zh_cn.json`){
return JSON.parse(读取 `./i18n/${modId}/lang/zh_cn.json`)
}
return {};
};
if (有存在于 enLang 中但不存在于 zhLang 中的 key){
写入文件`./lang/zh_cn/${modId}.json` (内容: 格式化为人易读的格式(zhLang))
}
}