Update i18n Scanning (#1352)

* detect duplicate values during scanning

* fix typo
This commit is contained in:
蓝梦实 2024-07-27 14:46:04 +08:00 committed by GitHub
parent 3f9a6bbfb4
commit 0565c3e072
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View File

@ -151,7 +151,7 @@
"请输入有效文本": "有効なテキストを入力してください",
"转换": "変換",
"输入待处理音频文件夹路径": "処理するオーディオフォルダのパスを入力してください:",
"输入文件夹路径": "力フォルダのパス",
"输入文件夹路径": "力フォルダのパス",
"输出logs/实验名目录下应有23456开头的文件和文件夹": "logs/実験名ディレクトリには23456で始まるファイルとフォルダが含まれている必要があります",
"输出信息": "出力情報",
"输出文件夹路径": "出力フォルダのパス",

View File

@ -86,11 +86,21 @@ def update_i18n_json(json_file, standard_keys):
print(f"{'Total Keys (After)'.ljust(KEY_LEN)}: {len(json_data)}")
# 识别有待翻译的键
num_miss_translation = 0
duplicate_items = {}
for key, value in json_data.items():
if value.startswith("#!"):
num_miss_translation += 1
if SHOW_KEYS:
print(f"{'Missing Translation'.ljust(KEY_LEN)}: {key}")
if value in duplicate_items:
duplicate_items[value].append(key)
else:
duplicate_items[value] = [key]
# 打印是否有重复的值
for value, keys in duplicate_items.items():
if len(keys) > 1:
print("\n".join([f"\033[31m{'[Failed] Duplicate Value'.ljust(KEY_LEN)}: {key} -> {value}\033[0m" for key in keys]))
if num_miss_translation > 0:
print(f"\033[31m{'[Failed] Missing Translation'.ljust(KEY_LEN)}: {num_miss_translation}\033[0m")
else: