refactor(i18n): move updateLanguage to runtime as shared funtionality - #289
refactor(i18n): move updateLanguage to runtime as shared funtionality#289dcoa wants to merge 6 commits into
Conversation
|
Thanks for the pull request, @dcoa! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
a7923f1 to
93bf13e
Compare
…ang attribute in html
4b9b67f to
3432147
Compare
Description
The current PR aims to consolidate a reusable feature that enables updating the language preference across different UI components, ensuring consistent behavior.
What changes were implemented?
Moved the
updateSiteLanguagefunction fromshell/footertoruntime/i18n, making it reusable across any component in the site. For example, it can now be used by theLanguageMenuin the Footer and the Language Preference Selector in the Account App.Added two optional configuration properties to the i18n runtime:
defaultLanguage(string, default:'en'): Defines the fallback locale when a user's preferred locale is not supported. Open edX provides theLANGUAGE_CODEsetting to configure the platform's default language (for any non-English site), but this setting is not currently read by the client-side code. This property provides equivalent flexibility on the client side.supportedLanguages(string[], default:[]): Defines an allowlist of supported language codes. When non-empty, only these languages are displayed in the language picker and considered supported during locale resolution. An empty array means that all loaded locales are considered supported.Updated
handleRtl()to set both thelanganddirattributes on<html>. Previously, thelangattribute was not being updated. Updatinglangensures browsers, screen readers, and other accessibility tools correctly identify the page's language and provide appropriate language-specific behavior.Performs a optimistic UI update,
updateLocalechanges the UI, then the user preference and the cookie is updated via API.Displays a Toast message when the preference language API or user preference API fails.
How to test
test-sitei18nfolder to expose the translations (you can get support of AI). For example:defaultLanguageScreencast.from.2026-08-14.23-51-01.webm
Additional Information
LLM use
Supported by Opencode - Deepseek V4