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

iOS await Devicelocale.currentAsLocale always return 'en' and correct CountryCode #38

Closed
tdujmic opened this issue Nov 4, 2021 · 8 comments

Comments

@tdujmic
Copy link

tdujmic commented Nov 4, 2021

Since iOS 15 is launched this issue is presented. Yesterday I saw that only adding array of supported languages into Info.plist
helps a bit, but for all other languages presented on phone which are not in Info.plist it returns 'en' for language.

I repeat that only happens on iOS 15.x

I added this in Info.plist and my languages are returned correctly now, but any other selected on iPhone returns 'en' if is not in Info.plist again for eg my local language 'hr' is returned as 'en' :

<key>CFBundleLocalizations</key>
<array>
	<string>en</string>
	<string>de</string>
	<string>no</string>
	<string>nb</string>
	<string>fr</string>
	<string>da</string>
</array>
@josefwilhelm-innio
Copy link

I have the same problem, does anyoone have a fix for this?

@magnatronus
Copy link
Owner

The answer above from @tdujmic (adding the app supported languages into the Info.plist) should work.

@josefwilhelm-innio
Copy link

no, it does not work.

the problem is that the returned locale is wrong if the locale is not in the array. and I want to get the correct device locale even if it's not in the supported locales because I want to show english as fallback.

with the example above, if I change the language to spanish, the plugin returns 'de' as the currentLocale which is not correct.

@magnatronus
Copy link
Owner

the problem is that the returned locale is wrong if the locale is not in the array. and I want to get the correct device locale even if it's not in the supported locales because I want to show english as fallback.

The plugin was designed to return the locales supported by the app if the app was developed in various languages (i.e. it shows which languages the app has been created for) .

Can you let me know you default locale (region) set on the phone, The list of preferred languages you have set up and the content of your info.plist. I will try and replicate and have a look at the issue.

Thanks.

@josefwilhelm-innio
Copy link

ok, then I didn't get that from the description in pub.dev.

My use case is to get the actual locale of the device in main() to set the locale for the first app start. And I can't use Localizations.of(context) there yet.

my info.plist
<key>CFBundleLocalizations</key> <array> <string>en</string> <string>de</string> <string>it</string> </array>

I tried it on an iOS simulator and set the region and language to Spain, 'es_ES', but the plugin shows 'de_ES'.

@magnatronus
Copy link
Owner

@josefwilhelm-innio
A new version has been published(0.6.0) that has new functionality (defaultLocale). You should be able to use this in place of currentLocale to return the correct default locale settings in iOS (i.e. the first language set and the current region).

@aytunch
Copy link

aytunch commented Mar 15, 2023

@magnatronus after this fix do we still need to set CFBundleLocalizations? thanks

@magnatronus
Copy link
Owner

If you currently use it for anything then yes, the update just gives you the first language and region.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants