Просмотр исходного кода

Internationalize Advanced Authentication error messages and dropdown options

Co-authored-by: cadtoolbox <12723486+cadtoolbox@users.noreply.github.com>
copilot-swe-agent[bot] 3 месяцев назад
Родитель
Сommit
099896a3c6

+ 12 - 12
frontend/src/components/EmailSettings.tsx

@@ -54,7 +54,7 @@ export function EmailSettings() {
     onSuccess: () => {
       queryClient.invalidateQueries({ queryKey: ['smtpSettings'] });
       queryClient.invalidateQueries({ queryKey: ['advancedAuthStatus'] });
-      showToast('SMTP settings saved successfully', 'success');
+      showToast(t('settings.email.success.settingsSaved'), 'success');
     },
     onError: (error: Error) => {
       showToast(error.message, 'error');
@@ -88,12 +88,12 @@ export function EmailSettings() {
   const handleSave = () => {
     // Validate required fields
     if (!smtpSettings.smtp_host || !smtpSettings.smtp_from_email) {
-      showToast('Please fill in all required fields', 'error');
+      showToast(t('settings.email.errors.requiredFields'), 'error');
       return;
     }
     // Validate auth fields when authentication is enabled
     if (smtpSettings.smtp_auth_enabled && (!smtpSettings.smtp_username)) {
-      showToast('Username is required when authentication is enabled', 'error');
+      showToast(t('settings.email.errors.usernameRequired'), 'error');
       return;
     }
     saveMutation.mutate(smtpSettings);
@@ -101,16 +101,16 @@ export function EmailSettings() {
 
   const handleTest = () => {
     if (!testEmail) {
-      showToast('Please enter a test email address', 'error');
+      showToast(t('settings.email.errors.enterTestEmail'), 'error');
       return;
     }
     if (!smtpSettings.smtp_host || !smtpSettings.smtp_from_email) {
-      showToast('Please fill in SMTP Server and From Email before testing', 'error');
+      showToast(t('settings.email.errors.smtpServerAndEmail'), 'error');
       return;
     }
     // Validate auth fields when authentication is enabled
     if (smtpSettings.smtp_auth_enabled && (!smtpSettings.smtp_username || !smtpSettings.smtp_password)) {
-      showToast('Username and Password are required when authentication is enabled', 'error');
+      showToast(t('settings.email.errors.usernamePasswordRequired'), 'error');
       return;
     }
     testMutation.mutate({
@@ -127,7 +127,7 @@ export function EmailSettings() {
 
   const handleToggleAdvancedAuth = () => {
     if (!advancedAuthStatus?.advanced_auth_enabled && !advancedAuthStatus?.smtp_configured) {
-      showToast('Please configure and test SMTP settings first', 'error');
+      showToast(t('settings.email.errors.configureSmtpFirst'), 'error');
       return;
     }
     toggleAdvancedAuthMutation.mutate(!advancedAuthStatus?.advanced_auth_enabled);
@@ -189,9 +189,9 @@ export function EmailSettings() {
                   onChange={(e) => setSMTPSettings({ ...smtpSettings, smtp_security: e.target.value as 'starttls' | 'ssl' | 'none' })}
                   className="w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors"
                 >
-                  <option value="starttls">STARTTLS (Port 587)</option>
-                  <option value="ssl">SSL/TLS (Port 465)</option>
-                  <option value="none">None (Port 25)</option>
+                  <option value="starttls">{t('settings.email.securityOptions.starttls')}</option>
+                  <option value="ssl">{t('settings.email.securityOptions.ssl')}</option>
+                  <option value="none">{t('settings.email.securityOptions.none')}</option>
                 </select>
               </div>
               <div>
@@ -203,8 +203,8 @@ export function EmailSettings() {
                   onChange={(e) => setSMTPSettings({ ...smtpSettings, smtp_auth_enabled: e.target.value === 'true' })}
                   className="w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors"
                 >
-                  <option value="true">Enabled</option>
-                  <option value="false">Disabled</option>
+                  <option value="true">{t('settings.email.authOptions.enabled')}</option>
+                  <option value="false">{t('settings.email.authOptions.disabled')}</option>
                 </select>
               </div>
             </div>

+ 24 - 0
frontend/src/i18n/locales/de.ts

@@ -1030,6 +1030,30 @@ export default {
       feature2: 'Benutzer können sich mit Benutzername oder E-Mail anmelden',
       feature3: 'Passwort vergessen Funktion ist verfügbar',
       feature4: 'Administratoren können Benutzerpasswörter per E-Mail zurücksetzen',
+      // Error messages
+      errors: {
+        requiredFields: 'Bitte füllen Sie alle Pflichtfelder aus',
+        usernameRequired: 'Benutzername ist erforderlich, wenn Authentifizierung aktiviert ist',
+        enterTestEmail: 'Bitte geben Sie eine Test-E-Mail-Adresse ein',
+        smtpServerAndEmail: 'Bitte füllen Sie SMTP-Server und Absender-E-Mail aus, bevor Sie testen',
+        usernamePasswordRequired: 'Benutzername und Passwort sind erforderlich, wenn Authentifizierung aktiviert ist',
+        configureSmtpFirst: 'Bitte konfigurieren und testen Sie zuerst die SMTP-Einstellungen',
+      },
+      // Success messages
+      success: {
+        settingsSaved: 'SMTP-Einstellungen erfolgreich gespeichert',
+      },
+      // Security options
+      securityOptions: {
+        starttls: 'STARTTLS (Port 587)',
+        ssl: 'SSL/TLS (Port 465)',
+        none: 'Keine (Port 25)',
+      },
+      // Authentication options
+      authOptions: {
+        enabled: 'Aktiviert',
+        disabled: 'Deaktiviert',
+      },
     },
     appearance: 'Erscheinungsbild',
     notifications: 'Benachrichtigungen',

+ 24 - 0
frontend/src/i18n/locales/en.ts

@@ -1030,6 +1030,30 @@ export default {
       feature2: 'Users can login with username or email',
       feature3: 'Forgot password feature is available',
       feature4: 'Admins can reset user passwords via email',
+      // Error messages
+      errors: {
+        requiredFields: 'Please fill in all required fields',
+        usernameRequired: 'Username is required when authentication is enabled',
+        enterTestEmail: 'Please enter a test email address',
+        smtpServerAndEmail: 'Please fill in SMTP Server and From Email before testing',
+        usernamePasswordRequired: 'Username and Password are required when authentication is enabled',
+        configureSmtpFirst: 'Please configure and test SMTP settings first',
+      },
+      // Success messages
+      success: {
+        settingsSaved: 'SMTP settings saved successfully',
+      },
+      // Security options
+      securityOptions: {
+        starttls: 'STARTTLS (Port 587)',
+        ssl: 'SSL/TLS (Port 465)',
+        none: 'None (Port 25)',
+      },
+      // Authentication options
+      authOptions: {
+        enabled: 'Enabled',
+        disabled: 'Disabled',
+      },
     },
     appearance: 'Appearance',
     notifications: 'Notifications',

+ 24 - 0
frontend/src/i18n/locales/ja.ts

@@ -1182,6 +1182,30 @@ export default {
       feature2: 'ユーザーはユーザー名またはメールでログインできます',
       feature3: 'パスワード忘れ機能が利用可能です',
       feature4: '管理者はメールでユーザーパスワードをリセットできます',
+      // Error messages
+      errors: {
+        requiredFields: 'すべての必須フィールドに入力してください',
+        usernameRequired: '認証が有効な場合、ユーザー名は必須です',
+        enterTestEmail: 'テストメールアドレスを入力してください',
+        smtpServerAndEmail: 'テストする前にSMTPサーバーと送信元メールを入力してください',
+        usernamePasswordRequired: '認証が有効な場合、ユーザー名とパスワードは必須です',
+        configureSmtpFirst: '最初にSMTP設定を構成してテストしてください',
+      },
+      // Success messages
+      success: {
+        settingsSaved: 'SMTP設定を保存しました',
+      },
+      // Security options
+      securityOptions: {
+        starttls: 'STARTTLS (ポート 587)',
+        ssl: 'SSL/TLS (ポート 465)',
+        none: 'なし (ポート 25)',
+      },
+      // Authentication options
+      authOptions: {
+        enabled: '有効',
+        disabled: '無効',
+      },
     },
 
     // General - Date/Time