If in Settings->General->Languge & Region I set Language to French and Region to Canada and my developer system is us-EN, Xamarin.iOS (C#) honors the system setting even if my app is not localized to French.
In my test setup below:
This C# code:
Console.WriteLine($"App Locale {NSLocale.CurrentLocale.Identifier}");
Console.WriteLine($"System Locale {NSLocale.PreferredLanguages[0]}");
var formatter = new NSDateFormatter();
formatter.DateStyle = NSDateFormatterStyle.Full;
formatter.TimeStyle = NSDateFormatterStyle.Short;
var stringDate = formatter.ToString(NSDate.Now);
Console.WriteLine(stringDate);
Prints:
App Locale fr_CA <<<---
System Locale fr-CA
samedi 15 octobre 2022 à 22:52
I like this behavior. Even though my app is not localized, at least I get localized date and time. It even honors the 24 hour time switch.
The equivalent Swift code does not, which my understanding is expected (see Locale.current reporting wrong language on device):
let formatter = DateFormatter()
formatter.dateStyle = .full
formatter.timeStyle = .short
let stringDate = formatter.string(from: NSDate.now)
NSLog(stringDate)
Prints:
App Locale en_CA <<<---
System Locale fr-CA
Saturday, October 15, 2022 at 10:55 PM
So Xamarin is using fr_CA for what I am calling App Locale while Swift is using "en_CA" -- English language + Canada region -- as expected due to lack of localization.
What is Xamarin doing to force the app locale to system locale?