mirror of
https://github.com/yeongpin/cursor-free-vip.git
synced 2025-09-27 05:26:03 +08:00
refactor: Internationalize and Clean Up Code Comments
- Translate Chinese comments to English across multiple files - Improve code readability by using consistent, clear comments - Remove redundant comments and simplify language-specific annotations - Maintain existing code structure while enhancing internationalization
This commit is contained in:
@@ -32,7 +32,7 @@ def get_cursor_paths(translator=None) -> Tuple[str, str]:
|
||||
""" Get Cursor related paths"""
|
||||
system = platform.system()
|
||||
|
||||
# 讀取配置文件
|
||||
# Read config file
|
||||
config = configparser.ConfigParser()
|
||||
config_dir = os.path.join(get_user_documents_path(), ".cursor-free-vip")
|
||||
config_file = os.path.join(config_dir, "config.ini")
|
||||
@@ -40,9 +40,9 @@ def get_cursor_paths(translator=None) -> Tuple[str, str]:
|
||||
if not os.path.exists(config_file):
|
||||
raise OSError(translator.get('reset.config_not_found') if translator else "找不到配置文件")
|
||||
|
||||
config.read(config_file, encoding='utf-8') # 指定編碼
|
||||
config.read(config_file, encoding='utf-8') # Specify encoding
|
||||
|
||||
# 根據系統獲取路徑
|
||||
# Get path based on system
|
||||
if system == "Darwin":
|
||||
section = 'MacPaths'
|
||||
elif system == "Windows":
|
||||
@@ -63,7 +63,7 @@ def get_cursor_paths(translator=None) -> Tuple[str, str]:
|
||||
pkg_path = os.path.join(base_path, "package.json")
|
||||
main_path = os.path.join(base_path, "out/main.js")
|
||||
|
||||
# 檢查文件是否存在
|
||||
# Check if files exist
|
||||
if not os.path.exists(pkg_path):
|
||||
raise OSError(translator.get('reset.package_not_found', path=pkg_path) if translator else f"找不到 package.json: {pkg_path}")
|
||||
if not os.path.exists(main_path):
|
||||
@@ -187,7 +187,7 @@ def check_cursor_version(translator) -> bool:
|
||||
with open(pkg_path, "r", encoding="utf-8") as f:
|
||||
data = json.load(f)
|
||||
except UnicodeDecodeError:
|
||||
# 如果 UTF-8 讀取失敗,嘗試其他編碼
|
||||
# If UTF-8 reading fails, try other encodings
|
||||
with open(pkg_path, "r", encoding="latin-1") as f:
|
||||
data = json.load(f)
|
||||
|
||||
@@ -206,15 +206,15 @@ def check_cursor_version(translator) -> bool:
|
||||
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {translator.get('reset.found_version', version=version)}{Style.RESET_ALL}")
|
||||
|
||||
# 檢查版本格式
|
||||
# Check version format
|
||||
if not re.match(r"^\d+\.\d+\.\d+$", version):
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('reset.invalid_version_format', version=version)}{Style.RESET_ALL}")
|
||||
return False
|
||||
|
||||
# 比較版本
|
||||
# Compare versions
|
||||
try:
|
||||
current = tuple(map(int, version.split(".")))
|
||||
min_ver = (0, 45, 0) # 直接使用元組而不是字符串
|
||||
min_ver = (0, 45, 0) # Use tuple directly instead of string
|
||||
|
||||
if current >= min_ver:
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {translator.get('reset.version_check_passed', version=version, min_version='0.45.0')}{Style.RESET_ALL}")
|
||||
@@ -445,7 +445,7 @@ class MachineIDResetter:
|
||||
elif sys.platform == "linux": # Linux
|
||||
if not config.has_section('LinuxPaths'):
|
||||
config.add_section('LinuxPaths')
|
||||
# 获取实际用户的主目录
|
||||
# Get actual user's home directory
|
||||
sudo_user = os.environ.get('SUDO_USER')
|
||||
actual_home = f"/home/{sudo_user}" if sudo_user else os.path.expanduser("~")
|
||||
|
||||
|
Reference in New Issue
Block a user