Add language switcher in user settings modal
- Closes https://github.com/Automattic/studio/issues/25
Proposed Changes
- Add language picker in user settings, which allows changing the language on the fly
- Add language to AppData user data file
- Remove locale from AppGlobals and refactor locale code
The only downside is that the user needs to be logged in to open the user settings.
Testing Instructions
- Run
npm start - Observe the App starts with the computer's language
- Login to Studio with your WPcom account
- Click in your profile picture in the left sidebar
- Change the language to any language, even RTL
- Observe the interface changes immediately
- Close the app
- Run
npm start - Observe the App starts with the latest language you selected
https://github.com/user-attachments/assets/dc252326-8c0b-4a82-86b4-aed0f3619431
Pre-merge Checklist
- [ ] Have you checked for TypeScript, React or other console errors?
Amazing, Thanks for the update @sejas 🙏
Amazing work @sejas ! I tested it and works as expected!
| Example 1 | Example2 |
|---|---|
@kozer How to test it?
@kozer How to test it?
Hey @nguyenquanghoang ! What I did is the following:
- Clone the repo, and checkout that branch (
add/user-locale-settings) - Run the project:
npm start - Follow the Testing instructions mentioned above.
Do you face any problems while trying to replicate those instructions?
@kozer I don't know how to do with the above instructions, Don't know what npm is? Sorry because I'm new, don't have much technical knowledge
@kozer I don't know how to do with the above instructions, Don't know what npm is? Sorry because I'm new, don't have much technical knowledge
Sure! It's ok!
First of all, you need to install nodejs. Navigate to that site, and click the Download button. Then you need to follow the instructions mentioned.
After that, open a terminal of your choice and run npm. You should wee an output similar to the below:
After that, you should be able to clone the repo, and run the npm instructions.
Make sure that after you clone the repo, and being in the root of the project, to run npm install first.
Feel free to ask for any help!
@sejas the feature works great, it's awesome that it reloads the whole UI as user changes the language.
The only downside is that the user needs to be logged in to open the user settings.
Let's display the language selector in settings for a logged-out user, too.
Great feature, thank you :)
I am currently using Studio on Windows, Tried following the instructions but it didn't work. Hope it can be easier for newbies like me, just turn on Studio, log in to your WordPress .com account and select the language you want to use.
Let's display the language selector in settings for a logged-out user, too. Done!
Here is the updated screencast:
https://github.com/user-attachments/assets/4a7896fc-ae5c-40cd-9057-fa0995a7bf05
I am currently using Studio on Windows, Tried following the instructions but it didn't work. Hope it can be easier for newbies like me, just turn on Studio, log in to your WordPress .com account and select the language you want to use.
@nguyenquanghoang, Yes, once we merge this PR and create the next release it will be as easy as starting Studio with double click.
@sejas Yes, I have enjoyed Studio since its launch. Everything is easier for newbies like me, always fast and has the essentials. Great UI 🙏
Heads up that I've encountered some issues related to this PR: https://github.com/Automattic/studio/pull/502#pullrequestreview-2276754994
Regarding the menu items, since it's created when instantiating the main window, the strings won't be translated because the locale date is fetched after the creation.
I'll work on a fix to be included before the next release.
UPDATE: Here's the PR.