Add locale attribute instead of detecting language#1244
Merged
Conversation
loiswells97
temporarily deployed
to
previews/1244/merge
September 18, 2025 11:46 — with
GitHub Actions
Inactive
loiswells97
temporarily deployed
to
previews/1244/merge
September 18, 2025 14:30 — with
GitHub Actions
Inactive
loiswells97
temporarily deployed
to
previews/1244/merge
September 18, 2025 14:33 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the internationalization setup to use an explicit locale attribute instead of automatic browser language detection. This change provides more control over the language used in the web component.
- Remove i18next-browser-languagedetector dependency and related configuration
- Add locale attribute support to web component with default value of "en"
- Implement useEffect to set language via i18n.changeLanguage when locale changes
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/web-component.js | Adds "locale" to the observed attributes array |
| src/utils/i18n.js | Removes LanguageDetector import and configuration |
| src/containers/WebComponentLoader.jsx | Adds locale prop with default "en" and useEffect to change language |
| src/containers/WebComponentLoader.test.js | Adds mock for react-i18next and test for language setting |
| package.json | Removes i18next-browser-languagedetector dependency |
| CHANGELOG.md | Documents the feature change |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
loiswells97
temporarily deployed
to
previews/1244/merge
September 18, 2025 15:03 — with
GitHub Actions
Inactive
adrian-rpf
reviewed
Sep 18, 2025
adrian-rpf
left a comment
Contributor
There was a problem hiding this comment.
Good code and changes make sense.
readme.md for new attribute
Merged
loiswells97
added a commit
that referenced
this pull request
Sep 19, 2025
### Added - Ability to translate demo project instructions (#1230) - Translations (#1212) ### Changed - Improved status bar styling (#1221) - Added method to translate last saved time (#1223) - Deleting unused strings and components (#1225) - Determine locale from web component attribute instead of browser path (#1244) ### Fixed - CrowdIn issue for pluralised strings with no `one` version (#1234) - Update `imagePanel.gallery` string to remove Title Casing for consistency (#1238) - Update `imageUploadButton.uploadImage` string to remove Title Casing for consistency (#1238) - Fixed typo in the `en.json` translation file (#1241) ### Removed - Remove unused translation string `filePanel.images` (#1238)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Switches to determining the language from an attribute rather than detecting through
i81n. This maintains independence from the setup of the host page whilst allowing the web component to be consistent with the host in its choice of language.closes https://github.com/RaspberryPiFoundation/digital-editor-issues/issues/883