Set Default Culture To Culture Of Device

MelbourneDeveloperMelbourneDeveloper AUMember ✭✭✭
edited August 2 in Xamarin.Forms Evolution

Summary

The default culture of the app should default to the culture of the device.

API Changes

Put this line of code somewhere in the startup of all Xamarin apps:

CultureInfo.DefaultThreadCurrentCulture = new CultureInfo(CultureInfo.CurrentUICulture.ToString());

Intended Use Case

Using a Xamarin App.

Note: If this code isn't added, the culture will default to en-US which has the whacky date format that everyone complains about.

0
0 votes

Open · Last Updated

Posts

  • MelbourneDeveloperMelbourneDeveloper AUMember ✭✭✭

    While this is probably useful, it doesn't fix the problem where dates don't display in the format of the local culture automatically. DateTime.ToString() still displays dates in en-US format not matter what you set here.

  • MelbourneDeveloperMelbourneDeveloper AUMember ✭✭✭

    Correction on this. When I posted this, I was working under the assumption that there was an inherent issue with cultures not defaulting to their correct culture on any given device. This is not the case. This is a more specific bug:
    https://bugzilla.xamarin.com/show_bug.cgi?id=58635

Sign In or Register to comment.