Repository navigation
Conversation
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait...
|
Review statusThanks for contributing. This comment tracks the review sequence and the next action. Current step: Required CI passed. Waiting for automated review of the latest commit. If automated review does not start, a maintainer must restart it. Review-state labels are managed by this workflow; do not edit them manually. |
a92c348 to
a3f60ad
Compare
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
bb168ef to
6f06052
Compare
Zoo-Code-Org#2122 (task rename) and Zoo-Code-Org#2160 (OpenCode Go temperature) added these baselines against the mocked toolkit; Zoo-Code-Org#2163 switched the gallery to the real VS Code toolkit without regenerating them. Rendered in the CI Playwright image (v1.62.1-noble). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
f386404 to
b1bf987
Compare
Related GitHub Issue
Closes: #2185
Description
Before this PR, the webview had three ways to get translations:
useAppTranslation,useTranslation, and a direct import ofimport {t} from "i18next". Some of them did not follow a language change, so text could keep the previous language. This PR fixes the UI language change problem and makes the webview use one approach with react-i18next. Then it removes the custom translation layer.The PR makes four changes:
Load translations at startup.
setup.tscallsloadTranslations()when the module loads. Before, a mount effect inTranslationProviderloaded them, so the first render could show raw keys.Apply the language directly. The new helper
applyLanguage()(webview-ui/src/i18n/language.ts) changes the i18next language. It does nothing if the language is already active. The"state"message handler inExtensionStateContextcalls it before the state is rendered. Thus components show the correct language from their first render.Use common rules for react-i18next. These rules prevent stale cached output:
tandi18nfromuseTranslation. Do not importtfromi18nextand do not calli18next.t.tto each<Trans>(<Trans t={t} ... />).tas an argument to helpers.formatLargeNumber,formatTimeAgo, andvalidateApiConfigurationnow taket.New ESLint rules in
webview-ui/eslint.config.mjsenforce these rules. The translation guides (.roo/rules-translate/001-general-rules.mdand.roo/skills/roo-translation/SKILL.md) describe them.Use one hook. All components use
useTranslationfromreact-i18next.useAppTranslationis no longer used.These changes make the translation harness simpler:
TranslationContext, its mock, and its test are deleted.TranslationContextstub and its Vite alias are deleted.createFixtureI18n()helper withI18nextProvider.react-i18next.For reviewers, please check these items with care:
applyLanguage()call in the"state"handler ofExtensionStateContext.tsx. This is now the only place where the language changes.targument inutils/format.tsandutils/validate.ts.useAppTranslationtouseTranslation,import { t } from "react-i18next"and direct usage ofttoconst { t } = useTranslation(), addingtproperty to every<Trans>component.Test Procedure
New unit tests:
webview-ui/src/i18n/__tests__/languageSwitch.spec.tsx: It changes the language fromentoeswithout a remount. PlainuseTranslation, namespaceduseTranslation, andTransconsumers all show the new language. The test consumers cache output ont, as React Compiler does. The test also checks thattis stable while the language does not change. It also checks that a namespacedtaccepts fully qualified keys.webview-ui/src/i18n/__tests__/hydrationLanguage.spec.tsx: Under StrictMode, components that hydration mounts show the hydrated language. It also testsapplyLanguage(). The helper changes to a different language. It does not emitlanguageChangedagain for the active language or for a missing language.format.spec.tsandvalidate.spec.tsnow passtto the helpers.To run the tests:
Manual test:
Pre-Submission Checklist
*.visual.tsxsnapshot inwebview-ui/. Seewebview-ui/AGENTS.md→ "When a UI change needs a snapshot".Videos (interaction / animation only)
Screen.Recording.2026-10-26.at.00.48.54.mov
Documentation Updates
Additional Notes
formatDatethat still usesi18ndirect import. Can we delete it or we can fix and reuse it, for example, in [TaskItemFooter] (https://github.com/rrewll/Zoo-Code/blob/2baac5e5b76018af2f1569450a70514b077a3748/webview-ui/src/components/history/TaskItemFooter.tsx#L48) to display date for the selected language/country?Get in Touch
GitHub: @rrewll
Discord: rorewillo