Skip to content

fix(i18n): stop React Compiler freezing strings after a language switch - #1127

Merged
RonenMars merged 1 commit into
mainfrom
fix/i18n-stale-strings-react-compiler
Sep 19, 2026
Merged

RonenMars merged 1 commit into
mainfrom
fix/i18n-stale-strings-react-compiler

Conversation

@RonenMars

Copy link
Copy Markdown
Owner

After switching the app language in Settings, part of the previous language stayed on screen until the screen was left and re-opened.
"+ Добавить сервер" and "Состояние сервера" stayed Russian after switching to English and Hebrew.

React Compiler is enabled (app.json), and it memoizes i18n.t('literal') calls in render because their only inputs are a module import and a string literal.
Those strings therefore never re-rendered on languageChanged, while strings using the useTranslation t updated correctly.

This switches the render-time i18n.t(...) calls in app/settings.tsx and the root stack header titles in app/_layout.tsx to the hook's t.
The useTranslation namespace lists are widened to include servers and feedback.
i18n.t calls inside event handlers and the error-boundary classes are unchanged, since they read the language at call time and are not compiled.

Checks

  • tsc and eslint are clean on both files.
  • npm run test:i18n passes.
  • __tests__/e2e/settings-flow.test.tsx passes alone (22/22); it timed out once in a batch run, which is the known load artifact.

Not yet verified

  • On-device check: switch Russian, then English, then Hebrew in Settings, and confirm no string keeps the previous language.

@vercel

vercel Bot commented Sep 19, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
threadbase-web Ignored Ignored Sep 19, 2026 10:54pm UTC

Render-time i18n.t('literal') calls have no reactive inputs, so React Compiler memoizes them and they keep the previous language until the screen remounts.
Use the useTranslation t in Settings and the root stack header titles so they re-render on languageChanged.
@RonenMars
RonenMars force-pushed the fix/i18n-stale-strings-react-compiler branch from ddcccf4 to edcf2ce Compare September 19, 2026 22:54
@RonenMars
RonenMars merged commit 1e7bed9 into main Sep 19, 2026
25 checks passed
@RonenMars
RonenMars deleted the fix/i18n-stale-strings-react-compiler branch September 19, 2026 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant