1
0
mirror of synced 2025-02-20 04:21:00 +01:00

fix locale_diff.py

This commit is contained in:
Ftps 2023-08-28 23:58:20 +09:00
parent 73627d22bb
commit cffdce2097

View File

@ -3,10 +3,10 @@ import os
from collections import OrderedDict from collections import OrderedDict
# Define the standard file name # Define the standard file name
standard_file = "zh_CN.json" standard_file = "i18n/locale/zh_CN.json"
# Find all JSON files in the directory # Find all JSON files in the directory
dir_path = "i18n/locale" dir_path = "i18n/locale/"
languages = [ languages = [
f for f in os.listdir(dir_path) if f.endswith(".json") and f != standard_file f for f in os.listdir(dir_path) if f.endswith(".json") and f != standard_file
] ]
@ -18,7 +18,7 @@ with open(standard_file, "r", encoding="utf-8") as f:
# Loop through each language file # Loop through each language file
for lang_file in languages: for lang_file in languages:
# Load the language file # Load the language file
with open(lang_file, "r", encoding="utf-8") as f: with open(dir_path + lang_file, "r", encoding="utf-8") as f:
lang_data = json.load(f, object_pairs_hook=OrderedDict) lang_data = json.load(f, object_pairs_hook=OrderedDict)
# Find the difference between the language file and the standard file # Find the difference between the language file and the standard file
@ -40,6 +40,6 @@ for lang_file in languages:
) )
# Save the updated language file # Save the updated language file
with open(lang_file, "w", encoding="utf-8") as f: with open(dir_path + lang_file, "w", encoding="utf-8") as f:
json.dump(lang_data, f, ensure_ascii=False, indent=4, sort_keys=True) json.dump(lang_data, f, ensure_ascii=False, indent=4, sort_keys=True)
f.write("\n") f.write("\n")