-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix/gb editor translations #10347
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
Fix/gb editor translations #10347
Conversation
| Context localizedContextCurrent = getActivity() | ||
| .createConfigurationContext(currentResources.getConfiguration()); | ||
| // if the current locale of the app is english stop here and return an empty map | ||
| Configuration currentConfiguration = localizedContextCurrent.getResources().getConfiguration(); |
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.
Wondering if we can use currentResources.getConfiguration() here. currentResources are read from the activity and should work.
|
Nice work @mzorz! Tested your PR and worked without any problem on my IT device. I've made some small changes to the code, and posted it below, since it was hard to follow with all that variables with similar names. I know, those were already there. diff here: https://gist.github.com/daniloercoli/cf6381c3bb4316bf625689a08466bbf8 Feel free to discard proposed changes above. |
hypest
left a comment
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.
Tested and the issue is fixed on my side 👍
|
Tested and LGTM! We can take my comments in consideration for another PR. |
|
Thank you for your review and comments @daniloercoli @hypest ! And let's make the changes on another PR for sure! 🙇 |
Fixes translation issues in the Editor when using Gutenberg.
Problem
Working with @daniloercoli it was found that when using mobile Gutenberg, some strings were defaulted to English even when the device was set to another supported language (for example, Spanish or Italian as per our tests).
Specifically, the overflow menu in the Editor was all in English, and within Gutenberg, the strings such as "ADD BLOCK" separator, or "Start writing..." hint on a new post were all in English:
Furthermore, after attempting to use GB, the rest of the app would be back to be translated to English (except for the main navigation, for instance).

Research & discovery
So, we apparently had 2 problems.
One problem:
onCreateOptionsMenu()and it still had the correct locale, but it still showed english.Another problem:
Looking further, found out these two:
in
getTranslations()would both return the english string, when thecurrentResourceStringshould be the translated one, even when inspecting bothcurrentResourcesanddeafultResourceshad the right locale set (one the current, i.e. spanish, and the other one the default, that isen).Solution
From testing various things, turned out both problems were the same; it seems these 2 changes were necessary:
createConfigurationContextin 34257d6 to create a "copy" of the current context (both for checking current resources and creating the english reference) based on the configuration object as per the code shown here.Doing either thing alone did not prove to work - rationale behind this is given I was still seeing the same default string being retrieved ("problem 2"), it looked like one of the internal references in Context was changed to the default one, in fact affecting the whole app with this change ("problem 1"). Using a more local context (Activity) and copying the configuration from there seems to behave in a good manner, without disrupting the app's context
To test:
Here are some various screenshots showing it works:
Italian:

Spanish:

German:

Update release notes:
RELEASE-NOTES.txt.