iosuidatepickernslocale

Changing locale of UIDatePicker in Countdown Timer mode


I have UIDatePicker in CountdownTimer mode and need to change the wording of hours and min to German locale. I tried both, to set locale to German (Germany) in storyboard and in code, but both failed and the app still shows default english words for hours and min.

timePicker.locale = Locale(identifier: "de")

When I configure locale on UIDatePicker in Date and Time mode, it correctly respects German locale and displays the date in german format. Any idea why locale does not change in Countdown timer mode? Thank you.


Solution

  • Thanks to Why UIActivityViewController doesn't display localized cancel string? post the solution also resolved the issue of localizing UIDatePicker in countdown timer mode, at least on iOS 11. Thank you.

    Add this row into your info.plist:

    enter image description here

    And it also helps to correctly localize Cancel button of the system share sheet: UIActivityViewController - how to change the cancel button text.