Skip to content

i18n: add warning if falling back to default translation#8164

Merged
mimecuvalo merged 1 commit intomainfrom
mime/i18n-log-warn
Mar 5, 2026
Merged

i18n: add warning if falling back to default translation#8164
mimecuvalo merged 1 commit intomainfrom
mime/i18n-log-warn

Conversation

@mimecuvalo
Copy link
Copy Markdown
Member

@mimecuvalo mimecuvalo commented Mar 5, 2026

followup to #8011
tiny nit feedback from @MitjaBezensek

Change type

  • bugfix
  • improvement
  • feature
  • api
  • other

Note

Low Risk
Low risk: adds a console.warn when useTranslation cannot find translation messages, which may increase log noise but does not change translation lookup behavior.

Overview
useTranslation now emits a console.warn when no translation messages are present and it falls back to DEFAULT_TRANSLATION, making missing/incorrect translation provider setup more visible during development.

Written by Cursor Bugbot for commit cd95cda. This will update automatically on new commits. Configure here.

@huppy-bot huppy-bot bot added the other ⚙️ Changes that don't affect SDK users, e.g. internal or .com changes label Mar 5, 2026
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
examples Ready Ready Preview Mar 5, 2026 3:26pm
5 Skipped Deployments
Project Deployment Actions Updated (UTC)
analytics Ignored Ignored Mar 5, 2026 3:26pm
chat-template Ignored Ignored Mar 5, 2026 3:26pm
tldraw-docs Ignored Ignored Mar 5, 2026 3:26pm
tldraw-shader Ignored Ignored Mar 5, 2026 3:26pm
workflow-template Ignored Ignored Mar 5, 2026 3:26pm

Request Review

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

const messages = translation?.messages ?? DEFAULT_TRANSLATION
if (!translation?.messages) {
console.warn('No translation messages found, falling back to default translation.')
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Console warning fires on every render cycle

Medium Severity

The console.warn is placed directly in the render body of the useTranslation hook rather than inside a useEffect. This means it fires on every single render of every component calling useTranslation() when the fallback condition is met. Given this hook is used in many components across the codebase, this will spam the console with repeated warnings on each re-render, making it noisy and potentially impacting dev-mode performance.

Fix in Cursor Fix in Web

@mimecuvalo mimecuvalo added this pull request to the merge queue Mar 5, 2026
Merged via the queue into main with commit 6c1cd68 Mar 5, 2026
25 checks passed
@mimecuvalo mimecuvalo deleted the mime/i18n-log-warn branch March 5, 2026 15:36
github-merge-queue bot pushed a commit that referenced this pull request Mar 5, 2026
bah, whoops, followup again
#8164 (review)

### Change type

- [ ] `bugfix`
- [ ] `improvement`
- [ ] `feature`
- [ ] `api`
- [x] `other`

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Low risk: only changes when the fallback `console.warn` fires, moving
it out of render and preventing repeated warnings on re-renders.
> 
> **Overview**
> Moves the "falling back to default translation" warning in
`useTranslation` from render-time to a `useEffect` keyed on
`translation?.messages`, so the warning only emits when messages are
missing (or change to missing) rather than on every render.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
87ae187. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

other ⚙️ Changes that don't affect SDK users, e.g. internal or .com changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant