Bug 28622 - PreferredLanguages not being picked up when running on iOS
Summary: PreferredLanguages not being picked up when running on iOS
Alias: None
Product: Forms
Classification: Xamarin
Component: Samples ()
Version: 1.4.1
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Rustam Zaitov
Depends on:
Reported: 2015-04-01 05:31 UTC by John Hardman
Modified: 2017-09-03 11:10 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description John Hardman 2015-04-01 05:31:02 UTC
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 (the code used is as per samples/documentation).

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 the rest of my app, but this code (obtained from samples/documentation) is not picking up the language correctly.

I don't know if this is an issue in the simulator, or is an issue in the sample code/documentation.
Comment 1 Rustam Zaitov 2015-04-01 09:01:22 UTC
Provided code looks good for me. NSLocale.PreferredLanguages should hold at least one element (current language). I am pretty sure that this is iOS8 simulator issue



We should just await fix from Apple
Comment 2 John Hardman 2017-09-03 11:10:22 UTC
I've just re-tested this, on both simulator and physical device. It is working now (and may have been for some time)