mirror of
https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI.git
synced 2026-02-16 16:20:23 +00:00
add localization(添加本地化) (#35)
* add i18n * Add gui.py as target * update * Update extract_locale.py
This commit is contained in:
33
locale/locale_diff.py
Normal file
33
locale/locale_diff.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import json
|
||||
import os
|
||||
from collections import OrderedDict
|
||||
|
||||
# Define the standard file name
|
||||
standard_file = "zh_CN.json"
|
||||
|
||||
# Define the list of supported languages
|
||||
languages = ["ja_JP.json", "en_US.json"]
|
||||
|
||||
# Load the standard file
|
||||
with open(standard_file, "r", encoding="utf-8") as f:
|
||||
standard_data = json.load(f, object_pairs_hook=OrderedDict)
|
||||
|
||||
# Loop through each language file
|
||||
for lang_file in languages:
|
||||
# Load the language file
|
||||
with open(lang_file, "r", encoding="utf-8") as f:
|
||||
lang_data = json.load(f, object_pairs_hook=OrderedDict)
|
||||
|
||||
# Find the difference between the language file and the standard file
|
||||
diff = set(standard_data.keys()) - set(lang_data.keys())
|
||||
|
||||
# Add any missing keys to the language file
|
||||
for key in diff:
|
||||
lang_data[key] = key
|
||||
|
||||
# Sort the keys of the language file to match the order of the standard file
|
||||
lang_data = OrderedDict(sorted(lang_data.items(), key=lambda x: list(standard_data.keys()).index(x[0])))
|
||||
|
||||
# Save the updated language file
|
||||
with open(lang_file, "w", encoding="utf-8") as f:
|
||||
json.dump(lang_data, f, ensure_ascii=False, indent=4)
|
||||
Reference in New Issue
Block a user