locked
Localization DatePicker and TimePicker

    Question

  • How do you localize the DatePicker and the TimePicker?

    Our use case is that the user will set the language in the control panel and we will try to display the correct datepicker/timepicker format.

    I tried setting the DatePicker/TimePicker Language property but it still is set to English and the order is still in english format (Month date year) for Date Picker and (Hour minutes AM/PM) for timepicker.

    I did try the DatePicker.CalendarIdentifier and it did change the date format of the datepicker. So for a Japanese language, it was correctly set, but the timepicker only has a clockidentifier, so it did not change the display (AM/PM is still in english).

    Does it mean that I have to identify the language and set the calendaridentifer/clockidentifier manually?

    Thanks in advance!

    UPDATE:

    I did found out about the GlobalizationPreference and I could set it to the Date and TimePicker:

    var calendar = Windows.System.UserProfile.GlobalizationPreferences.Calendars[0];
    var clock = Windows.System.UserProfile.GlobalizationPreferences.Clocks[0];

    If I set the region settings to Japanese, the clock is correctly set to 24HourClock. But the calendar is still set to GregorianCalendar.

    Is this a bug or there is a different way to set the calendar so that I could retrieve correctly the GlobalizationPreferences.Calendar?


    • Edited by gianime Wednesday, March 11, 2015 9:42 AM
    Wednesday, March 11, 2015 7:40 AM

All replies

  • Yes they are the same question because I created both question here and on stackoverflow since I am not sure if anyone would be able to answer it...
    Monday, March 16, 2015 2:22 AM
  • I was able to fix my issue on this one.

    Somehow, although I have already set the regional settings and language settings in the control panel (example: japanese), the datepicker.Language and timepicker.Language still uses the Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride that was set. Eventhough I set the language in the control (datepicker and timepicker) to japanese.

    So what I did is that, in the startup of the application, app.xaml.cs, I set the Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride this to an empty string and now it follows the setting I set in the language settings and region settings.

    It is not the best solution but for now this one works. I have been trying to solve this for days and this is the only one that worked.

    This could be a workaround instead of a fix but I would do with this while the datepicker.calendar still returns the gregorian calendar.

    Friday, March 20, 2015 2:18 AM