Question

On an iPhone, when the user sets their Language to French and their Region Format to United States, the CurrentCulture represents en-US.

Only when the user sets their Region Format to France do I get fr-FR;

How can I determine the language if the user has set their Langauge, but not their Region Format?

enter image description here

Was it helpful?

Solution

You want to look at NSLocale, e.g. NSLocale.CurrentLocale.Identifier to get a string like en-US. That will give you the exact values that iOS is using.

Both .NET and iOS have similar, but subtly different, API to get those values. It's difficult to be fully compatible with .NET by using only iOS data (it's not a perfect fit). In some case, e.g. RegionInfo, we have been able to bootstrap the .NET classes using iOS provided data. As more features becomes available we might be able to do the same for other types in the future.

OTHER TIPS

NSLocale.CurrentLocale gives the region format, not the language.

To get the language, use NSLocale.PreferredLanguages[0] instead. The result will be a string like fr or en-US for the language that is selected.

For more info, see Getting current device language in iOS?.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top