Skip to content

Conversation

ravishanker
Copy link
Contributor

@ravishanker ravishanker commented Sep 15, 2022

This PR adds Per-app Language Preferences introduced in Android 12 (API 31) level.

Fixes #

App Lanaguages > App

device-2022-09-16-114901.mp4

App > Language

device-2022-09-16-114935.mp4

To test:

Test 1:

  • Build and run
  • Launch WordPress or Jetpack app
  • Now go to device Settings > System > Languages & Input > App Languages > Select (WordPress app or Jetpack app)
  • Ensure WordPress or Jetpack app shows in App Lanaguages
  • Tap on the app. It should navigate to App Lanaguage selection screen

Test 2:

  • Build and run
  • Launch WordPress or Jetpack app
  • Settings > Apps > Select (WordPress app or Jetpack app) > Language (scroll if required)
  • Tap on the Language option. It should navigate to App Lanaguage selection screen

NOTE:

  • WordPress app / Jetpack app already have in app Language picker ( Me > App Setttings > Interface Language)
  • Once we upgrade compileSdkVersion and targetSdkVersion to Android 13 (API 33), we can enable this Per-app Language Preferences and potentially remove in app language picker

Regression Notes

  1. Potential unintended areas of impact

  2. What I did to test those areas of impact (or what existing automated tests I relied on)

  3. What automated tests I added (or what prevented me from doing so)

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

Step1: Create locales_config.xml file for supported languages
Step 2: Update manifest with localeConfig line
Step 3: Specify supported languages using resConfigs in build.gradle
Step 4: Update compileSdkVersion in top level build.gradle to support localeConfig
Fix for ClassNotFoundException by updating path
Update androidx appcompat to 1.6.0-rc01 for backward compatibility
Updates for API changes with upgrade to appcompat 1.6.0-rc01
@ravishanker ravishanker added this to the Future milestone Sep 15, 2022
@ravishanker ravishanker self-assigned this Sep 15, 2022
@wpmobilebot

This comment was marked as off-topic.

@wpmobilebot
Copy link
Contributor

You can test the Jetpack changes on this Pull Request by downloading an installable build (jetpack-installable-build-pr17158-5fa233c.apk), or scanning this QR code:

@wpmobilebot
Copy link
Contributor

You can test the WordPress changes on this Pull Request by downloading an installable build (wordpress-installable-build-pr17158-5fa233c.apk), or scanning this QR code:

// Limit string resources to Mag16 only for Jetpack
// Note: this only affects included _locales_; variants for `values-night`, `values-land` and other configs are _still_ preserved in Jetpack and not filtered by this.
resourceConfigurations = ["ar", "de", "es", "fr", "he", "id", "it", "ja", "ko", "nl", "pt-rBR", "ru", "sv", "tr", "zh-rCN", "zh-rTW"]
resConfigs "ar", "de", "es", "fr", "he", "id", "it", "ja", "ko", "nl", "pt-rBR", "ru", "sv", "tr", "zh-rCN", "zh-rTW"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to what I read in the documentation and what Oguz told me recently [internal ref: pxLjZ-7b9-p2#comment-19303], resConfig is deprecated in favor of resourceConfigurations now (though sadly not all the guides in the Android docs have been updated)

Our current release scripts also checks the resourceConfigurations field (and not the resConfig deprecated one) at release time to ensure our setup is consistent between here in build.gradle and in what locales are configured to be downloaded from GlotPress in our Fastlane scripts, so it's another reason to use resourceConfigurations here and not resConfigs.

implementation 'androidx.exifinterface:exifinterface:1.0.0'
implementation 'androidx.media:media:1.0.1'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.appcompat:appcompat:1.6.0-rc01'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cc @ParaskP7 I know you had in your backlog to look into updating AppCompat at some point (in part exactly for this use case of supporting per-app locale backwards compatibility); seems @ravishanker beat you to it, which means (assuming no other changes due to this AppCompat update in other parts/topics in the app are needed) you might be able to cross an item off your list once this lands?

<locale android:name="zh-TW"/> <!-- Chinese (Traditional) -->
<!-- <locale android:name="zu"/> &lt;!&ndash; Zulu &ndash;&gt;-->
</locale-config>

Copy link
Contributor

@AliSoftware AliSoftware Sep 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll want to auto generate this file using our release-toolkit when we download the list of locales from GlotPress.

Basically replicate here what we already do for available_languages.xml (which we'll in turn be able to stop generating when we'll get rid of our custom in-app switcher once we fully migrate to this new Android 12 built-in per-app switcher)

Otherwise this list can easily go out of sync when we'll revisit the list of locales we include in the app [internal ref: pdnsEh-ev-p2]

@ParaskP7
Copy link
Contributor

👋 @ravishanker !

This is so cool that you are trying this Per-app language preferences feature! 🌟

This PR adds Per-app Language Preferences introduced in Android 12 (API 31) level.

Btw, in your description, did you mean Android 13 (API 33) maybe? 🤔

@ravishanker
Copy link
Contributor Author

There's a new PR for this work

@ravishanker ravishanker deleted the Per-app-Language-Preferences branch December 19, 2022 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants