3

I'm creating a UIDatePicker programmatically, and setting its locale with the following code:

datePicker.locale = [[[NSLocale alloc] initWithLocaleIdentifier:@"es_ES"] autorelease];

The datepicker still appears in English (or whatever language I've set the phone to). Anyone have any idea why this does nothing, or how to fix it?

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370
DougW
  • 28,776
  • 18
  • 79
  • 107

2 Answers2

4

As answered here Can I localize a UIDatePicker?, the picker display depends on country settings, not on language settings.

In your example you are changing the language locale only.

Community
  • 1
  • 1
Vlad Grichina
  • 1,059
  • 8
  • 16
0

Try changing the locale of the UIDatePicker's calendar as well:

NSLocale *locale = [[[NSLocale alloc] initWithLocaleIdentifier:@"es_ES"] autorelease];
datePicker.locale = locale; 
datePicker.calendar = [locale objectForKey:NSLocaleCalendar]; 
Don
  • 3,654
  • 1
  • 26
  • 47