Instrument content on record, graph and upload pages stays in the previous language after switching interface language
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- react, typescript
- Domain
- frontend, internationalization
Research direction
Start with apps/web/src/hooks/useInstrument.ts:16-29 and the useInstrument test at apps/web/src/hooks/__tests__/useInstrument.test.ts; check how the hook interprets the bundle and responds to resolvedLanguage. Run the hook test, then verify the language-switch case in testing/src/specs/subject-detail.spec.ts. Done when instrument content updates to the selected language without leaving and reopening the page.
Written by the indexing model from the issue text.
Description
useInstrument translates the instrument once, in whatever language is active when its bundle loads, and never again. So pages built on it keep showing the instrument's title, field labels and measure labels in the old language after the user switches interface language. The effect calls translateInstrument(instrument, resolvedLanguage) but lists only instrumentBundleQuery.data as a dependency. A language change keeps the cached bundle, so the effect does not re-run. The rest of each page switches language, and the instrument-derived parts do not:
- the record view (
/datahub/subjects/$subjectId/table/$recordId,InstrumentSummary): title, question labels and measure labels; - the subject graph: the measure picker (
useMeasureOptions), while the instrument picker next to it, fed by the language-keyeduseInstrumentInfoQuery, switches; - the upload page heading ("Upload Data For <title>");
- the instrument title in the assignment details sheet on the subject's Assignments tab.
Where
apps/web/src/hooks/useInstrument.ts:16-29:
useEffect(() => {
if (instrumentBundleQuery.data) {
const { bundle, id } = instrumentBundleQuery.data;
interpreter
.interpret(bundle, { id, validate: import.meta.env.DEV })
.then((instrument) => setInstrument(translateInstrument(instrument, resolvedLanguage)))
// ...
}
}, [instrumentBundleQuery.data]);
Reproduce
- With the interface in English, open a subject's record for a bilingual (English/French) form instrument.
- Switch the interface language to French.
Actual: the navigation and page chrome switch to French, but the record's title, questions and measures stay in English until the page is left and reopened.
Expected: the instrument content switches to French along with the rest of the page.
Tests
apps/web/src/hooks/__tests__/useInstrument.test.ts: it('should retranslate the loaded instrument when the interface language changes'). Rerender with a different mocked resolvedLanguage and assert translateInstrument is called with the new language.
testing/src/specs/subject-detail.spec.ts: open a record, switch the language toggle, and assert the record title is shown in the new language.
Suggested fix
Keep the interpreted (multilingual) instrument in state, and derive the translated one with useMemo(() => instrument && translateInstrument(instrument, resolvedLanguage), [instrument, resolvedLanguage]). That way a language change only re-translates and does not re-interpret the bundle.
- Dominant language
- TypeScript
- Stars
- 119
- Forks
- 19
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 56
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from DouglasNeuroInformatics/OpenDataCapture
-
Area: Playground Bug Difficulty: Low Good First Issue Priority: Low
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
DouglasNeuroInformatics/OpenDataCapture#1805 ·
Maintainers usually reply within 1 day
-
Area: Instruments Bug Difficulty: Low Priority: Low
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
DouglasNeuroInformatics/OpenDataCapture#1801 ·
Maintainers usually reply within 1 day
-
Area: Instruments Bug Difficulty: Low Good First Issue Priority: Low
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
DouglasNeuroInformatics/OpenDataCapture#1800 ·
Maintainers usually reply within 1 day
-
Area: Instruments Bug Difficulty: Low Good First Issue Priority: Low
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
DouglasNeuroInformatics/OpenDataCapture#1799 ·
Maintainers usually reply within 1 day
-
Area: Instruments Bug Difficulty: Low Performance Priority: Medium
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
DouglasNeuroInformatics/OpenDataCapture#1795 ·
Maintainers usually reply within 1 day
All issues in DouglasNeuroInformatics/OpenDataCapture
Similar issues
-
[Feature]: [P3] engine-rs: the package source hash should ignore line endings and untracked filesOpen
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
maniator/verticopolis#880 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
siyuan-note/siyuan#20353 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
black-forest-labs/skills#17 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Albert-Weasker/niubigeo#168 ·
Maintainers usually reply within 1 day