From 3543615a69f91e6182e3a389b50df4ad9c9c225d Mon Sep 17 00:00:00 2001 From: yeongpin Date: Tue, 25 Feb 2025 12:16:55 +0800 Subject: [PATCH] fix: Improve Windows Language Detection and Platform Compatibility - Correct Windows language detection method in Translator class - Update platform system check for Windows-specific imports - Refactor language detection to use platform-specific checks - Ensure more robust cross-platform language detection logic --- main.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index dfb0485..0c598f5 100644 --- a/main.py +++ b/main.py @@ -11,6 +11,7 @@ import platform # 只在 Windows 系统上导入 windll if platform.system() == 'Windows': import ctypes + # 只在 Windows 上导入 windll from ctypes import windll # 初始化colorama @@ -33,7 +34,7 @@ EMOJI = { class Translator: def __init__(self): self.translations = {} - self.current_language = self._detect_system_language() + self.current_language = self.detect_system_language() # 使用正确的方法名 self.fallback_language = 'en' # Fallback language if translation is missing self.load_translations() @@ -55,7 +56,7 @@ class Translator: """Detect language on Windows systems""" try: # 确保我们在 Windows 上 - if not hasattr(ctypes, 'windll'): + if platform.system() != 'Windows': return 'en' # 获取键盘布局