Skip to content

fix(i18n): localize WebUI modal buttons and password validation errors#1917

Merged
piorpua merged 2 commits intomainfrom
fix/issue-1175
Mar 31, 2026
Merged

fix(i18n): localize WebUI modal buttons and password validation errors#1917
piorpua merged 2 commits intomainfrom
fix/issue-1175

Conversation

@kaizhou-lab
Copy link
Copy Markdown
Collaborator

Summary

  • AionModal default footer buttons now use useTranslation() for Cancel/Confirm labels instead of hardcoded English strings
  • AuthService.validatePasswordStrength returns machine-readable error codes (PASSWORD_TOO_SHORT, PASSWORD_TOO_LONG, PASSWORD_TOO_COMMON) instead of English sentences
  • WebuiModalContent translates backend error codes to localized messages, handling both single and semicolon-joined multiple codes
  • Added i18n keys (webui.passwordTooShort, webui.passwordTooLong, webui.passwordTooCommon) across all 6 locales: en-US, zh-CN, zh-TW, ja-JP, ko-KR, tr-TR

Related Issues

Closes #1175

Test Plan

  • Unit tests for AuthService.validatePasswordStrength error codes (5 tests, all passing)
  • Type check passes (tsc --noEmit)
  • Lint and format pass
  • Manual: Open WebUI settings in Chinese locale → modal buttons should show 取消/确定
  • Manual: Set a weak password → error message should appear in the current locale language

@piorpua
Copy link
Copy Markdown
Contributor

piorpua commented Mar 30, 2026

Code Review:fix(i18n): localize WebUI modal buttons and password validation errors (#1917)

变更概述

本 PR 将 WebUI 中硬编码的英文字符串替换为 i18n 国际化支持:(1) AionModal 默认 footer 按钮文案(Cancel/Confirm)改用 useTranslation() 获取本地化文本;(2) AuthService.validatePasswordStrength 返回机器可读的错误码(PASSWORD_TOO_SHORT 等)替代英文句子;(3) WebuiModalContent 前端将后端错误码翻译为本地化消息。涉及 6 个 locale 文件、后端服务、前端组件和新增单元测试。


方案评估

结论:✅ 方案合理

方案正确地将国际化关注点分离:后端返回语言无关的错误码,前端负责本地化展示,符合 i18n 最佳实践。AionModal 的改动利用了 common.cancel / common.confirm 已有的 i18n key,避免重复定义。错误码通过 '; ' 分隔符传递,与 WebuiService.changePassworderrors.join('; ') 一致,链路完整。


问题清单

未发现 CRITICAL、HIGH 或 MEDIUM 级别问题。


🔵 LOW — validateUsername 仍返回英文硬编码字符串

文件src/process/webserver/auth/service/AuthService.ts,第 445–449 行

问题说明validatePasswordStrength 已改为返回错误码,但同文件的 validateUsername 方法仍返回英文人类可读字符串(如 'Username must be at least 3 characters long')。虽不在本 PR 范围内,但为保持一致性建议后续统一处理。


汇总

# 严重级别 文件 问题
1 🔵 LOW AuthService.ts:445 validateUsername 仍返回英文硬编码字符串,与 validatePasswordStrength 风格不一致

结论

批准合并 — 方案合理,实现正确,测试覆盖充分。仅有一个 LOW 级别的一致性建议,不阻塞合并。


本报告由本地 pr-review skill 生成,包含完整项目上下文,无截断限制。

CONCLUSION: APPROVED
IS_CRITICAL_PATH: false
PR_NUMBER: 1917

@piorpua piorpua added bot:ci-waiting CI failed and author notified — snoozed until new commits are pushed and removed bot:reviewing Review in progress (mutex) labels Mar 30, 2026
- Add i18n to AionModal default footer buttons (Cancel/Confirm)
- Return error codes from AuthService.validatePasswordStrength instead of English strings
- Add frontend translation of backend password validation error codes
- Add i18n keys for all 6 locales (en-US, zh-CN, zh-TW, ja-JP, ko-KR, tr-TR)
- Add unit tests for password validation error codes
@piorpua piorpua added bot:reviewing Review in progress (mutex) and removed bot:ci-waiting CI failed and author notified — snoozed until new commits are pushed labels Mar 31, 2026
@piorpua
Copy link
Copy Markdown
Contributor

piorpua commented Mar 31, 2026

✅ 已自动 review,无阻塞性问题,正在触发自动合并。

@piorpua piorpua merged commit 8c5ba06 into main Mar 31, 2026
17 checks passed
@piorpua piorpua deleted the fix/issue-1175 branch March 31, 2026 07:15
@piorpua piorpua added bot:done Auto-merged by bot and removed bot:reviewing Review in progress (mutex) labels Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:done Auto-merged by bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

【Bug】WebUI 设置页多语言失效及 Tips 缺失防抖 / WebUI settings page language sync failed and Tips lack debouncing

2 participants