Skip to content
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

Send non-deprecated language tags from Android in initialProps #37565

Merged
merged 4 commits into from
Jan 14, 2022

Conversation

mchowning
Copy link
Contributor

@mchowning mchowning commented Dec 21, 2021

Description

Fixes wordpress-mobile/gutenberg-mobile#4368

By default, the Android/Java Locale class uses deprecated language codes for Hebrew and Indonesian in order to not break backwards compatibility. But Gutenberg uses the new language codes, which prevented the proper translations from being picked up for those languages on Android. This updates Android to instead send the new language codes to Gutenberg in the initial props.

I'm applying this fix on the Android native side because (1) it allows me to use Locale::toLanguageTag to "revert" the change in the language code. This felt right to me since it is the Locale class itself that was switching to the deprecated language code and causing this problem in the first place.

How has this been tested?

Note that this has to be tested via WPAndroid (relevant PR) because language changes are not picked up in the demo app.

  1. Set Android's language to Hebrew or Indonesian [instructions]
  2. Clean install WordPress for Android (clean install avoids the issue that updating the device language has no effect if the user previously set a language within WPAndroid's App settings)
  3. Create a new post
  4. Open the Block Inserter and observe that the block names are translated

Screenshots

Types of changes

Bugfix

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR (please manually search all *.native.js files for terms that need renaming or removal).

@twstokes
Copy link
Contributor

twstokes commented Jan 4, 2022

LGTM @mchowning!

Sequence I followed using WordPress-pr-15743-build-117826:

  1. Clean installed the app and authenticated in English, closed app
  2. Set the Android system language to Hebrew
  3. Started a new post and observed the app's interface as well as the Block Inserter were translated

The interface differed slightly from your screenshot, but that was expected for the build type and matched the English version, just swapped laterally.

@mchowning mchowning merged commit 44f69d1 into trunk Jan 14, 2022
@mchowning mchowning deleted the rnmobile/fix/deprecated-language-tags-from-android branch January 14, 2022 19:39
@github-actions github-actions bot added this to the Gutenberg 12.5 milestone Jan 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Android: Title and Inserter do not honor system language when set to Hebrew
2 participants