mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-16 01:40:46 +08:00
chore: update overseas clients tools
add a new tool to help locate untranslated texts in json minor updates to the old ones rename files so that they are more intuitive
This commit is contained in:
2
tools/OverseasClients/.gitignore
vendored
Normal file
2
tools/OverseasClients/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
diff_image/
|
||||
missing*
|
||||
90
tools/OverseasClients/FindMissingJsonTranslate.py
Normal file
90
tools/OverseasClients/FindMissingJsonTranslate.py
Normal file
@@ -0,0 +1,90 @@
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
|
||||
# NOTE
|
||||
# You may customize here
|
||||
regex_ignore_list = [
|
||||
"Mizuki",
|
||||
"SSS",
|
||||
"Reclamation",
|
||||
"Rogue"
|
||||
]
|
||||
|
||||
server_list = [
|
||||
"YoStarJP",
|
||||
"YoStarEN",
|
||||
"YoStarKR",
|
||||
"txwy"
|
||||
]
|
||||
|
||||
# Get the server name from argument
|
||||
try:
|
||||
# server_name = "YoStarJP"
|
||||
server_name = sys.argv[1]
|
||||
if server_name not in server_list:
|
||||
raise
|
||||
except Exception:
|
||||
server_name = None
|
||||
while (not server_name):
|
||||
print("Enter one and only one server name:",
|
||||
", ".join(server_list))
|
||||
t = input()
|
||||
server_name = t if t in server_list else None
|
||||
|
||||
output_file = "missing_translate-" + server_name + ".txt"
|
||||
|
||||
cur_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
proj_dir = os.path.join(cur_dir, "../../")
|
||||
output_file = os.path.join(cur_dir, output_file)
|
||||
|
||||
# File name of the json
|
||||
# NOTE: You may change this to e.g. recruitment.json
|
||||
# This is hardcoded because tasks.json is the most likely modified one
|
||||
json_name = "tasks.json"
|
||||
|
||||
zh_json_file = os.path.join(proj_dir, "resource/", json_name)
|
||||
gl_json_file = os.path.join(proj_dir, "resource/global/",
|
||||
server_name, "resource/", json_name)
|
||||
|
||||
# For test purpose
|
||||
# gl_json_file = os.path.join(cur_dir, "test.json")
|
||||
|
||||
with open(zh_json_file, 'r', encoding='utf-8') as zh_fh:
|
||||
zh_json: dict = json.load(zh_fh)
|
||||
|
||||
with open(gl_json_file, 'r', encoding='utf-8') as gl_fh:
|
||||
gl_json: dict = json.load(gl_fh)
|
||||
|
||||
# def getBaseTask(task: dict) -> dict:
|
||||
# try:
|
||||
# base_task = zh_json[task["base_task"]]
|
||||
# return getBaseTask(base_task)
|
||||
# except:
|
||||
# return task
|
||||
|
||||
res_keys = []
|
||||
for key, value in zh_json.items():
|
||||
value: dict
|
||||
# check if it has a "text" and if the text is empty
|
||||
if value.get("text"):
|
||||
# and then check if gl_json has a corresponding one
|
||||
try:
|
||||
_ = gl_json[key]["text"][0]
|
||||
except:
|
||||
if any(map(lambda x: re.search(x, key), regex_ignore_list)):
|
||||
continue
|
||||
# NOTE
|
||||
# It is likely that Ascii texts do not need a translation but there is no guarantee.
|
||||
# You may want to comment this out in some cases.
|
||||
# if getBaseTask(value).get("isAscii", False) is True:
|
||||
if all(map(str.isascii, value["text"])):
|
||||
continue
|
||||
|
||||
res_keys.append(key + ': ' + ', '.join(value["text"]))
|
||||
|
||||
print(key, value["text"])
|
||||
|
||||
with open(output_file, 'w', encoding='utf-8') as f:
|
||||
f.write('\n'.join(res_keys))
|
||||
@@ -16,18 +16,29 @@
|
||||
# 1. Install Python
|
||||
# 2. Run "$python diff_resource.py xxx" in the terminal where xxx is the desired
|
||||
# server name i.e. YoStarJP/YoStarEN/YoStarKR/txwy
|
||||
# 3. Results can be found in the diff_image folder
|
||||
# 3. Results can be found in the missing_templates folder
|
||||
#
|
||||
|
||||
|
||||
import os
|
||||
import sys
|
||||
import shutil
|
||||
import re
|
||||
|
||||
# NOTE
|
||||
# Put the file names of text-less images (so that global servers use the same
|
||||
# image as the ZH (ZH_CN) server does) in this file.
|
||||
# Note you have to manually update the content of this file.
|
||||
ignore_list_file_name = "ignore_list.txt"
|
||||
ignore_list_file_name = "ignore_list_of_templates.txt"
|
||||
|
||||
# NOTE
|
||||
# You may customize here
|
||||
regex_ignore_list = [
|
||||
"Mizuki",
|
||||
"SSS",
|
||||
"Reclamation",
|
||||
"Rogue"
|
||||
]
|
||||
|
||||
server_list = [
|
||||
"YoStarJP",
|
||||
@@ -67,27 +78,23 @@ with open(os.path.join(cur_dir, ignore_list_file_name)) as f:
|
||||
ignore_files = [line.rstrip('\n') for line in f]
|
||||
|
||||
# ZH server pics not found in global server nor ignored will be filtered here
|
||||
diff_files = [i for i in zh_files if
|
||||
|
||||
# NOTE: You May Customize Here
|
||||
# not i.startswith("Mizuki@Roguelike") and
|
||||
"Rogue" not in i and
|
||||
|
||||
i not in gl_files and
|
||||
i not in ignore_files
|
||||
diff_files = [f for f in zh_files if
|
||||
not any(map(lambda x: re.search(x, f), regex_ignore_list)) and
|
||||
f not in gl_files and
|
||||
f not in ignore_files
|
||||
]
|
||||
|
||||
# These pictures will be copied to the diff_image folder for reference.
|
||||
# These pictures will be copied to the missing_templates folder for reference.
|
||||
# Contributors of global servers may screenshot the corresponding files.
|
||||
# Note this folder is in .gitignore so it will not be uploaded.
|
||||
out_dir = os.path.join(cur_dir, "diff_image/", server_name)
|
||||
out_dir = os.path.join(cur_dir, "missing_templates/", server_name)
|
||||
if os.path.exists(out_dir):
|
||||
shutil.rmtree(out_dir)
|
||||
os.makedirs(out_dir)
|
||||
|
||||
for i in diff_files:
|
||||
# print(i)
|
||||
shutil.copyfile(os.path.join(zh_dir, i), os.path.join(out_dir, i))
|
||||
for f in diff_files:
|
||||
# print(f)
|
||||
shutil.copyfile(os.path.join(zh_dir, f), os.path.join(out_dir, f))
|
||||
|
||||
print("Pictures not included in", server_name,
|
||||
"server resources is copied to diff_image/" + server_name)
|
||||
"server resources is copied to missing_templates/" + server_name)
|
||||
1
tools/global_servers/.gitignore
vendored
1
tools/global_servers/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
diff_image/
|
||||
Reference in New Issue
Block a user