1
0
mirror of synced 2025-01-19 17:28:42 +01:00
源文雨 33e1a0f1d2
fix: i18n导致无法启动 & 增加 --noautoopen 参数 (#39)
* optimize: 精简未用到的配置项并在特征提取初步引入mps

* add cmd argument: --noautoopen

* fix: i18n

* fix

* fix

* add genlocale workflow

* add unitest

* fix

* fix

* fix
2023-04-12 16:53:50 +08:00

21 lines
592 B
Python

import locale
import json
def load_language_list(language):
with open(f"./locale/{language}.json", "r", encoding="utf-8") as f:
language_list = json.load(f)
return language_list
class I18nAuto:
def __init__(self, language=None):
if language is None:
language = 'auto'
if language == 'auto':
language = locale.getdefaultlocale()[0]
self.language = language
print("Use Languane:", language)
self.language_map = load_language_list(language)
def __call__(self, key):
return self.language_map[key]