optimize: move i18n to lib
This commit is contained in:
parent
8364750272
commit
76c18b547c
2
.github/workflows/genlocale.yml
vendored
2
.github/workflows/genlocale.yml
vendored
@ -14,7 +14,7 @@ jobs:
|
|||||||
- name: Run locale generation
|
- name: Run locale generation
|
||||||
run: |
|
run: |
|
||||||
python3 extract_locale.py
|
python3 extract_locale.py
|
||||||
cd i18n && python3 locale_diff.py
|
cd lib/i18n && python3 locale_diff.py
|
||||||
|
|
||||||
- name: Commit back
|
- name: Commit back
|
||||||
if: ${{ !github.head_ref }}
|
if: ${{ !github.head_ref }}
|
||||||
|
@ -29,6 +29,6 @@ print("processing gui_v1.py")
|
|||||||
process("gui_v1.py")
|
process("gui_v1.py")
|
||||||
|
|
||||||
# Save as a JSON file
|
# Save as a JSON file
|
||||||
with open("./i18n/zh_CN.json", "w", encoding="utf-8") as f:
|
with open("./lib/i18n/zh_CN.json", "w", encoding="utf-8") as f:
|
||||||
json.dump(data, f, ensure_ascii=False, indent=4)
|
json.dump(data, f, ensure_ascii=False, indent=4)
|
||||||
f.write("\n")
|
f.write("\n")
|
||||||
|
4
i18n.py
4
i18n.py
@ -4,7 +4,7 @@ import os
|
|||||||
|
|
||||||
|
|
||||||
def load_language_list(language):
|
def load_language_list(language):
|
||||||
with open(f"./i18n/{language}.json", "r", encoding="utf-8") as f:
|
with open(f"./lib/i18n/{language}.json", "r", encoding="utf-8") as f:
|
||||||
language_list = json.load(f)
|
language_list = json.load(f)
|
||||||
return language_list
|
return language_list
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ class I18nAuto:
|
|||||||
language = locale.getdefaultlocale()[
|
language = locale.getdefaultlocale()[
|
||||||
0
|
0
|
||||||
] # getlocale can't identify the system's language ((None, None))
|
] # getlocale can't identify the system's language ((None, None))
|
||||||
if not os.path.exists(f"./i18n/{language}.json"):
|
if not os.path.exists(f"./lib/i18n/{language}.json"):
|
||||||
language = "en_US"
|
language = "en_US"
|
||||||
self.language = language
|
self.language = language
|
||||||
# print("Use Language:", language)
|
# print("Use Language:", language)
|
||||||
|
Loading…
Reference in New Issue
Block a user