refactor(auth): merge the duplicate login form and localize the auth screens
Gitea Actions Runner Test / test-job (push) Successful in 1s
CI / check (push) Successful in 1m8s
CI / tests-integration (push) Successful in 1m53s
CI / tests-unit (push) Successful in 1m59s
CI / tests-ui (push) Successful in 2m42s
CI / preflight (push) Skipped
CI / deploy (push) Successful in 4m33s

`home-login-form.tsx` and `login-form.tsx` were two ~240-line near-identical
components. Delete the former and give `LoginForm` a `variant` prop:

- `variant="page"`   sr-only labels plus the register/forgot footer (/login)
- `variant="compact"` visible labels, no footer (homepage sidebar)

Field ids now come from `useId()`, so the two usages can never collide, and the
hardcoded "Show"/"Hide"/"Loading" strings are translated.

Localization of the login and register screens:

- `home-login-form.tsx` was entirely hardcoded English.
- `passwordStrength()` returned hardcoded "Weak"/"Fair"/"Good"/"Strong".
- `register.ts` returned only English strings. It now returns a
  locale-independent `code` next to the message, and the form renders
  `t(code)` with the English string as a fallback.
- Backfilled the new keys across all 25 locales, plus the login/register
  strings that were still English in most of them. `ar`, `fi` and `ja` had
  their entire login/register namespace in English and are now filled in.
  Locale parity stays at 0 missing keys, as `i18n:check` requires.

Copy that did not match the enforced rules: the UI advertised "min 8 chars"
(EN) / "min 6 tekens" (NL) while registration requires 12 characters plus an
uppercase, a lowercase, a digit and a special character. Corrected in every
locale. `password-reset.ts` enforced only 6 characters and is raised to 12 to
match registration.

Accessibility: `login-form.tsx` had no `<label>`, no `id` and no `required` on
any field. All three are now present, and error banners are announced with
`role="alert"`.

Adds `src/i18n/auth-messages.test.ts`, which asserts every `RegisterErrorCode`
resolves to a non-empty message in all 25 locales; verified it fails when a key
is removed. The existing register tests now also assert the error `code`.
This commit is contained in:
openhands committed 2026-10-04 18:50:23 +02:00
1 parent 3d828a61ab
commit 6bffc53779
33 files changed
+1756 -842

No files matched your search

+37 -6
View File
@@ -1015,7 +1015,11 @@
"errorCaptcha": "Captcha verification failed. Please try again.",
"whoIsOnline": "Who's online",
"newestCitizens": "Newest citizens",
"usersOnline": "{count} online"
"usersOnline": "{count} online",
"showPassword": "Show",
"hidePassword": "Hide",
"username": "Username",
"password": "Password"
},
"register": {
"title": "Create account",
@@ -1026,7 +1030,7 @@
"confirmPassword": "Repeat password",
"usernamePlaceholder": "Username",
"emailPlaceholder": "Email",
"passwordPlaceholder": "Password (min 8 chars)",
"passwordPlaceholder": "Password (min 12 chars)",
"confirmPasswordPlaceholder": "Repeat password",
"selectOutfit": "Select your outfit",
"termsAccept": "I am 18+ and accept the {hotel} terms & rules.",
@@ -1049,14 +1053,39 @@
"termsError": "You must accept the terms & rules to register.",
"usernameError": "Username is required.",
"emailError": "Valid email is required.",
"passwordError": "Password must be at least 6 characters.",
"passwordError": "Password must be at least 12 characters",
"confirmPasswordError": "Passwords do not match.",
"termsRequired": "You must accept the terms & rules.",
"usernameRequired": "Username is required.",
"emailRequired": "Email is required.",
"passwordRequired": "Password is required.",
"passwordsDontMatch": "Passwords do not match.",
"invitedBy": "Invited by {username}"
"invitedBy": "Invited by {username}",
"strengthWeak": "Weak",
"strengthFair": "Fair",
"strengthGood": "Good",
"strengthStrong": "Strong",
"passwordMinLength": "Password must be at least 12 characters",
"passwordUpper": "Password must contain at least one uppercase letter",
"passwordLower": "Password must contain at least one lowercase letter",
"passwordDigit": "Password must contain at least one digit",
"passwordSpecial": "Password must contain at least one special character",
"passwordMaxLength": "Password is too long",
"usernameMinLength": "Username must be at least 3 characters",
"usernameMaxLength": "Username must be at most 25 characters",
"usernamePattern": "Username may only contain letters, numbers, underscore and hyphen",
"usernameReserved": "This username is reserved",
"emailValid": "Enter a valid email address",
"emailDisposable": "Temporary email domains are not allowed",
"passwordsMatch": "Passwords do not match",
"usernameTaken": "That username is already taken",
"captchaFailed": "Captcha verification failed. Please try again.",
"rateLimited": "Too many sign-up attempts. Please wait a few minutes and try again.",
"vpnBlocked": "Registrations from VPN/proxy connections are not allowed.",
"maxAccountsPerIp": "You have reached the maximum number of accounts for your connection.",
"unavailable": "Registration is temporarily unavailable.",
"createFailed": "Could not create the account. Please try again or contact staff.",
"invalidInput": "Please check the highlighted fields and try again."
},
"forgot": {
"title": "Reset password",
@@ -1070,9 +1099,11 @@
"reset": {
"title": "Set a new password",
"subtitle": "Choose a strong password you don't use elsewhere.",
"passwordPlaceholder": "New password (min 6 chars)",
"passwordPlaceholder": "New password (min 12 chars)",
"resetPassword": "Reset password",
"backToLogin": "Back to login"
"backToLogin": "Back to login",
"passwordMinLength": "Password must be at least 12 characters",
"tooManyAttempts": "Too many attempts — try again later"
},
"verify": {
"verifiedTitle": "You're all set",