Bug: ArgumentOutOfRangeException: Not a valid calendar for the given culture.

More
3 years 1 week ago #4246 by Mike9000
Hi everyone, Cloud Diagnostics just reported this exception coming from I2 used on Android with a Thai (th) system language.
(I have English, Spanish and German enabled)
System.Globalization.DateTimeFormatInfo.set_Calendar (System.Globalization.Calendar value) (at <00000000000000000000000000000000>:0)
System.Globalization.CultureInfo.get_DateTimeFormat () (at <00000000000000000000000000000000>:0)
System.Globalization.CultureInfo.GetFormat (System.Type formatType) (at <00000000000000000000000000000000>:0)
System.Globalization.DateTimeFormatInfo.get_CurrentInfo () (at <00000000000000000000000000000000>:0)
System.DateTimeParse.ParseExactMultiple (System.String s, System.String[] formats, System.Globalization.DateTimeFormatInfo dtfi, System.Globalization.DateTimeStyles style) (at <00000000000000000000000000000000>:0)
I2.Loc.LanguageSourceData.Import_Google (System.Boolean ForceUpdate, System.Boolean justCheck) (at <00000000000000000000000000000000>:0)
I2.Loc.LocalizationManager.AddSource (I2.Loc.LanguageSourceData Source) (at <00000000000000000000000000000000>:0)
I2.Loc.LocalizationManager.RegisterSourceInResources () (at <00000000000000000000000000000000>:0)
I2.Loc.LocalizationManager.UpdateSources () (at <00000000000000000000000000000000>:0)
I2.Loc.LocalizationManager.InitializeIfNeeded () (at <00000000000000000000000000000000>:0)
I2.Loc.LocalizationManager.get_CurrentLanguage () (at <00000000000000000000000000000000>:0)
I2.Loc.Localize.OnLocalize (System.Boolean Force) (at <00000000000000000000000000000000>:0)
LoadScene+<ClosePopup>d__2.MoveNext () (at <00000000000000000000000000000000>:0)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <00000000000000000000000000000000>:0)
<ClosePopup>d__2:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

Please Log in or Create an account to join the conversation.

More
3 years 1 week ago #4247 by Mike9000
More exceptions over night, all coming from thai language users. Any idea how I can combat this? On a quick look, this seems to come from the module that checks for when to update from the Google sheet? Any idea if disabling this is enough to put a stop to this?

Please Log in or Create an account to join the conversation.

More
3 years 1 week ago - 3 years 1 week ago #4248 by Frank
Hi,
It looks like the DateTime.TryParse is not working correctly for the Thai culture information as it requires a different date format than what google sents back.

You can solve that issue by replacing the DateTime.TryParse in
Assets/I2/Localization/Scripts/LanguageSource/LanguageSourceData_Import_Google.cs line 120

from:
try
{
	if (DateTime.TryParse( sTimeOfLastUpdate, out TimeOfLastUpdate ))
	{
		double TimeDifference = (DateTime.Now-TimeOfLastUpdate).TotalDays;
		switch (updateFrequency)

to
try
{
	if (DateTime.TryParse( sTimeOfLastUpdate, CultureInfo.InvariantCulture, DateTimeStyles.None, out TimeOfLastUpdate ))
	{
		double TimeDifference = (DateTime.Now-TimeOfLastUpdate).TotalDays;
		switch (updateFrequency)

I will add that change to the plugin and release a new version as soon as posible.

Thanks for reporting this issue.
Frank

Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out
Last edit: 3 years 1 week ago by Frank.
The following user(s) said Thank You: Mike9000, combatsheep

Please Log in or Create an account to join the conversation.

More
2 years 9 months ago - 2 years 9 months ago #4305 by combatsheep
if (DateTime.TryParse( sTimeOfLastUpdate, CultureInfo.InvariantCulture, DateTimeStyles.None, out TimeOfLastUpdate ))
I tryed it, but get 2 errors.
[Error] The name 'CultureInfo' does not exist in the current context
Compiler.Compiler() at LanguageSourceData_Import_Google.cs
[Error] The name 'DateTimeStyles' does not exist in the current context
Compiler.Compiler() at LanguageSourceData_Import_Google.cs

How can I fix it?
Thanks.

<Added>
When I added "using System.Globalization;" to "LanguageSourceData_Import_Google.cs", these two problems were solved, but I still get the error "at System.Globalization.DateTimeFormatInfo" of the main subject and it is not solved. :(

<Added>
I solved it by link.xml!B)
Last edit: 2 years 9 months ago by combatsheep.

Please Log in or Create an account to join the conversation.

Time to create page: 0.143 seconds
Template by JoomlaShine