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

NativeModules.SettingsManager.settings.AppleLocale not working in ios 13 #26540

Closed
kefyru opened this issue Sep 23, 2019 · 5 comments
Closed
Labels
API: Settings Platform: iOS iOS applications. Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot. Type: Question Issues that are actually questions and not bug reports.

Comments

@kefyru
Copy link

kefyru commented Sep 23, 2019

I used NativeModules.SettingsManager.settings.AppleLocale to define interface language in my app. After updating xcode to version 11.0 (11A420a) and run in emulator on ios 13 it stopped work.

@kefyru kefyru added the Type: Question Issues that are actually questions and not bug reports. label Sep 23, 2019
@react-native-bot
Copy link
Collaborator

We are automatically closing this issue because it does not appear to follow any of the provided issue templates.

👉 Click here if you want to report a reproducible bug or regression in React Native.

@react-native-bot react-native-bot added Ran Commands One of our bots successfully processed a command. Resolution: No Template labels Sep 23, 2019
@algarpe
Copy link

algarpe commented Sep 26, 2019

I'm in the same situation. Does anyone managed to get it working?

@tomasvarga
Copy link

Yes.

When you launch the fresh simulator or you have a device with language without a region, AppleLocale is nowhere to be found in NSUserDefaults on iOS 13. Now when you do change it to, for example, English(Canada) -> it's there.

Workaround:

let locale = NativeModules.SettingsManager.settings.AppleLocale // "fr_FR"
if (locale === undefined) {
    // iOS 13 workaround, take first of AppleLanguages array  ["en", "en-NZ"]
    locale = NativeModules.SettingsManager.settings.AppleLanguages[0]
    if (locale == undefined) {
          locale = "en" // default language
    }
}

Similar issue on expo here: expo/expo#5735 (comment)

As per my understanding the problem is that if the phone (either device or simulator) has the default language because the user didn't set it, all the language properties like timezone, country, currency and so on are undefined raising the exception
I'm able to reproduce the issue with iOS13 on a fresh simulator or on some devices.
Changing the language in "settings" to English/UK or English/US, the Localization.* properties are set properly.

@algarpe
Copy link

algarpe commented Sep 27, 2019

More or less, that was what I was going to do, but I was waiting if there was another way.
Thanks a lot
Much appreciated

@webjay
Copy link

webjay commented Jun 12, 2020

This is the path I followed: https://docs.expo.io/versions/latest/sdk/localization/

@facebook facebook locked as resolved and limited conversation to collaborators Oct 3, 2021
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Oct 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
API: Settings Platform: iOS iOS applications. Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot. Type: Question Issues that are actually questions and not bug reports.
Projects
None yet
Development

No branches or pull requests

5 participants