I'm trying to get the localized weekday from an nsdate object
+ (NSString *)localizedWeekdayForDate:(NSDate *)date
{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
NSString *language = [[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0];
dateFormatter.dateFormat = [NSDateFormatter dateFormatFromTemplate:@"EEEE" options:0 locale:[NSLocale localeWithLocaleIdentifier:language]];
NSString *formattedDateString = [dateFormatter stringFromDate:date];
return formattedDateString;
}
The language string is always "en" ... even thou the device language is not english... I tried [NSLocale currentLocale]; as well as preferedLanguages... this also doesn't work..
Any suggestions?
You are forgetting to set the local of the dateFormatter: