From 4a459574ada4b4ea1b356f0814df356bf994b4a9 Mon Sep 17 00:00:00 2001 From: Pin Studios Date: Wed, 30 Apr 2025 17:09:53 +0800 Subject: [PATCH] Enhance TempMailPlus integration by adding translator support for internationalization, improving error messages, and updating the email tab interface documentation. Additionally, update localization files for multiple languages to include new translation keys related to email verification processes. --- cursor_register_manual.py | 2 +- email_tabs/email_tab_interface.py | 8 +++---- email_tabs/tempmail_plus_tab.py | 38 +++++++++++++++++++------------ locales/ar.json | 12 ++++++++++ locales/bg.json | 12 ++++++++++ locales/de.json | 12 ++++++++++ locales/en.json | 12 ++++++++++ locales/es.json | 12 ++++++++++ locales/fr.json | 12 ++++++++++ locales/it.json | 12 ++++++++++ locales/ja.json | 12 ++++++++++ locales/nl.json | 12 ++++++++++ locales/pt.json | 12 ++++++++++ locales/ru.json | 12 ++++++++++ locales/tr.json | 12 ++++++++++ locales/vi.json | 12 ++++++++++ locales/zh_cn.json | 12 ++++++++++ locales/zh_tw.json | 12 ++++++++++ 18 files changed, 209 insertions(+), 19 deletions(-) diff --git a/cursor_register_manual.py b/cursor_register_manual.py index 8dce3b1..2e2ddda 100644 --- a/cursor_register_manual.py +++ b/cursor_register_manual.py @@ -112,7 +112,7 @@ class CursorRegistration: epin = config.get('TempMailPlus', 'epin') if email and epin: from email_tabs.tempmail_plus_tab import TempMailPlusTab - email_tab = TempMailPlusTab(email, epin) + email_tab = TempMailPlusTab(email, epin, self.translator) print(f"{Fore.CYAN}{EMOJI['MAIL']} {self.translator.get('register.using_tempmail_plus')}{Style.RESET_ALL}") # Use new_signup.py directly for registration diff --git a/email_tabs/email_tab_interface.py b/email_tabs/email_tab_interface.py index d80f0a1..20ce9e0 100644 --- a/email_tabs/email_tab_interface.py +++ b/email_tabs/email_tab_interface.py @@ -1,7 +1,7 @@ from abc import ABC, abstractmethod class EmailTabInterface(ABC): - """Email tab interface for handling email verification""" + """Interface for email tab implementations""" @abstractmethod def refresh_inbox(self) -> None: @@ -10,10 +10,10 @@ class EmailTabInterface(ABC): @abstractmethod def check_for_cursor_email(self) -> bool: - """Check if there is a verification email from Cursor + """Check if there is a new email from Cursor Returns: - bool: True if verification email exists, False otherwise + bool: True if new email found, False otherwise """ pass @@ -22,6 +22,6 @@ class EmailTabInterface(ABC): """Get the verification code from the email Returns: - str: The verification code if found, empty string otherwise + str: The verification code if available, empty string otherwise """ pass diff --git a/email_tabs/tempmail_plus_tab.py b/email_tabs/tempmail_plus_tab.py index 81b556d..69efc41 100644 --- a/email_tabs/tempmail_plus_tab.py +++ b/email_tabs/tempmail_plus_tab.py @@ -7,15 +7,17 @@ from .email_tab_interface import EmailTabInterface class TempMailPlusTab(EmailTabInterface): """Implementation of EmailTabInterface for tempmail.plus""" - def __init__(self, email: str, epin: str): + def __init__(self, email: str, epin: str, translator=None): """Initialize TempMailPlusTab Args: email: The email address to check epin: The epin token for authentication + translator: Optional translator for internationalization """ self.email = email self.epin = epin + self.translator = translator self.base_url = "https://tempmail.plus/api" self.headers = { 'accept': 'application/json', @@ -72,7 +74,7 @@ class TempMailPlusTab(EmailTabInterface): return True return False except Exception as e: - print(f"检查新邮件失败: {str(e)}") + print(f"{self.translator.get('tempmail.check_email_failed', error=str(e)) if self.translator else f'Check email failed: {str(e)}'}") return False def _extract_verification_code(self) -> str: @@ -114,7 +116,7 @@ class TempMailPlusTab(EmailTabInterface): return "" except Exception as e: - print(f"提取验证码失败: {str(e)}") + print(f"{self.translator.get('tempmail.extract_code_failed', error=str(e)) if self.translator else f'Extract verification code failed: {str(e)}'}") return "" def get_verification_code(self) -> str: @@ -129,35 +131,43 @@ if __name__ == "__main__": import os import time import sys + import configparser from config import get_config - config = get_config() + # 尝试导入 translator + try: + from main import Translator + translator = Translator() + except ImportError: + translator = None + + config = get_config(translator) try: email = config.get('TempMailPlus', 'email') epin = config.get('TempMailPlus', 'epin') - print(f"配置的邮箱: {email}") + print(f"{translator.get('tempmail.configured_email', email=email) if translator else f'Configured email: {email}'}") - # 初始化TempMailPlusTab - mail_tab = TempMailPlusTab(email, epin) + # 初始化TempMailPlusTab,传递 translator + mail_tab = TempMailPlusTab(email, epin, translator) # 检查是否有Cursor的邮件 - print("正在检查Cursor验证邮件...") + print(f"{translator.get('tempmail.checking_email') if translator else 'Checking for Cursor verification email...'}") if mail_tab.check_for_cursor_email(): - print("找到Cursor验证邮件") + print(f"{translator.get('tempmail.email_found') if translator else 'Found Cursor verification email'}") # 获取验证码 verification_code = mail_tab.get_verification_code() if verification_code: - print(f"获取到的验证码: {verification_code}") + print(f"{translator.get('tempmail.verification_code', code=verification_code) if translator else f'Verification code: {verification_code}'}") else: - print("未能获取到验证码") + print(f"{translator.get('tempmail.no_code') if translator else 'Could not get verification code'}") else: - print("未找到Cursor验证邮件") + print(f"{translator.get('tempmail.no_email') if translator else 'No Cursor verification email found'}") except configparser.Error as e: - print(f"读取配置文件错误: {str(e)}") + print(f"{translator.get('tempmail.config_error', error=str(e)) if translator else f'Config file error: {str(e)}'}") except Exception as e: - print(f"发生错误: {str(e)}") \ No newline at end of file + print(f"{translator.get('tempmail.general_error', error=str(e)) if translator else f'An error occurred: {str(e)}'}") \ No newline at end of file diff --git a/locales/ar.json b/locales/ar.json index dd9429b..88da798 100644 --- a/locales/ar.json +++ b/locales/ar.json @@ -850,5 +850,17 @@ "updating_database": "تحديث قاعدة بيانات مصادقة المؤشر ...", "title": "مصادقة المؤشر اليدوي", "auth_update_failed": "فشل في تحديث معلومات المصادقة" + }, + "tempmail": { + "config_error": "خطأ في ملف التكوين: {error}", + "no_email": "لم يتم العثور على بريد إلكتروني للتحقق من المؤشر", + "general_error": "حدث خطأ: {error}", + "checking_email": "التحقق من البريد الإلكتروني للتحقق من المؤشر ...", + "extract_code_failed": "فشل استخراج رمز التحقق: {error}", + "configured_email": "البريد الإلكتروني المكون: {البريد الإلكتروني}", + "check_email_failed": "فشل التحقق من البريد الإلكتروني: {error}", + "no_code": "لا يمكن الحصول على رمز التحقق", + "email_found": "تم العثور على البريد الإلكتروني للتحقق من المؤشر", + "verification_code": "رمز التحقق: {code}" } } \ No newline at end of file diff --git a/locales/bg.json b/locales/bg.json index 585a0de..1d3a596 100644 --- a/locales/bg.json +++ b/locales/bg.json @@ -863,5 +863,17 @@ "auth_update_failed": "Неуспешно актуализиране на информацията за удостоверяване", "title": "Ръчно удостоверяване на курсора", "updating_database": "Актуализиране на базата данни за удостоверяване на курсора ..." + }, + "tempmail": { + "no_email": "Не е намерен имейл за проверка на курсора", + "config_error": "Грешка в конфигурацията на файла: {грешка}", + "general_error": "Възникна грешка: {грешка}", + "configured_email": "Конфигуриран имейл: {имейл}", + "extract_code_failed": "Кодът за проверка на екстракт не успя: {Грешка}", + "checking_email": "Проверка за имейл за проверка на курсора ...", + "no_code": "Не можа да получи код за проверка", + "email_found": "Намерен имейл за проверка на курсора", + "check_email_failed": "Проверете имейла не е успешен: {Грешка}", + "verification_code": "Код за проверка: {код}" } } \ No newline at end of file diff --git a/locales/de.json b/locales/de.json index 064345b..4eb5ceb 100644 --- a/locales/de.json +++ b/locales/de.json @@ -862,5 +862,17 @@ "description": "Dieses Tool modifiziert die Datei workbench.desktop.main.js, um die Token -Grenze zu umgehen", "press_enter": "Drücken Sie die Eingabetaste, um fortzufahren ...", "title": "Bypass Token Limit Tool" + }, + "tempmail": { + "no_email": "Keine Cursorüberprüfungs -E -Mail gefunden", + "general_error": "Es ist ein Fehler aufgetreten: {Fehler}", + "config_error": "Konfigurationsdateifehler: {Fehler}", + "checking_email": "Überprüfung nach Cursor -Überprüfungs -E -Mail ...", + "extract_code_failed": "Verifizierungscode extrahieren fehlgeschlagen: {Fehler}", + "configured_email": "Konfigurierte E -Mail: {E -Mail}", + "no_code": "Konnte keinen Bestätigungscode erhalten", + "check_email_failed": "Überprüfen Sie die E -Mail fehlgeschlagen: {Fehler}", + "email_found": "Gefundene Cursor -Überprüfungs -E -Mail gefunden", + "verification_code": "Überprüfungscode: {Code}" } } \ No newline at end of file diff --git a/locales/en.json b/locales/en.json index 4fd7507..87fbc49 100644 --- a/locales/en.json +++ b/locales/en.json @@ -850,5 +850,17 @@ "auth_updated_successfully": "Authentication information updated successfully!", "auth_update_failed": "Failed to update authentication information", "error": "Error: {error}" + }, + "tempmail": { + "check_email_failed": "Check email failed: {error}", + "extract_code_failed": "Extract verification code failed: {error}", + "configured_email": "Configured email: {email}", + "checking_email": "Checking for Cursor verification email...", + "email_found": "Found Cursor verification email", + "verification_code": "Verification code: {code}", + "no_code": "Could not get verification code", + "no_email": "No Cursor verification email found", + "config_error": "Config file error: {error}", + "general_error": "An error occurred: {error}" } } \ No newline at end of file diff --git a/locales/es.json b/locales/es.json index a39f181..faab22a 100644 --- a/locales/es.json +++ b/locales/es.json @@ -862,5 +862,17 @@ "description": "Esta herramienta modifica el archivo workbench.desktop.main.js para evitar el límite del token", "press_enter": "Presione Entrar para continuar ...", "title": "Herramienta de límite de token de derivación" + }, + "tempmail": { + "general_error": "Se produjo un error: {error}", + "config_error": "Error de archivo de configuración: {error}", + "no_email": "No se encuentra el correo electrónico de verificación del cursor", + "checking_email": "Comprobación del correo electrónico de verificación del cursor ...", + "configured_email": "Correo electrónico configurado: {correo electrónico}", + "extract_code_failed": "Extraer el código de verificación fallido: {error}", + "no_code": "No pudo obtener el código de verificación", + "check_email_failed": "Verifique el correo electrónico fallido: {error}", + "email_found": "Correo electrónico de verificación del cursor encontrado", + "verification_code": "Código de verificación: {código}" } } \ No newline at end of file diff --git a/locales/fr.json b/locales/fr.json index a51e2c5..5337c20 100644 --- a/locales/fr.json +++ b/locales/fr.json @@ -862,5 +862,17 @@ "description": "Cet outil modifie le fichier workbench.desktop.main.js pour contourner la limite de jeton", "press_enter": "Appuyez sur Entrée pour continuer ...", "title": "Outil de limite de jeton de contournement" + }, + "tempmail": { + "no_email": "Aucun e-mail de vérification du curseur trouvé", + "general_error": "Une erreur s'est produite: {erreur}", + "config_error": "Erreur de fichier de configuration: {erreur}", + "configured_email": "Email configuré: {e-mail}", + "extract_code_failed": "Extraire le code de vérification a échoué: {error}", + "checking_email": "Vérification du courrier électronique de vérification du curseur ...", + "email_found": "Email de vérification du curseur trouvé", + "no_code": "Impossible d'obtenir le code de vérification", + "check_email_failed": "Vérifier l'échec de l'e-mail: {Erreur}", + "verification_code": "Code de vérification: {code}" } } \ No newline at end of file diff --git a/locales/it.json b/locales/it.json index 2b0af0b..7f703aa 100644 --- a/locales/it.json +++ b/locales/it.json @@ -850,5 +850,17 @@ "description": "Questo strumento modifica il file workbench.desktop.main.js per bypassare il limite token", "press_enter": "Premere Invio per continuare ...", "title": "Strumento di limite di bypass token" + }, + "tempmail": { + "config_error": "Errore del file di configurazione: {errore}", + "no_email": "Nessuna e -mail di verifica del cursore trovato", + "general_error": "Si è verificato un errore: {errore}", + "extract_code_failed": "Extract Verifica Codice non riuscito: {errore}", + "configured_email": "Email configurata: {email}", + "no_code": "Impossibile ottenere il codice di verifica", + "checking_email": "Verificare la verifica della verifica del cursore ...", + "check_email_failed": "Controlla l'e -mail non riuscita: {errore}", + "email_found": "Email di verifica del cursore trovato", + "verification_code": "Codice di verifica: {codice}" } } \ No newline at end of file diff --git a/locales/ja.json b/locales/ja.json index b40bc2c..70ac73b 100644 --- a/locales/ja.json +++ b/locales/ja.json @@ -850,5 +850,17 @@ "title": "手動カーソル認証", "updating_database": "カーソル認証データベースの更新...", "auth_update_failed": "認証情報の更新に失敗しました" + }, + "tempmail": { + "general_error": "エラーが発生しました:{エラー}", + "no_email": "カーソル検証メールは見つかりません", + "config_error": "構成ファイルエラー:{エラー}", + "checking_email": "カーソル検証メールの確認...", + "extract_code_failed": "検証コードが失敗した抽出:{エラー}", + "configured_email": "構成された電子メール:{電子メール}", + "email_found": "カーソル検証メールが見つかりました", + "no_code": "確認コードを取得できませんでした", + "check_email_failed": "電子メールの失敗を確認する:{エラー}", + "verification_code": "検証コード:{code}" } } \ No newline at end of file diff --git a/locales/nl.json b/locales/nl.json index 534e25a..83184bb 100644 --- a/locales/nl.json +++ b/locales/nl.json @@ -862,5 +862,17 @@ "description": "Deze tool wijzigt het bestand Workbench.desktop.main.js om de tokenlimiet te omzeilen", "press_enter": "Druk op Enter om door te gaan ...", "title": "Omzeilen token limiet tool" + }, + "tempmail": { + "no_email": "Geen cursorverificatie -e -mail gevonden", + "general_error": "Er is een fout opgetreden: {error}", + "config_error": "Config -bestandsfout: {error}", + "checking_email": "Controleren op cursorverificatie -e -mail ...", + "extract_code_failed": "Extract Verificatiecode mislukt: {error}", + "configured_email": "Geconfigureerd e -mail: {e -mail}", + "no_code": "Kon geen verificatiecode krijgen", + "email_found": "Cursor Verificatie -e -mail gevonden", + "check_email_failed": "Controleer e -mail mislukt: {error}", + "verification_code": "Verificatiecode: {code}" } } \ No newline at end of file diff --git a/locales/pt.json b/locales/pt.json index c99261f..cb79d48 100644 --- a/locales/pt.json +++ b/locales/pt.json @@ -862,5 +862,17 @@ "description": "Esta ferramenta modifica o arquivo workbench.desktop.main.js para ignorar o limite do token", "press_enter": "Pressione Enter para continuar ...", "title": "Ipassue Token Limit Tool" + }, + "tempmail": { + "config_error": "Erro de arquivo de configuração: {erro}", + "general_error": "Ocorreu um erro: {erro}", + "no_email": "Nenhum e -mail de verificação do cursor encontrado", + "extract_code_failed": "Código de verificação de extração falhou: {erro}", + "checking_email": "Verificando o e -mail de verificação do cursor ...", + "configured_email": "Email configurado: {email}", + "no_code": "Não foi possível obter o código de verificação", + "check_email_failed": "Verifique o e -mail falhado: {erro}", + "verification_code": "Código de verificação: {code}", + "email_found": "E -mail de verificação do cursor encontrado" } } \ No newline at end of file diff --git a/locales/ru.json b/locales/ru.json index 5267751..9a341c0 100644 --- a/locales/ru.json +++ b/locales/ru.json @@ -862,5 +862,17 @@ "description": "Этот инструмент изменяет файл workbench.desktop.main.js, чтобы обойти предел токена", "press_enter": "Нажмите Enter, чтобы продолжить ...", "title": "Инструмент ограничения обхода токена" + }, + "tempmail": { + "no_email": "Электронное письмо с проверкой курсора не найдено", + "config_error": "Ошибка файла конфигурации: {ошибка}", + "extract_code_failed": "Установка кода извлечения проверки: {ошибка}", + "general_error": "Произошла ошибка: {ошибка}", + "no_code": "Не удалось получить код проверки", + "checking_email": "Проверка на проверку курсора по электронной почте ...", + "configured_email": "Настройка электронной почты: {электронная почта}", + "check_email_failed": "Проверка по электронной почте не удастся: {ошибка}", + "verification_code": "Код проверки: {код}", + "email_found": "Найдено электронное письмо с проверкой курсора" } } \ No newline at end of file diff --git a/locales/tr.json b/locales/tr.json index 2c5cba7..3f4735d 100644 --- a/locales/tr.json +++ b/locales/tr.json @@ -862,5 +862,17 @@ "description": "Bu araç, jeton sınırını atlamak için workbench.desktop.main.js dosyasını değiştirir", "press_enter": "Devam etmek için Enter tuşuna basın ...", "title": "Baypas Token Limit Aracı" + }, + "tempmail": { + "general_error": "Bir hata oluştu: {hata}", + "no_email": "İmleç doğrulama e -postası bulunamadı", + "config_error": "Yapılandırma dosya hatası: {error}", + "extract_code_failed": "Çıkarma Doğrulama Kodu Başarısız: {Hata}", + "configured_email": "Yapılandırılmış e -posta: {e -posta}", + "checking_email": "İmleç doğrulama e -postasını kontrol etmek ...", + "check_email_failed": "E -postanın başarısız olduğunu kontrol edin: {hata}", + "no_code": "Doğrulama kodu alamadı", + "email_found": "İmleç doğrulama e -postası bulundu", + "verification_code": "Doğrulama kodu: {kod}" } } \ No newline at end of file diff --git a/locales/vi.json b/locales/vi.json index 9ca14f6..ff1c7a0 100644 --- a/locales/vi.json +++ b/locales/vi.json @@ -863,5 +863,17 @@ "profile": "Hồ sơ {Number}", "profile_list": "Có sẵn {trình duyệt} Hồ sơ:", "invalid_selection": "Lựa chọn không hợp lệ. Hãy thử lại." + }, + "tempmail": { + "config_error": "Lỗi tệp cấu hình: {error}", + "general_error": "Đã xảy ra lỗi: {lỗi}", + "no_email": "Không tìm thấy email xác minh con trỏ", + "checking_email": "Kiểm tra email xác minh con trỏ ...", + "configured_email": "Email được định cấu hình: {email}", + "extract_code_failed": "Trích xuất mã xác minh không thành công: {error}", + "no_code": "Không thể nhận mã xác minh", + "check_email_failed": "Kiểm tra email không thành công: {lỗi}", + "email_found": "Tìm thấy email xác minh con trỏ", + "verification_code": "Mã xác minh: {code}" } } \ No newline at end of file diff --git a/locales/zh_cn.json b/locales/zh_cn.json index 2bb5195..3af643f 100644 --- a/locales/zh_cn.json +++ b/locales/zh_cn.json @@ -854,5 +854,17 @@ "title": "手动Cursor身份验证", "token_verified": "令牌成功验证了!", "updating_database": "更新Cursor身份验证数据库..." + }, + "tempmail": { + "general_error": "发生错误:{error}", + "no_email": "找不到Cursor验证电子邮件", + "configured_email": "配置的电子邮件:{email}", + "config_error": "配置文件错误:{error}", + "extract_code_failed": "提取验证代码失败:{error}", + "no_code": "无法获得验证代码", + "check_email_failed": "检查电子邮件失败:{error}", + "checking_email": "检查Cursor验证电子邮件...", + "email_found": "找到Cursor验证电子邮件", + "verification_code": "验证代码:{code}" } } \ No newline at end of file diff --git a/locales/zh_tw.json b/locales/zh_tw.json index 14ef2d5..fe642d2 100644 --- a/locales/zh_tw.json +++ b/locales/zh_tw.json @@ -869,5 +869,17 @@ "title": "手動Cursor身份驗證", "updating_database": "更新Cursor身份驗證數據庫...", "auth_update_failed": "無法更新身份驗證信息" + }, + "tempmail": { + "general_error": "發生錯誤:{error}", + "config_error": "配置文件錯誤:{error}", + "no_email": "找不到Cursor驗證電子郵件", + "checking_email": "檢查Cursor驗證電子郵件...", + "extract_code_failed": "提取驗證代碼失敗:{error}", + "configured_email": "配置的電子郵件:{email}", + "no_code": "無法獲得驗證代碼", + "check_email_failed": "檢查電子郵件失敗:{error}", + "email_found": "找到Cursor驗證電子郵件", + "verification_code": "驗證代碼:{code}" } } \ No newline at end of file