refactor(auth): merge the duplicate login form and localize the auth screens

`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
2026-10-04 18:50:23 +02:00
parent 3d828a61ab
commit 6bffc53779
33 changed files with 1756 additions and 842 deletions
+94 -63
View File
@@ -6067,69 +6067,98 @@
"rateLimit": "Too many attempts. Please wait before trying again."
},
"login": {
"title": "Sign in",
"subtitle": "Welcome back — log in to enter the hotel.",
"subtitle2fa": "Enter the 6-digit code from your authenticator.",
"welcomeBack": "Welcome back",
"welcomeBackSub": "Sign in to continue to {hotelName}",
"usernamePlaceholder": "Username",
"passwordPlaceholder": "Password",
"codePlaceholder": "2FA code",
"pleaseWait": "Please wait…",
"verify": "Verify",
"signIn": "Sign in",
"or": "or",
"noAccount": "No account?",
"createOne": "Create one",
"forgotPassword": "Forgot password?",
"errorInvalidCredentials": "Invalid username or password",
"errorInvalid2fa": "Invalid 2FA code",
"errorUnverified": "Please verify your email before signing in.",
"errorCaptcha": "Captcha verification failed. Please try again.",
"whoIsOnline": "Who's online",
"newestCitizens": "Newest citizens",
"usersOnline": "{count} online"
"title": "ログイン",
"subtitle": "ログインして次のホテルへ進みましょう。",
"subtitle2fa": "認証アプリの6桁のコードを入力してください。",
"welcomeBack": "おかえりなさい",
"welcomeBackSub": "ログインして {hotelName} に参加しましょう",
"usernamePlaceholder": "ユーザー名",
"passwordPlaceholder": "パスワード",
"codePlaceholder": "2FAコードを入力",
"pleaseWait": "お待ちください...",
"verify": "確認",
"signIn": "ログイン",
"or": "または",
"noAccount": "アカウントをお持ちでない方",
"createOne": "アカウントを作成",
"forgotPassword": "パスワードをお忘れですか?",
"errorInvalidCredentials": "ユーザー名またはパスワードが違います",
"errorInvalid2fa": "2FAコードが正しくありません",
"errorUnverified": "ログインする前にメールアドレスを認証してください。",
"errorCaptcha": "認証コードの検証に失敗しました。再度お試しください。",
"whoIsOnline": "オンラインの人",
"newestCitizens": "最新の住民",
"usersOnline": "{count} 人がオンライン",
"username": "ユーザー名",
"password": "パスワード",
"showPassword": "表示",
"hidePassword": "非表示"
},
"register": {
"title": "Create account",
"subtitle": "Join the hotel — it only takes a moment.",
"username": "Username",
"email": "Email",
"password": "Password",
"confirmPassword": "Repeat password",
"usernamePlaceholder": "Username",
"emailPlaceholder": "Email",
"passwordPlaceholder": "Password (min 8 chars)",
"confirmPasswordPlaceholder": "Repeat password",
"selectOutfit": "Select your outfit",
"termsAccept": "I am 18+ and accept the {hotel} terms & rules.",
"accepted": "Accepted & agreed",
"showPassword": "Show",
"hidePassword": "Hide",
"accountDetails": "Account details",
"credentials": "Credentials & security",
"createAccount": "Create account",
"creatingAccount": "Creating account...",
"redirecting": "Redirecting to your account...",
"alreadyHaveAccount": "Already have an account? Login!",
"alreadyHaveAccountPre": "Already have an account?",
"alreadyHaveAccountLink": "Sign in",
"register": "Register",
"whoIsOnline": "Who's online",
"usersOnline": "{count} online",
"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.",
"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.",
"newestCitizens": "Newest citizens",
"ageVerified": "18歳以上です。年齢要件に同意します。",
"invitedBy": "{username} さんに招待されました"
"title": "アカウント作成",
"subtitle": "ホテルに参加しましょう — すぐに終わります。",
"username": "ユーザー名",
"email": "メールアドレス",
"password": "パスワード",
"confirmPassword": "パスワードの確認",
"usernamePlaceholder": "ユーザー名",
"emailPlaceholder": "メールアドレス",
"passwordPlaceholder": "パスワード(12文字以上)",
"confirmPasswordPlaceholder": "パスワードの確認",
"selectOutfit": "アバターを選んでスタイルを設定",
"termsAccept": "18歳以上であり、{hotel} の規約に同意します。",
"accepted": "承認して同意しました",
"showPassword": "表示",
"hidePassword": "非表示",
"accountDetails": "アカウント情報",
"credentials": "ログイン情報とセキュリティ",
"createAccount": "アカウントを作成",
"creatingAccount": "アカウントを作成中...",
"redirecting": "アカウント画面へ移動しています...",
"alreadyHaveAccount": "すでにアカウントをお持ちですか?ログインしましょう!",
"alreadyHaveAccountPre": "すでにアカウントをお持ちですか?",
"alreadyHaveAccountLink": "ログイン",
"register": "登録",
"whoIsOnline": "オンラインの人",
"usersOnline": "{count} 人がオンライン",
"termsError": "登録するには規約に同意する必要があります。",
"usernameError": "ユーザー名は必須です。",
"emailError": "有効なメールアドレスが必要です。",
"passwordError": "パスワードは12文字以上にしてください",
"confirmPasswordError": "パスワードが一致しません。",
"termsRequired": "規約に同意する必要があります。",
"usernameRequired": "ユーザー名は必須です。",
"emailRequired": "メールアドレスは必須です。",
"passwordRequired": "パスワードは必須です。",
"passwordsDontMatch": "パスワードが一致しません。",
"newestCitizens": "最新の住民",
"ageVerified": "18歳以上であり、年齢要件に同意します。",
"invitedBy": "{username} からの招待",
"strengthWeak": "弱",
"strengthFair": "普通",
"strengthGood": "良",
"strengthStrong": "強",
"passwordMinLength": "パスワードは12文字以上にしてください",
"passwordUpper": "パスワードには大文字を1文字以上含めてください",
"passwordLower": "パスワードには小文字を1文字以上含めてください",
"passwordDigit": "パスワードには数字を1文字以上含めてください",
"passwordSpecial": "パスワードには記号を1文字以上含めてください",
"passwordMaxLength": "パスワードが長すぎます",
"usernameMinLength": "ユーザー名は3文字以上にしてください",
"usernameMaxLength": "ユーザー名は25文字以内にしてください",
"usernamePattern": "ユーザー名には英数字・アンダースコア・ハイフンのみ使用できます",
"usernameReserved": "そのユーザー名は予約されています",
"emailValid": "有効なメールアドレスを入力してください",
"emailDisposable": "一時的なメールアドレスドメインは使用できません",
"passwordsMatch": "Passwords do not match.",
"captchaFailed": "認証コードの検証に失敗しました。再度お試しください。",
"usernameTaken": "そのユーザー名はすでに使用されています",
"rateLimited": "登録の試行が多すぎます。数分待ってから再度お試しください。",
"vpnBlocked": "VPN/プロキシ経由の登録は許可されていません。",
"maxAccountsPerIp": "この接続で作成できるアカウント数の上限に達しました。",
"unavailable": "現在、登録を一時停止しています。",
"createFailed": "アカウントを作成できませんでした。再度お試しいただくか、スタッフにご連絡ください。",
"invalidInput": "強調された項目を確認して、もう一度お試しください。"
},
"forgot": {
"title": "Reset password",
@@ -6143,9 +6172,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": "パスワードは12文字以上にしてください",
"tooManyAttempts": "試行回数が多すぎます — 後で再度お試しください"
},
"verify": {
"verifiedTitle": "You're all set",