mirror of
https://github.com/JoeanAmier/XHS-Downloader.git
synced 2025-12-26 04:48:05 +08:00
perf(translate.py): 更新项目翻译模块
This commit is contained in:
parent
63c8a9e325
commit
2d8d6781e6
@ -3,6 +3,8 @@ from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent.parent
|
||||
|
||||
from locale import getlocale
|
||||
|
||||
|
||||
class TranslationManager:
|
||||
"""管理gettext翻译的类"""
|
||||
@ -19,7 +21,13 @@ class TranslationManager:
|
||||
if not localedir:
|
||||
localedir = ROOT.joinpath('locale')
|
||||
self.localedir = Path(localedir)
|
||||
self.current_translator = self.setup_translation()
|
||||
self.current_translator = self.setup_translation(self.get_language_code())
|
||||
|
||||
@staticmethod
|
||||
def get_language_code() -> str:
|
||||
# 获取当前系统的语言和区域设置
|
||||
language_code, __ = getlocale()
|
||||
return "zh_CN" if "Chinese" in language_code else "en_US"
|
||||
|
||||
def setup_translation(self, language: str = "zh_CN"):
|
||||
"""设置gettext翻译环境"""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user