3

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.

Martin Koles
  • 5,177
  • 8
  • 39
  • 59

2 Answers2

0

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.

Martin Koles
  • 5,177
  • 8
  • 39
  • 59
  • How to fix without localisation , but providing manually language preferences. – umer sufyan Feb 26 '18 at 15:50
  • I don't think this is possible, but you can try it. I would suggest to do the key in info.plist as suggested above and then change locale of the UIDatePicker in storyboard or in code as seen in the question above. But I don't think it is going to work. – Martin Koles Feb 26 '18 at 19:19
  • 1
    that's simple a bug in UIDatepicker it does't change to locale if its type is set to countdowntimer. all others mode are working fine except this one. and as you suggested i did that but no luck – umer sufyan Feb 27 '18 at 10:14
  • @umersufyan I'm facing the same issue. Have you resolved it yet? – Duan Nguyen May 03 '18 at 03:43
  • 1
    @MartinKoles this does't work in case of UIDatepicker in countdown mode – umer sufyan May 04 '18 at 07:17
  • @Duan nguyen This did work for me and thanks to the solution the app shows correctly Stunden and Minuten in German language in Datepicker in countdown mode, or in any other language the iOS is set to. – Martin Koles May 04 '18 at 10:48
  • 1
    @MartinKoles of course it works with device locale. It doesn't work in case you wanna specific a locale. Btw, I used this code and it worked: https://github.com/LukasCZ/GSTimeIntervalPicker – Duan Nguyen May 04 '18 at 11:03
0

I am mentioning here reply from APPLE that i got upon Technical support on this specific issue but unfortunately there is no support to this feature yet.

When running in the count down mode, UIDatePicker showns the hours and minutes to count down. In this context, the “hours” and “minutes” are not a format, thus not covered by locale;

Thing is that they did not mention any time line for support of this feature.

umer sufyan
  • 1,005
  • 1
  • 12
  • 22
  • The statement from Apple is interesting as the solution in my answer correctly adjusts units of the Datepicker in countdown mode according to the language the iOS is set to. – Martin Koles May 04 '18 at 10:51
  • share screen shot and share your code please. if that works great, then we need to talk to Apple, by the way that was in March 2018 . not so long – umer sufyan May 04 '18 at 11:06