From 9394aa62d4986eee8a4dfcf69dcfc6600a400ff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E7=91=97=E6=9D=B0?= <3695888@qq.com> Date: Fri, 22 Oct 2021 06:36:06 +0800 Subject: [PATCH] some update? --- Difficult_Rocket/api/translate.py | 22 +++++++++++----------- configs/logger.json5 | 6 +++--- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Difficult_Rocket/api/translate.py b/Difficult_Rocket/api/translate.py index 35db51e..c71b971 100644 --- a/Difficult_Rocket/api/translate.py +++ b/Difficult_Rocket/api/translate.py @@ -36,40 +36,40 @@ class Lang: """ def __init__(self, language: str = 'zh-CN'): - self.language = language + self.语言 = language self.翻译结果 = tools.load_file(f'configs/lang/{language}.json5') self.默认翻译 = tools.load_file('configs/lang/zh-CN.json5') def __str__(self) -> str: - return self.language + return self.语言 - def __getitem__(self, item): + def __getitem__(self, item) -> Union[int, str, list, dict]: try: return self.翻译结果[item] except KeyError: try: return self.默认翻译[item] except KeyError: - raise LanguageError(f'there\'s no key {item} in both {self.language} and zh-CN') + raise LanguageError(f'there\'s no key {item} in both {self.语言} and zh-CN') def __setitem__(self, key, value): if key == 'language' or key == 'lang': try: self.翻译结果 = tools.load_file(f'configs/lang/{value}.json5') - self.language = value + self.语言 = value except FileNotFoundError: raise LanguageError(f'{value}\'s language json5 file not found') else: raise NotImplementedError - def set_language(self, language): + def set_language(self, language) -> None: try: self.翻译结果 = tools.load_file(f'configs/lang/{language}.json5') - self.language = language + self.语言 = language except FileNotFoundError: raise LanguageError(f'{language}\'s language json5 file not found') - def lang(self, *args) -> Union[int, str, list]: + def lang(self, *args) -> Union[int, str, list, dict]: try: 结果 = self.翻译结果 for 选项 in args: @@ -82,10 +82,10 @@ class Lang: 结果 = 结果[选项] return 结果 except KeyError: - raise LanguageError(f'there\'s no key {args} in both {self.language} and zh-CN') + raise LanguageError(f'there\'s no key {args} in both {self.语言} and zh-CN') - def 翻译(self, *args): - self.lang(args) + def 翻译(self, *args) -> Union[int, str, list, dict]: + return self.lang(args) tr = Lang('zh-CN') diff --git a/configs/logger.json5 b/configs/logger.json5 index 1562af7..6fd3f07 100644 --- a/configs/logger.json5 +++ b/configs/logger.json5 @@ -35,15 +35,15 @@ }, 'loggers': { 'client': { -// 'level': 'DEBUG', + 'level': 'DEBUG', 'handlers': [] }, 'server': { -// 'level': 'DEBUG', + 'level': 'DEBUG', 'handlers': [] }, 'main': { -// 'level': 'DEBUG', + 'level': 'DEBUG', 'handlers': [] } },