Apply user language selected in WordPress app to Jetpack app during migration - #17768
Conversation
This was already handled by the application callbacks and therefore not needed.
This fix was needed to address possible issues when the language and the app theme is set manually by the user in the WordPress app.
This fix was needed to address possible issues when the language and the app theme is set manually by the user in the WordPress app.
# Conflicts: # WordPress/src/main/java/org/wordpress/android/localcontentmigration/LocalMigrationResult.kt # WordPress/src/main/java/org/wordpress/android/ui/main/jetpack/migration/JetpackMigrationViewModel.kt
|
|||||||||||
| 💡 Scan this QR code with your Android phone to download and install the APK directly on it. | ||
| App | Jetpack | |
| Build Flavor | Jalapeno | |
| Build Type | Debug | |
| Commit | 11e73fa | |
|
|||||||||||
| 💡 Scan this QR code with your Android phone to download and install the APK directly on it. | ||
| App | WordPress | |
| Build Flavor | Jalapeno | |
| Build Type | Debug | |
| Commit | 11e73fa | |
| * @param locale The locale to be used in the [LocalContext] configuration override. | ||
| * @param onLocaleChange Callback to be invoked when the locale is overridden, useful to update other app components. | ||
| * @param content The Composable function to be rendered with the overridden locale. | ||
| */ |
There was a problem hiding this comment.
Thank you for documenting this properly 🙇
antonis
left a comment
There was a problem hiding this comment.
Great work @ovitrif 👍
I've tested the implementation on a Pixel 5 (Android 13) and everything worked as described for me. The code changes also look good to me
🚀 As a solution to these issues I introduced the new LocaleAwareComposable utility that listens to language changes and synchronizes the local configuration inside its content composable when needed.
I also validated that this case is cover too 🎉
I'll restrain from merging in case @mkevins has any more feedback 🙇
| private fun emitLanguageRefreshIfNeeded(languageCode: String) { | ||
| if (languageCode.isNotEmpty()) { | ||
| val shouldEmitLanguageRefresh = !localeManagerWrapper.isSameLanguage(languageCode) | ||
| if (shouldEmitLanguageRefresh) { | ||
| _refreshAppLanguage.value = languageCode | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Not suggesting a change here, but wanted to note that my first thought here was if we could instead use:
val refreshAppLanguage: LiveData<String> = _refreshAppLanguage.distinct()but I guess this could result in one unnecessary refresh at the start compared to the approach used here, since this way compares to the locale set in the current context. 🤷♂️
There was a problem hiding this comment.
In the future, it would be nice if this idempotency was intrinsic to the implementation, so we wouldn't need to worry about it at the call site, but that's out of scope for this PR 😅 .
There was a problem hiding this comment.
In the future, it would be nice if this idempotency was intrinsic to the implementation, so we wouldn't need to worry about it at the call site
Top idea 👏 , totally agreeing with you on this one, that would add to the reusability of the code 🚀
I've added a card on our team's private GitHub project to further pursue this when there's time for technical improvements 🙇 . On the other hand, it's possible we won't need this at all if we add support for the Android 13 Per-app language preferences mechanism soon 🤔
There was a problem hiding this comment.
Good point, this could all become moot in the future 😄 👍
|
I tested all flows described on a Pixel 3a (physical device) and it is working as expected. Great work on this Ovi! Also, the code looks good! 👍 |
mkevins
left a comment
There was a problem hiding this comment.
As mentioned above, LGTM!


Fixes #17685
This PR enhances the implementation of the Jetpack Content Migration Flow by applying the interface language set by the user in the WordPress app to the Migration screens.
To test:
Me→App Settings→Appearanceand Set the WordPress app theme toDarkmode (or the opposite of the system default)Interface Languageand change the app language toArabic(or a language you know,Arabichelps to verify the RTL texts)app themeis inDarkmode (or whatever was manually set in WordPress)languageisArabic(or whatever was manually set in WordPress)layout directionisRTLmode if Arabic/LTRif in a LTR languageNeed help?→Log out, force close & restart the appMy Sitetap on the card with theWordPresslogo (to open "Please Delete WordPress.." screen)darkmode, then tolight modeand navigate to another screen (there was an issue with this behavior and specific fixes were needed for this)app theme,languageandlayout directionare persisted (same as on Welcome Screen)🎬 Video recording preview
(click to expand)app_language_transfer.mp4
Regression Notes
Potential unintended areas of impact
Migration of user language and theme from WordPress to Jetpack app.
What I did to test those areas of impact (or what existing automated tests I relied on)
Manual testing & unit tests from
JetpackMigrationViewModelTest.What automated tests I added (or what prevented me from doing so)
Added unit tests to
JetpackMigrationViewModelTestfor the updated language transfer logic.PR submission checklist:
RELEASE-NOTES.txtif necessary.