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

[expo-localization] Add hooks, config plugin changes and more features to expo-localization #22763

Merged
merged 9 commits into from
Jun 20, 2023

Conversation

aleqsio
Copy link
Contributor

@aleqsio aleqsio commented Jun 6, 2023

Why

#22638
https://linear.app/expo/issue/ENG-6296/add-event-based-hooks-to-expo-localization-to-allow-listening-to

How

Hooks (https://linear.app/expo/issue/ENG-6296/add-event-based-hooks-to-expo-localization-to-allow-listening-to)

We add hooks to JS and event listeners on native side.
On iOS it's easy as we can just use NotificationCenter.

On Android we need to add |locale|layoutDirection to [configChanges](android:configChanges).
To do this we need to add a mod to a config plugin.
We also need to use the old Package api and create a static notifier object that will inform our Module that a Package has received a onConfigurationChanged event.

User settings (#22638)

We take two separate locales, and for settings that are overridable by the user (decimal separators, number separators, ect.) we use the current locale instead of the locale computed from the language.

I'm not confident this is the best solution.
On Android it's just a list of locales, on iOS we get one locale and a list of preferred languages. There's also no way to check if settings are default for the locale or overridden by the user.

Other options:

  • Only override the locale defaults for the first locale on the list – if an app only supports locale US perhaps it should also format numbers in the US way.

Test Plan

Tested manually in a standalone app – this makes both Android and iOS update locale settings without loosing react state.

Checklist

@aleqsio aleqsio requested a review from EvanBacon as a code owner June 6, 2023 10:26
@aleqsio aleqsio requested a review from tsapeta June 6, 2023 10:26
@expo-bot expo-bot added the bot: suggestions ExpoBot has some suggestions label Jun 6, 2023
@aleqsio aleqsio changed the title Add hooks, config plugin changes and more features to expo-localization [expo-localization] Add hooks, config plugin changes and more features to expo-localization Jun 7, 2023
@expo-bot expo-bot added bot: passed checks ExpoBot has nothing to complain about and removed bot: suggestions ExpoBot has some suggestions labels Jun 7, 2023
@aleqsio aleqsio requested a review from tsapeta June 12, 2023 15:33
@aleqsio aleqsio merged commit 52d6405 into main Jun 20, 2023
7 of 9 checks passed
@aleqsio aleqsio deleted the @aleqsio/expo-localization-hooks branch June 20, 2023 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: passed checks ExpoBot has nothing to complain about
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants