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

fix(mobile): fixes on language change #14089

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

johnstef99
Copy link
Contributor

@johnstef99 johnstef99 commented Nov 11, 2024

This pull request fixes several problems around the flow of changing language:

  1. When you change language some widgets in the pages [SettingsSubPage, SettingsPage, LibraryPage] stay in the old language.
  2. Because across the app, you don't pass the context.locale to DateFormat, by default Intl 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.
  3. I created a new provider 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 the localeProvider 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

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.
@NicholasFlamy NicholasFlamy added date-time Issues with date/time/time zone changelog:bugfix labels Nov 11, 2024
@NicholasFlamy
Copy link
Contributor

@johnstef99 Is PR #14035 related to one of the issues you're fixing?

@johnstef99
Copy link
Contributor Author

Is kind of related, because the user describes this:

Changing my phone to English does resolve the issue.

That means that DateFormat does not use the context.locale and instead uses the phone's locale. That problem is going to get fixed by this change here

@NicholasFlamy
Copy link
Contributor

Is kind of related, because the user describes this:

Changing my phone to English does resolve the issue.

That means that DateFormat does not use the context.locale and instead uses the phone's locale. That problem is going to get fixed by this change here

Okay, just wanna be sure your changes and that PR don't conflict.

@johnstef99
Copy link
Contributor Author

No conflicts for sure. The #14035 initialises the date formatter, but this PR make the date formatter use the selected locale from immich settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:bugfix date-time Issues with date/time/time zone 📱mobile
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants