- 
                Notifications
    You must be signed in to change notification settings 
- Fork 357
[website] Add support to internationalization #2823
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for making this, @fellyph!
After visually scanning this PR and reminding myself how various bits work around i18n, I think this looks pretty good overall. I have one question and one comment.
How will we extract new strings for translation when the UI is updated? There is a WP-CLI command for helping with these things, but for Playground which uses Node.js-based tooling, maybe a package like node-gettext would be more appropriate. Either way, I think we should add scripts for extracting these strings as part of this PR. (maybe I even missed that there are already such scripts)
On the treatment of individual strings:
AFAICT, the __() is mostly (or maybe entirely?) what is used in this PR, but I suspect translators will find many of the strings ambiguous or unclear without additional context provided by something like _x() or /* translators: ...*/ comments.
I think it would probably be better to merge this PR before taking the time to improve how the strings are presented to translators, but it would be helpful to make a follow-up PR immediately afterward to add string context where needed.
Motivation for the change, related issues
This pull request introduces comprehensive internationalization (i18n) support throughout the Playground website UI by integrating translation functions into user-facing strings. The changes ensure that all visible text, labels, and messages can be easily localized, improving accessibility for non-English users. The implementation leverages the
@wordpress/i18npackage and a customuseI18nhook to provide translation capabilities in React components.Related to issue ##1991
Key changes include:
Internationalization Implementation:
@wordpress/i18nas a dependency inpackage.jsonto enable translation functions.useI18nhook and imported it into all relevant components to access the translation function (__).UI String Localization:
AddressBar,BrowserChrome,EnsurePlaygroundSiteIsSelected,ErrorReportModal,ImportFormModal,ImportForm, andLogModalwith calls to the translation function (__). This covers aria-labels, modal titles, button labels, error messages, and instructional text.These updates lay the groundwork for translating the Playground UI into multiple languages, making the application more accessible and user-friendly for a global audience.
Testing Instructions (or ideally a Blueprint)
npm run devAnd check the UI:
Spanish UI

Brazilian Portuguese UI
