exception : Not a valid calendar for the given culture. Parameter name: value
---------------------------------------------------------------------------------------
iOS에서 시스템 언어가 태국어(Thai) 일 때, 위와 같은 에러가 나서 확인해보니,
il2cpp에서 태국어 일 때 CultureInfo를 제대로 생성 못하는 버그가 있다고 한다.
그래서 [참조] 링크의 내용을 참조해서 아래와 같이 소스를 넣고, 앱 시작 시 실행하도록 소스를 추가 했다.
(아랍어도 같은 이슈가 있다고 해서 소스를 같이 추가함)
public static void InitArabicCalendarCrashFix()
{
// Two Letter ISO Language
string strTwoLetterISOLanguage = System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;
Debug.LogFormat("[CurrentCulture.strTwoLetterISOLanguage] {0}", strTwoLetterISOLanguage);
if (strTwoLetterISOLanguage == "ar")
{
new System.Globalization.UmAlQuraCalendar();
}
// CultureName
//string strCurrentCultureName = System.Threading.Thread.CurrentThread.CurrentCulture.Name;
//Debug.LogFormat("[CurrentCulture.Name] {0}", strCurrentCultureName);
//if (strCurrentCultureName == "ar-SA")
//{
// new System.Globalization.UmAlQuraCalendar();
//}
}
public static void InitThaiCalendarCrashFix()
{
// Two Letter ISO Language
string strTwoLetterISOLanguage = System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;
Debug.LogFormat("[CurrentCulture.strTwoLetterISOLanguage] {0}", strTwoLetterISOLanguage);
if (strTwoLetterISOLanguage == "th")
{
new System.Globalization.ThaiBuddhistCalendar();
}
// CultureName
//string strCurrentCultureName = System.Threading.Thread.CurrentThread.CurrentCulture.Name;
//Debug.LogFormat("[CurrentCulture.Name] {0}", strCurrentCultureName);
//if (strCurrentCultureName == "th-TH")
//{
// new System.Globalization.ThaiBuddhistCalendar();
//}
}
[참조]
forums.xamarin.com/discussion/42899/datetime-tostring-throws-argumentoutofrangeexception-in-thai-locale
DateTime.ToString() throws ArgumentOutOfRangeException in Thai locale
Hi, We're seeing an issue when our app is being used on iOS when in the Thai locale, seemingly down to the DateTime.ToString() method throwing an ArgumentOutOfRangeException with the message "Not a valid calendar for the given culture".
forums.xamarin.com