Spaces:
Configuration error
Configuration error
Commit ·
f0df26f
1
Parent(s): f24fef6
Delete extract_locale.py
Browse files- extract_locale.py +0 -34
extract_locale.py
DELETED
|
@@ -1,34 +0,0 @@
|
|
| 1 |
-
import json
|
| 2 |
-
import re
|
| 3 |
-
|
| 4 |
-
# Define regular expression patterns
|
| 5 |
-
pattern = r"""i18n\([\s\n\t]*(["'][^"']+["'])[\s\n\t]*\)"""
|
| 6 |
-
|
| 7 |
-
# Initialize the dictionary to store key-value pairs
|
| 8 |
-
data = {}
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
def process(fn: str):
|
| 12 |
-
global data
|
| 13 |
-
with open(fn, "r", encoding="utf-8") as f:
|
| 14 |
-
contents = f.read()
|
| 15 |
-
matches = re.findall(pattern, contents)
|
| 16 |
-
for key in matches:
|
| 17 |
-
key = eval(key)
|
| 18 |
-
print("extract:", key)
|
| 19 |
-
data[key] = key
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
print("processing infer-web.py")
|
| 23 |
-
process("infer-web.py")
|
| 24 |
-
|
| 25 |
-
print("processing gui_v0.py")
|
| 26 |
-
process("gui_v0.py")
|
| 27 |
-
|
| 28 |
-
print("processing gui_v1.py")
|
| 29 |
-
process("gui_v1.py")
|
| 30 |
-
|
| 31 |
-
# Save as a JSON file
|
| 32 |
-
with open("./i18n/en_US.json", "w", encoding="utf-8") as f:
|
| 33 |
-
json.dump(data, f, ensure_ascii=False, indent=4)
|
| 34 |
-
f.write("\n")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|