12345
This commit is contained in:
parent
df30d80669
commit
4ebff91502
2
01.py
2
01.py
@ -27,4 +27,4 @@ def sort_json_keys(input_file, output_file):
|
|||||||
|
|
||||||
# 示例用法
|
# 示例用法
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
sort_json_keys("text_original/ch1/ja_JP.json", "text_original/ch1/ja_JP.json")
|
sort_json_keys("text_original/ch2/ja_JP.json", "text_original/ch2/ja_JP.json")
|
||||||
|
8
02.py
8
02.py
@ -4,8 +4,8 @@ import os
|
|||||||
|
|
||||||
def build_translation_dict(folder):
|
def build_translation_dict(folder):
|
||||||
en_path = os.path.join(folder, "en.json")
|
en_path = os.path.join(folder, "en.json")
|
||||||
zh_path = os.path.join(folder, "zh_CN.json")
|
zh_path = os.path.join(folder, "ja_JP.json")
|
||||||
out_path = os.path.join(folder, "zh_CN_new.json")
|
out_path = os.path.join(folder, "ja_JP_new.json")
|
||||||
|
|
||||||
# 加载 JSON 文件
|
# 加载 JSON 文件
|
||||||
with open(en_path, "r", encoding="utf-8") as f:
|
with open(en_path, "r", encoding="utf-8") as f:
|
||||||
@ -18,7 +18,7 @@ def build_translation_dict(folder):
|
|||||||
|
|
||||||
for key, en_value in en_data.items():
|
for key, en_value in en_data.items():
|
||||||
zh_value = zh_data.get(key, "")
|
zh_value = zh_data.get(key, "")
|
||||||
if zh_value == "" or zh_value == en_value:
|
if zh_value == "":
|
||||||
result[key] = ""
|
result[key] = ""
|
||||||
else:
|
else:
|
||||||
result[key] = zh_value
|
result[key] = zh_value
|
||||||
@ -32,4 +32,4 @@ def build_translation_dict(folder):
|
|||||||
|
|
||||||
# 示例调用
|
# 示例调用
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
build_translation_dict("text_original/ch2") # 当前目录下执行,可替换为其他路径
|
build_translation_dict("text_original/ch1") # 当前目录下执行,可替换为其他路径
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
6244
text_processed/ch1/ja_JP.json
Normal file
6244
text_processed/ch1/ja_JP.json
Normal file
File diff suppressed because it is too large
Load Diff
13093
text_processed/ch2/ja_JP.json
Normal file
13093
text_processed/ch2/ja_JP.json
Normal file
File diff suppressed because it is too large
Load Diff
6244
text_target/ch1/ja_JP.json
Normal file
6244
text_target/ch1/ja_JP.json
Normal file
File diff suppressed because it is too large
Load Diff
13093
text_target/ch2/ja_JP.json
Normal file
13093
text_target/ch2/ja_JP.json
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user