Share locales between editor-ui and source - #1562
Conversation
There was a problem hiding this comment.
Pull request overview
This PR propagates the host-selected locale (from the <editor-wc locale="..."> attribute / Raspberry Pi navigation) into the embedded Scratch editor iframe, and normalizes Raspberry Pi locale identifiers to Scratch-compatible locale codes inside the scratch-frame app.
Changes:
- Thread
localefromWebComponentLoader→WebComponentProject→Project→ScratchContainer, adding it to the Scratch iframe URL query string. - Add Scratch-frame locale normalization via
toScratchLocale()(with mappings likees-LA → es-419, and region-dropping fallbacks). - Add/adjust unit tests to verify locale propagation and normalization behavior.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/containers/WebComponentLoader.test.js | Updates Scratch remix-related test to assert locale is passed into the Scratch iframe URL. |
| src/containers/WebComponentLoader.jsx | Passes locale down to WebComponentProject. |
| src/components/WebComponentProject/WebComponentProject.jsx | Adds locale prop (default en) and forwards it to Project. |
| src/components/Editor/Project/Project.jsx | Accepts locale and forwards it to ScratchContainer when rendering Scratch projects. |
| src/components/Editor/Project/ScratchContainer.jsx | Accepts locale (default en) and appends it to the Scratch iframe URL query params. |
| src/components/Editor/Project/ScratchContainer.test.js | Adds a test ensuring the locale is included in the Scratch iframe URL. |
| apps/scratch-frame/src/utils/scratchLocale.js | Introduces locale normalization helper for Scratch locale identifiers. |
| apps/scratch-frame/src/utils/scratchLocale.test.js | Adds unit tests for locale normalization mappings and fallbacks. |
| apps/scratch-frame/src/scratch.jsx | Reads locale from query params and passes normalized locale to ScratchEditor. |
| apps/scratch-frame/src/scratch.test.js | Adds tests ensuring Scratch receives normalized locale via query param and preserves legacy dataset locale. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a589f14. Configure here.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
src/containers/WebComponentLoader.test.js:821
- This test parses the iframe
srcwithnew URL(...)without providing a base URL. IfREACT_APP_SCRATCH_FRAME_URLis unset (or thesrcis ever relative),new URL()will throwTypeError: Invalid URL, making the test environment-dependent.
const scratchIframe = await screen.findByTitle("Scratch");
const scratchUrl = new URL(scratchIframe.getAttribute("src"));
src/containers/WebComponentLoader.test.js:809
configureStore(RTK) does not use anauthtop-level option here; thisauth: { user }entry is ignored and can mislead future readers. The auth slice is already initialized by theauthreducer’s default state above.
},
auth: { user },
});

Closes: https://github.com/RaspberryPiFoundation/digital-editor-issues/issues/1629
Passes the locale selected in the external navigation through to the Scratch editor.
The locale is normalized to Scratch’s identifiers, including: