Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

How to pick up PreferredLanguages correctly when using iOS simulator?

$
0
0

I am testing my app with different languages. On Windows Phone and Android, everything is fine. However, testing in the iOS Simulator, the code for detecting the language is not picking up the preferred languages.

This is what I am using:

var netLanguage = "en";

if (NSLocale.PreferredLanguages.Length > 0) 
{
    var pref = NSLocale.PreferredLanguages [0];
    netLanguage = pref.Replace ("_", "-");
}
return new System.Globalization.CultureInfo(netLanguage);

However, the PreferredLanguages collection is coming back empty. If I hack this and set the netLanguage to the appropriate value (e.g. "nl") then I can test my app, but would far prefer to get this working. Is this an issue in the simulator, or is the bit of code above (which I got from a sample) incorrect?

Many thanks,

John H.


Viewing all articles
Browse latest Browse all 58056

Trending Articles