0

My iOS application supports 6 languages. Now I want to show localized month names.

e.g. January in French will show "Janvier"

For this I have below code while converting date from UTC to local time zone

    -(NSString *)getLocalDateFromUTCFormattedDate:(NSString*)utcDate
{
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    NSTimeZone *sourceTimeZone = [NSTimeZone timeZoneWithName:@"UTC"];
    [dateFormatter setTimeZone:sourceTimeZone];
    [dateFormatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH:mm:ss'Z'"];
    NSDate *dateFromServer = [dateFormatter dateFromString:utcDate];

    // Now convert to local date
    dateFormatter.locale = [NSLocale systemLocale];
    [dateFormatter setDateFormat:@"dd MMMM yyyy"];
    NSTimeZone* localTimeZone = [NSTimeZone systemTimeZone];
    [dateFormatter setTimeZone:localTimeZone];
    NSString *localDate = [dateFormatter stringFromDate:dateFromServer];
    return localDate;
}

But month name is still in english even after I change the language to french / japanese. I got this link , but I don't want to hardcode the locale. So I have used

dateFormatter.locale = [NSLocale systemLocale];

But no luck. Can anybody tell me whats wrong in this ?

Community
  • 1
  • 1
iOSAppDev
  • 2,755
  • 4
  • 39
  • 77

1 Answers1

0

May be this tutorial help you for that.

enter image description here

iBug
  • 2,334
  • 3
  • 32
  • 65
  • I do have .strings file for every language that my app supports. So what you are saying is I need translated month names for every language , right ? Does iOS does not change the month name to the language which is selected from iOS Settings ? – iOSAppDev Jun 26 '14 at 12:34