MonoTouch: CurrentCulture when Language is set

On iPhone, when a user sets the Language to French and the Region format to the United States , CurrentCulture represents ru-US .

Only when the user sets his Region format to France, I get fr-FR ;

How can I determine the language if the user installed Langauge , but not their Region format ?

enter image description here

+4
source share
2 answers

You want to see NSLocale , for example. NSLocale.CurrentLocale.Identifier to get a string of type en-US . This will give you the exact values ​​that iOS uses.

Both .NET and iOS have a similar but subtlely different API to get these values. It is hard to be fully compatible with .NET using only iOS data (this is not ideal). In some cases, such as RegionInfo , we were able to load .NET classes using the data provided by iOS. As more functions become available, we could do the same for other types in the future.

+5
source

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

To get the language, use NSLocale.PreferredLanguages[0] . The result is a string of type fr or en-US for the selected language.

For more information, see Get the current device language in iOS? .

0
source

Source: https://habr.com/ru/post/1444217/


All Articles