Skip to content

fix(i18n): localize the required-field message when enabling two-factor auth#29780

Open
Sloppy0726 wants to merge 1 commit into
calcom:mainfrom
Sloppy0726:fix/localize-2fa-required-message
Open

fix(i18n): localize the required-field message when enabling two-factor auth#29780
Sloppy0726 wants to merge 1 commit into
calcom:mainfrom
Sloppy0726:fix/localize-2fa-required-message

Conversation

@Sloppy0726

@Sloppy0726 Sloppy0726 commented Jul 15, 2026

Copy link
Copy Markdown

What does this PR do?

Found this with Cal set to 繁體中文 on an English browser.

The enable-2FA dialog is translated the whole way through, t("incorrect_password"),
t("something_went_wrong") and the rest. Then you press Enter on an empty password field and the
browser answers in its own language: "Please fill out this field.", where the dialog around it says
此欄位為必填.

Enter is the path that matters here. That <form onSubmit={handleSetup}> holds the password input
and nothing else — Continue lives down in the footer, inside the other <Form>, and is disabled
until you type. A form with one field and no submit button of its own submits implicitly on Enter,
and InputField passes required down to the native input, so the message is the browser's to
render and it comes out in the browser's locale.

Fix sets the message in onInvalid and clears it in the existing onInput so a corrected field can
go valid again. field_required already exists and is already translated (zh-TW 此欄位為必填, ja
このフィールドは必須です, fr Ce champ est obligatoire), so there are no new strings and nothing
for lingo.dev.

Nothing else changes — still native validation, still blocks submit on the same field, handleSetup
untouched. Only the text differs.

Visual Demo

Nothing to screenshot. The bubble is browser chrome, drawn outside the page. So I read it off the
running app instead, on /settings/security/two-factor-auth, Cal on 繁體中文, browser on en-US,
driving the same submission path Enter takes:

const pw = document.querySelector('input[name="password"]');
pw.form.requestSubmit();
pw.validationMessage; // 此欄位為必填, was "Please fill out this field."
pw.validity.valid;    // false, still blocks submit
validationMessage
today Please fill out this field.
after 此欄位為必填

Submit stays blocked either way.

How should this be tested?

Nothing special to set up. Settings → Security → Two-factor auth, Cal on any non-English language,
click Enable, then press Enter with the password field empty. Clicking Continue won't show it — the
button is disabled until the field has a value.

Or yarn vitest run apps/web/components/settings/EnableTwoFactorModal.test.tsx.

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox. — N/A
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

The test needed one thing to run at all. vitest.config.mts resolves @lib and @calcom/web but
not @components, so nothing in apps/web that imports @components/... can be mounted in a test,
and this modal pulls in @components/auth/TwoFactor. Added the alias next to the others, same as
apps/web/tsconfig.json already has it. Happy to split that into its own PR if you'd rather keep
this one to the fix.

Typecheck passes. Typing into the field clears the message and it goes valid again, so nothing gets
stuck.

…or auth

Submitting the enable-2FA dialog with an empty password showed the browser's
own "Please fill out this field." in the browser's locale, not the one set in
Cal. Set the message in onInvalid and clear it in the existing onInput so a
corrected field can go valid again. field_required already exists and is
already translated, so there are no new strings.

Add a regression test, and the @components alias vitest needs to mount any
apps/web component that uses it.
@github-actions

Copy link
Copy Markdown
Contributor

Welcome to Cal.diy, @Sloppy0726! Thanks for opening this pull request.

A few things to keep in mind:

  • This is Cal.diy, not Cal.com. Cal.diy is a community-driven, fully open-source fork of Cal.com licensed under MIT. Your changes here will be part of Cal.diy — they will not be deployed to the Cal.com production app.
  • Please review our Contributing Guidelines if you haven't already.
  • Make sure your PR title follows the Conventional Commits format.

A maintainer will review your PR soon. Thanks for contributing!

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

An error occurred during the review process. Please try again later.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant