mirror of
https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI.git
synced 2024-12-29 19:15:04 +08:00
fix genlocale
This commit is contained in:
parent
19670917c6
commit
ea1047ec8e
4
.github/workflows/genlocale.yml
vendored
4
.github/workflows/genlocale.yml
vendored
@ -13,8 +13,8 @@ jobs:
|
|||||||
|
|
||||||
- name: Run locale generation
|
- name: Run locale generation
|
||||||
run: |
|
run: |
|
||||||
python3 lib/i18n/scan_i18n.py
|
python3 i18n/scan_i18n.py
|
||||||
cd lib/i18n && python3 locale_diff.py
|
python3 i18n/locale_diff.py
|
||||||
|
|
||||||
- name: Commit back
|
- name: Commit back
|
||||||
if: ${{ !github.head_ref }}
|
if: ${{ !github.head_ref }}
|
||||||
|
@ -8,7 +8,9 @@ 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
|
os.path.join(dir_path, f)
|
||||||
|
for f in os.listdir(dir_path)
|
||||||
|
if f.endswith(".json") and f != standard_file
|
||||||
]
|
]
|
||||||
|
|
||||||
# Load the standard file
|
# Load the standard file
|
||||||
@ -18,7 +20,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(dir_path + lang_file, "r", encoding="utf-8") as f:
|
with open(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 +42,6 @@ for lang_file in languages:
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Save the updated language file
|
# Save the updated language file
|
||||||
with open(dir_path + lang_file, "w", encoding="utf-8") as f:
|
with open(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")
|
||||||
|
@ -49,8 +49,8 @@ print()
|
|||||||
print("Total unique:", len(code_keys))
|
print("Total unique:", len(code_keys))
|
||||||
|
|
||||||
|
|
||||||
standard_file = "zh_CN.json"
|
standard_file = "i18n/locale/zh_CN.json"
|
||||||
with open(f"lib/i18n/{standard_file}", "r", encoding="utf-8") as f:
|
with open(standard_file, "r", encoding="utf-8") as f:
|
||||||
standard_data = json.load(f, object_pairs_hook=OrderedDict)
|
standard_data = json.load(f, object_pairs_hook=OrderedDict)
|
||||||
standard_keys = set(standard_data.keys())
|
standard_keys = set(standard_data.keys())
|
||||||
|
|
||||||
@ -70,6 +70,6 @@ for s in strings:
|
|||||||
code_keys_dict[s] = s
|
code_keys_dict[s] = s
|
||||||
|
|
||||||
# write back
|
# write back
|
||||||
with open(f"lib/i18n/{standard_file}", "w", encoding="utf-8") as f:
|
with open(standard_file, "w", encoding="utf-8") as f:
|
||||||
json.dump(code_keys_dict, f, ensure_ascii=False, indent=4, sort_keys=True)
|
json.dump(code_keys_dict, f, ensure_ascii=False, indent=4, sort_keys=True)
|
||||||
f.write("\n")
|
f.write("\n")
|
Loading…
Reference in New Issue
Block a user