Go to your device Settings App > General > Language and regions and set the following:
Preferred languages: English, Italian
Region: United States
Deploy and run the sample on iOS
It crashes with the following error:
**System.InvalidOperationException:** 'Failed to load CalendarDatePickerLanguageBug.MainPage: System.Globalization.CultureNotFoundException: Culture name it-US is not supported.
Parameter name: name
at System.Globalization.CultureInfo..ctor (System.String name, System.Boolean useUserOverride, System.Boolean read_only) [0x0006d] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/corlib/System.Globalization/CultureInfo.cs:730
at System.Globalization.CultureInfo..ctor (System.String name, System.Boolean useUserOverride) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/corlib/System.Globalization/CultureInfo.cs:710
at System.Globalization.CultureInfo..ctor (System.String name) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/corlib/System.Globalization/CultureInfo.cs:707
at Windows.Globalization.DateTimeFormatting.DateTimeFormatter.BuildLookup (System.String language) [0x00011] in C:\a\1\s\src\Uno.UWP\Globalization\DateTimeFormatting\DateTimeFormatter.cs:178
at Uno.Extensions.CollectionExtensions.SelectToArray[TSource,TResult] (TSource[] source, System.Func`2[T,TResult] selector) [0x0000d] in C:\a\1\s\src\Uno.Foundation\Uno.Core.Extensions\Uno.Core.Extensions.Collections\CollectionExtensions.cs:221
at Windows.Globalization.DateTimeFormatting.DateTimeFormatter..ctor (System.String formatTemplate, System.Collections.Generic.IEnumerable`1[T] languages) [0x000ab] in C:\a\1\s\src\Uno.UWP\Globalization\DateTimeFormatting\DateTimeFormatter.cs:118
at Windows.Globalization.DateTimeFormatting.DateTimeFormatter..ctor (System.String formatTemplate, System.Collections.Generic.IEnumerable`1[T] languages, System.String geographicRegion, System.String calendar, System.String clock) [0x00000] in C:\a\1\s\src\Uno.UWP\Globalization\DateTimeFormatting\DateTimeFormatter.cs:129
at Windows.UI.Xaml.Controls.CalendarView.CreateDateTimeFormatter (System.String format, Windows.Globalization.DateTimeFormatting.DateTimeFormatter& ppDateTimeFormatter) [0x00013] in <d4f183b8dc434848a056dbac2b2444f5>:0
at Windows.UI.Xaml.Controls.CalendarView.CreateCalendarAndMonthYearFormatter () [0x000ca] in <d4f183b8dc434848a056dbac2b2444f5>:0
at Windows.UI.Xaml.Controls.CalendarView.PrepareState () [0x000a8] in <d4f183b8dc434848a056dbac2b2444f5>:0
at Windows.UI.Xaml.Controls.CalendarView..ctor () [0x00148] in <d4f183b8dc434848a056dbac2b2444f5>:0
at Uno.UI.FluentTheme.v2.__Resources._themeresources_v2_45f76a11e2ea901415bf5c04615d7196_themeresources_v2RDSC36+<>c__DisplayClass3_0.<Build>b__0 (Windows.UI.Xaml.Controls.Grid c2794) [0x004d6] in <915938372b474ad18c168d6cff44c03f>:0
at Uno.UI.FluentTheme.v2.themeresources_v2_45f76a11e2ea901415bf5c04615d7196XamlApplyExtensions.themeresources_v2_45f76a11e2ea901415bf5c04615d7196_XamlApply (Windows.UI.Xaml.Controls.Grid instance, Uno.UI.FluentTheme.v2.themeresources_v2_45f76a11e2ea901415bf5c04615d7196XamlApplyExtensions+XamlApplyHandler17 handler) [0x00000] in <915938372b474ad18c168d6cff44c03f>:0
at Uno.UI.FluentTheme.v2.__Resources._themeresources_v2_45f76a11e2ea901415bf5c04615d7196_themeresources_v2RDSC36.Build (System.Object __ResourceOwner_1) [0x00300] in <915938372b474ad18c168d6cff44c03f>:0
at Uno.UI.FluentTheme.v2.GlobalStaticResources+ResourceDictionarySingleton__themeresources_v2_45f76a11e2ea901415bf5c04615d7196+<>c.<Get_152>b__75_1 (System.Object __owner) [0x00005] in <915938372b474ad18c168d6cff44c03f>:0
at Windows.UI.Xaml.FrameworkTemplate.LoadContent () [0x0002d] in <d4f183b8dc434848a056dbac2b2444f5>:0
at Windows.UI.Xaml.FrameworkTemplatePool.DequeueTemplate (Windows.UI.Xaml.FrameworkTemplate template) [0x00088] in <d4f183b8dc434848a056dbac2b2444f5>:0
at Windows.UI.Xaml.FrameworkTemplate.LoadContentCached () [0x00005] in <d4f183b8dc434848a056dbac2b2444f5>:0
at Windows.UI.Xaml.Controls.Control.UpdateTemplate () [0x00045] in <d4f183b8dc434848a056dbac2b2444f5>:0
at Windows.UI.Xaml.Controls.Control.SetUpdateControlTemplate (System.B...Details propertyDetails, System.Boolean isPersistentResourceBinding) [0x0001a] in <d4f183b8dc434848a056dbac2b2444f5>:0
at Windows.UI.Xaml.DependencyObjectStore.SetValue (Windows.UI.Xaml.DependencyProperty property, System.Object value) [0x00000] in <d4f183b8dc434848a056dbac2b2444f5>:0
at Uno.UI.Controls.BindableUIView.SetValue (Windows.UI.Xaml.DependencyProperty dp, System.Object value) [0x00006] in <d4f183b8dc434848a056dbac2b2444f5>:0
at Windows.UI.Xaml.Setter.ApplyTo (Windows.UI.Xaml.DependencyObject o) [0x0007d] in <d4f183b8dc434848a056dbac2b2444f5>:0
at Windows.UI.Xaml.Style.ApplyTo (Windows.UI.Xaml.DependencyObject o, Windows.UI.Xaml.DependencyPropertyValuePrecedences precedence) [0x0003a] in <d4f183b8dc434848a056dbac2b2444f5>:0
at Windows.UI.Xaml.FrameworkElement.OnStyleChanged (Windows.UI.Xaml.Style oldStyle, Windows.UI.Xaml.Style newStyle, Windows.UI.Xaml.DependencyPropertyValuePrecedences precedence) [0x00014] in <d4f183b8dc434848a056dbac2b2444f5>:0
at Windows.UI.Xaml.FrameworkElement.ApplyStyle () [0x0000d] in <d4f183b8dc434848a056dbac2b2444f5>:0
at Windows.UI.Xaml.FrameworkElement.ApplyStyles () [0x00000] in <d4f183b8dc434848a056dbac2b2444f5>:0
at Windows.UI.Xaml.FrameworkElement.CreationComplete () [0x00014] in <d4f183b8dc434848a056dbac2b2444f5>:0
at CalendarDatePickerLanguageBug.MainPage+<>c.<InitializeComponent_60508768>b__7_4 (Windows.UI.Xaml.Controls.CalendarDatePicker c0, CalendarDatePickerLanguageBug.MainPage __that, Windows.UI.Xaml.NameScope __nameScope) [0x0002b] in C:\Users\DTO\CalendarDatePickerLanguageBug\CalendarDatePickerLanguageBug\CalendarDatePickerLanguageBug.iOS\Uno.UI.SourceGenerators\Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGenerator\MainPage_c0fb7f1b03533a6ed3341c5f36aa9eb6.cs:90
at Uno.UI.Helpers.Xaml.ApplyExtensions.GenericApply[TType,TArg1,TArg2] (TType instance, TArg1 arg1, TArg2 arg2, System.Action`3[T1,T2,T3] apply) [0x00000] in <d4f183b8dc434848a056dbac2b2444f5>:0
at CalendarDatePickerLanguageBug.MainPage.InitializeComponent_60508768 () [0x0003b] in C:\Users\DTO\CalendarDatePickerLanguageBug\CalendarDatePickerLanguageBug\CalendarDatePickerLanguageBug.iOS\Uno.UI.SourceGenerators\Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGenerator\MainPage_c0fb7f1b03533a6ed3341c5f36aa9eb6.cs:72
at CalendarDatePickerLanguageBug.MainPage.InitializeComponent () [0x00001] in C:\Users\DTO\CalendarDatePickerLanguageBug\CalendarDatePickerLanguageBug\CalendarDatePickerLanguageBug.iOS\Uno.UI.SourceGenerators\Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGenerator\MainPage_c0fb7f1b03533a6ed3341c5f36aa9eb6.cs:58
at CalendarDatePickerLanguageBug.MainPage..ctor () [0x0002a] in C:\Users\DTO\CalendarDatePickerLanguageBug\CalendarDatePickerLanguageBug\CalendarDatePickerLanguageBug.Shared\MainPage.xaml.cs:19
at CalendarDatePickerLanguageBug.MetadataBuilder_701.CreateInstance () [0x00000] in C:\Users\DTO\CalendarDatePickerLanguageBug\CalendarDatePickerLanguageBug\CalendarDatePickerLanguageBug.iOS\Uno.UI.SourceGenerators\Uno.UI.SourceGenerators.BindableTypeProviders.BindableTypeProvidersSourceGenerator\BindableMetadata.g.cs:28541
at Windows.UI.Xaml.Controls.Frame.CreatePageInstance (System.Type sourcePageType) [0x0001c] in <d4f183b8dc434848a056dbac2b2444f5>:0
at Windows.UI.Xaml.PagePool.DequeuePage (System.Type pageType) [0x00007] in <d4f183b8dc434848a056dbac2b2444f5>:0
at Windows.UI.Xaml.Controls.Frame.CreatePageInstanceCached (System.Type sourcePageType) [0x00000] in <d4f183b8dc434848a056dbac2b2444f5>:0
at Windows.UI.Xaml.Controls.Frame.EnsurePageInitialized (Windows.UI.Xaml.Navigation.PageStackEntry entry) [0x00011] in <d4f183b8dc434848a056dbac2b2444f5>:0
at Windows.UI.Xaml.Controls.Frame.InnerNavigateUnsafe (Windows.UI.Xaml.Navigation.PageStackEntry entry, Windows.UI.Xaml.Navigation.NavigationMode mode) [0x0009e] in <d4f183b8dc434848a056dbac2b2444f5>:0
at Windows.UI.Xaml.Controls.Frame.InnerNavigate (Windows.UI.Xaml.Navigation.PageStackEntry entry, Windows.UI.Xaml.Navigation.NavigationMode mode) [0x00000] in <d4f183b8dc434848a056dbac2b2444f5>:0 '
Current behavior
The CalendarDatePicker doesn't work in an iOS environment where more than one Preferred Language is set via the Settings App.
Expected behavior
CalendarDatePicker works regardless of the Preferred Languages set.
How to reproduce it (as minimally and precisely as possible)
Download this sample: CalendarDatePickerLanguageBug.zip
Go to your device Settings App > General > Language and regions and set the following:
Preferred languages: English, Italian
Region: United States
Deploy and run the sample on iOS
It crashes with the following error:
Workaround
None that I know of
Works on UWP/WinUI
None
Environment
Uno.UI / Uno.UI.WebAssembly / Uno.UI.Skia, Uno.SourceGenerationTasks, Uno.UI.RemoteControl / Uno.WinUI.RemoteControl
NuGet package version(s)
4.8.39
Affected platforms
iOS
IDE
Visual Studio 2022
IDE version
17.5.0
Relevant plugins
No response
Anything else we need to know?
No response