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

30 lines
1.2 KiB
Plaintext
Raw 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. 尽量不使用第三方库adm-zip 除外用来解析jar包
2. 使用双引号代替单引号
3. 使用引号
伪代码:
const errorMods = new Array();
遍历读取 ./mods_translated/*.jar (*.jar等同于*.zip压缩包) {
输出 `正在读取 ${*.jar}`
const modId = JSON.parse(读取jar内部的 ./fabric.mod.json).id;
if (./mods_translated/*.jar 内存在文件 `/assets/${modId}/lang/en_us.json`){
const enLang = JSON.parse(读取 ./mods_translated/*.jar 内的 `/assets/${modId}/lang/en_us.json`);
const zhLang = JSON.parse(读取 ./mods_translated/*.jar 内的 `/assets/${modId}/lang/zh_cn.json`);
对比 enLang 和 zhLang 的 keys 是否相同,如果不同 则 errorMods.append(*.jar)
遍历 enLang 和 zhLang 的每一个 key {
const enTags: Array<string> = enLang[key]字符串内所有的 "%+字母" 格式的字符串
const zhTags: Array<string> = zhLang[key]字符串内所有的 "%+字母" 格式的字符串
排序 enTags 和 zhTags
if (enTags和zhTags不相同 ){
errorMods.append(*.jar)
}
}
}
}
console.log(errorMods)