From 90e059af32f85ae492be6bf4de46f405a681a2b9 Mon Sep 17 00:00:00 2001 From: snowy Date: Fri, 5 Apr 2024 09:18:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- liteyuki/utils/language.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/liteyuki/utils/language.py b/liteyuki/utils/language.py index 8c7fa890..a69116f0 100644 --- a/liteyuki/utils/language.py +++ b/liteyuki/utils/language.py @@ -103,12 +103,10 @@ def load_from_dict(data: dict, lang_code: str): class Language: def __init__(self, lang_code: str = None, fallback_lang_code: str = None): - nonebot.logger.debug(_language_data) if lang_code is None: lang_code = config.get("default_language", get_default_lang()) self.lang_code = lang_code self.fallback_lang_code = fallback_lang_code - if self.fallback_lang_code is None: self.fallback_lang_code = config.get("default_language", get_system_lang_code()) @@ -129,8 +127,10 @@ class Language: try: if self.lang_code in _language_data and item in _language_data[self.lang_code]: return _language_data[self.lang_code][item].format(*args, **kwargs) + nonebot.logger.warning(f"Language text not found: {self.lang_code}.{item}") if self.fallback_lang_code in _language_data and item in _language_data[self.fallback_lang_code]: return _language_data[self.fallback_lang_code][item].format(*args, **kwargs) + nonebot.logger.warning(f"Language text not found in fallback language: {self.fallback_lang_code}.{item}") return default or item except Exception as e: nonebot.logger.error(f"Failed to get language text or format: {e}")