mirror of
https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI.git
synced 2026-01-20 02:51:09 +00:00
add localization(添加本地化) (#35)
* add i18n * Add gui.py as target * update * Update extract_locale.py
This commit is contained in:
28
extract_locale.py
Normal file
28
extract_locale.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import json
|
||||
import re
|
||||
|
||||
# Define regular expression patterns
|
||||
pattern = r'i18n\([^)]*\)'
|
||||
|
||||
# Initialize the dictionary to store key-value pairs
|
||||
data = {}
|
||||
|
||||
# Extract labels from infer-webui.py
|
||||
with open('infer-web.py', 'r', encoding='utf-8') as f:
|
||||
contents = f.read()
|
||||
matches = re.findall(pattern, contents)
|
||||
for match in matches:
|
||||
key = match.strip('()"')
|
||||
data[key] = key
|
||||
|
||||
# Extract labels from gui.py
|
||||
with open('gui.py', 'r', encoding='utf-8') as f:
|
||||
contents = f.read()
|
||||
matches = re.findall(pattern, contents)
|
||||
for match in matches:
|
||||
key = match.strip('()"')
|
||||
data[key] = key
|
||||
|
||||
# Save as a JSON file
|
||||
with open('./locale/zh_CN.json', 'w', encoding='utf-8') as f:
|
||||
json.dump(data, f, ensure_ascii=False, indent=4)
|
||||
Reference in New Issue
Block a user