Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DatePickerCell doesn't support users with Arabic language #122

Open
2 tasks done
TrueGeek opened this issue Jul 24, 2020 · 2 comments
Open
2 tasks done

DatePickerCell doesn't support users with Arabic language #122

TrueGeek opened this issue Jul 24, 2020 · 2 comments

Comments

@TrueGeek
Copy link

Description

On phones with the language set to Arabic we're seeing the following error when using the DatePickerCell

Error is System.ArgumentOutOfRangeException

Specified time is not supported in this calendar. It should be between 04/30/1900 00:00:00 (Gregorian date) and 11/16/2077 23:59:59 (Gregorian date), inclusive.
Parameter name: time

Steps to Reproduce

  1. Change iOS simulator language to Arabic
  2. Open a page with DatePickerCell

Expected Behavior

No crash 👍

Actual Behavior

Yes crash 😞

Platforms

  • Android
  • iOS

Basic Information

  • AiForms.SettingsView x1.0.9
  • Xamarin.Forms 4.6.1073
  • Android Support Library Version:
  • Affected Devices:

Stacktrace

  at System.Globalization.UmAlQuraCalendar.CheckTicksRange (System.Int64 ticks) [0x0001a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/globalization/umalquracalendar.cs:384 
  at System.Globalization.UmAlQuraCalendar.GetDatePart (System.DateTime time, System.Int32 part) [0x0000d] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/globalization/umalquracalendar.cs:490 
  at System.Globalization.UmAlQuraCalendar.GetDayOfMonth (System.DateTime time) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/globalization/umalquracalendar.cs:587 
  at System.DateTimeFormat.FormatCustomized (System.DateTime dateTime, System.ReadOnlySpan`1[T] format, System.Globalization.DateTimeFormatInfo dtfi, System.TimeSpan offset, System.Text.StringBuilder result) [0x003b9] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/Common/src/CoreLib/System/Globalization/DateTimeFormat.cs:586 
  at System.DateTimeFormat.FormatStringBuilder (System.DateTime dateTime, System.ReadOnlySpan`1[T] format, System.Globalization.DateTimeFormatInfo dtfi, System.TimeSpan offset) [0x000bb] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/Common/src/CoreLib/System/Globalization/DateTimeFormat.cs:1132 
  at System.DateTimeFormat.Format (System.DateTime dateTime, System.String format, System.IFormatProvider provider, System.TimeSpan offset) [0x0009a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/Common/src/CoreLib/System/Globalization/DateTimeFormat.cs:1037 
  at System.DateTimeFormat.Format (System.DateTime dateTime, System.String format, System.IFormatProvider provider) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/Common/src/CoreLib/System/Globalization/DateTimeFormat.cs:1006 
  at System.DateTime.ToString (System.String format) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/Common/src/CoreLib/System/DateTime.cs:1285 
  at AiForms.Renderers.iOS.DatePickerCellView.UpdateDate () [0x0003b] in <6fe2a7ae3f3a4c32b996efb9688dfe87>:0 
  at AiForms.Renderers.iOS.DatePickerCellView.UpdateMaximumDate () [0x0001b] in <6fe2a7ae3f3a4c32b996efb9688dfe87>:0 
  at AiForms.Renderers.iOS.DatePickerCellView.UpdateCell () [0x00006] in <6fe2a7ae3f3a4c32b996efb9688dfe87>:0 
  at AiForms.Renderers.iOS.CellBaseRenderer`1[TnativeCell].GetCell (Xamarin.Forms.Cell item, UIKit.UITableViewCell reusableCell, UIKit.UITableView tv) [0x00044] in <6fe2a7ae3f3a4c32b996efb9688dfe87>:0 
  at AiForms.Renderers.iOS.SettingsTableSource.GetCell (UIKit.UITableView tableView, Foundation.NSIndexPath indexPath) [0x00047] in <6fe2a7ae3f3a4c32b996efb9688dfe87>:0 
  at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.3.2/src/Xamarin.iOS/UIKit/UIApplication.cs:86 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.3.2/src/Xamarin.iOS/UIKit/UIApplication.cs:65 
  at AgentApp.iOS.Application.Main (System.String[] args) [0x00001] in /Users/bdean/code/AgentAppNew/AgentApp.iOS/Main.cs:24 
@TrueGeek
Copy link
Author

Workaround

I was able to find a workaround. In app.xaml.cs I'm manually changing the culture to one that uses a Gregorian calendar:

`
public App()
{

        InitializeComponent();

        System.Globalization.CultureInfo.DefaultThreadCurrentCulture = new System.Globalization.CultureInfo("en-US");

`

Note that this works for us because we handle i18n string substitution by setting the language in a setting. Then, when we do string substitutions we check the value in that setting, not the current culture. If you are relying on the CultureInfo then, obviously, this will change all of your app's language strings to English.

I've tested that this works on both iOS and Android. The date picker is still shown in the native language since it's a native control:

iOS:
image

Android:
image

I'm not sure what the solution is to fix this in AiForms.SettingsView.

@muak
Copy link
Owner

muak commented Oct 1, 2020

@TrueGeek
Thank you for the helpful information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants