-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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(mobile): fixes on language change #14089
fix(mobile): fixes on language change #14089
Conversation
This will make the make the pages to instantly refresh the correct translated string, without the need to pop and push the settings page.
This is needed because across the app, you don't pass the context.locale to DateFormat, so by default it uses the system's locale. This will fix the issue without the need to refactor a lot of code.
This provider can be used to refresh providers that provide UI elements and get cached.
This is necessary to update the locale on the already evaluated DateFormat.
@johnstef99 Is PR #14035 related to one of the issues you're fixing? |
Is kind of related, because the user describes this:
That means that |
Okay, just wanna be sure your changes and that PR don't conflict. |
No conflicts for sure. The #14035 initialises the date formatter, but this PR make the date formatter use the selected locale from immich settings. |
@@ -46,6 +46,7 @@ class SettingsPage extends StatelessWidget { | |||
|
|||
@override | |||
Widget build(BuildContext context) { | |||
context.locale; |
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.
Is this used to trigger the widget rebuild?
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.
Exactly! It's like doing MediaQuery.sizeOf(context)
which is going to rebuild the widget when the size changes from the InheritedWidget
* fix(mobile): make widgets rebuild on locale changes This will make the make the pages to instantly refresh the correct translated string, without the need to pop and push the settings page. * fix(mobile): set the default intl locale This is needed because across the app, you don't pass the context.locale to DateFormat, so by default it uses the system's locale. This will fix the issue without the need to refactor a lot of code. * feat(mobile): create localeProvider This provider can be used to refresh providers that provide UI elements and get cached. * fix(mobile): refresh asset providers on locale change This is necessary to update the locale on the already evaluated DateFormat. --------- Co-authored-by: Alex <alex.tran1502@gmail.com>
This pull request fixes several problems around the flow of changing language:
[SettingsSubPage, SettingsPage, LibraryPage]
stay in the old language.context.locale
toDateFormat
, by defaultIntl
uses the system's locale. This means that even after selecting a language in the immich settings, the dates will stay in the system's language.localeProvider
that can be used inside other providers to invalidate them whenever the locale is changed. This is needed because immich has providers that cache UI elements. I added thelocaleProvider
only to the asset providers of the photos page but I am sure someone with more knowledge of the codebase can find other instances where it's needed.Before fix:
not_fixed.mp4
After fix:
As you can see when changing language both settings and photo grid get updated.
fixed.mp4