Skip to content

Share locales between editor-ui and source - #1562

Merged
abcampo-iry merged 6 commits into
mainfrom
issues/1629
Jul 31, 2026
Merged

Share locales between editor-ui and source#1562
abcampo-iry merged 6 commits into
mainfrom
issues/1629

Conversation

@abcampo-iry

@abcampo-iry abcampo-iry commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

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:

  • ga-IE → ga
  • es-LA → es-419
  • fr-FR → fr

@abcampo-iry
abcampo-iry temporarily deployed to previews/1562/merge July 30, 2026 08:14 — with GitHub Actions Inactive

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 locale from WebComponentLoaderWebComponentProjectProjectScratchContainer, adding it to the Scratch iframe URL query string.
  • Add Scratch-frame locale normalization via toScratchLocale() (with mappings like es-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.

Comment thread apps/scratch-frame/src/utils/scratchLocale.js

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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 using default effort and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread apps/scratch-frame/src/ScratchIntegrationHOC.jsx Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 src with new URL(...) without providing a base URL. If REACT_APP_SCRATCH_FRAME_URL is unset (or the src is ever relative), new URL() will throw TypeError: 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 an auth top-level option here; this auth: { user } entry is ignored and can mislead future readers. The auth slice is already initialized by the auth reducer’s default state above.
      },
      auth: { user },
    });

@abcampo-iry
abcampo-iry temporarily deployed to previews/1562/merge July 30, 2026 11:20 — with GitHub Actions Inactive

@cocomarine cocomarine left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🌟

@abcampo-iry
abcampo-iry merged commit 7726a90 into main Jul 31, 2026
9 checks passed
@abcampo-iry
abcampo-iry deleted the issues/1629 branch July 31, 2026 09:20
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.

3 participants