Polish Months appear to be translated incorrectly

When using the date format "MMMM" our Polish users are seeing incorrect month names. I'm not a native speaker, but was informed iOS is using the wrong possessive tense. The month names should be as below (Jan-Dec):

  • Styczeń
  • Luty
  • Marzec
  • Kwiecień
  • Maj
  • Czerwiec
  • Lipiec
  • Sierpień
  • Wrzesień
  • Październik
  • Listopad
  • Grudzień

Can anyone confirm and correct if necessary?

Answered by MaBell in 707988022

In brief:

NSDateFormatter *instance = [[NSDateFormatter alloc] init];
[instance setDateFormat:@ "MMMM yyyy"];
[instance setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
return [instance stringFromDate:self];

From second comment, legacy code isn't setting locale or formattingContext.

Hi, I seem to get these values currently already. Are you using formatter.dateFormat = "MMMM"?

This should not be used to display dates to the user, but rather:

formatter.setLocalizedDateFormatFromTemplate("MMMM")

 

Or rather, I would advise relying on formatter.dateStyle and formatter.timeStyle instead of formats.

See below

Could you include the code you're using? I'm getting the expected values with my source.

let templateFormatter = DateFormatter()
templateFormatter.locale = Locale(identifier: "pl")
templateFormatter.formattingContext = .standalone
templateFormatter.setLocalizedDateFormatFromTemplate("MMMM")
let gregorianCalendar = Calendar(identifier: .gregorian)
for month in 1...12 {
    let date = gregorianCalendar.date(from: DateComponents(era: 1, year: 2022, month: month, day: 1, hour: 0, minute: 0, second: 0))!
    let formattedValue = templateFormatter.string(from: date)
    print(formattedValue)
}
Accepted Answer

In brief:

NSDateFormatter *instance = [[NSDateFormatter alloc] init];
[instance setDateFormat:@ "MMMM yyyy"];
[instance setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
return [instance stringFromDate:self];

From second comment, legacy code isn't setting locale or formattingContext.

Rather than setDateFormat use setLocalizedDateFormatFromTemplate and let the parameter be yMMMM.

Polish Months appear to be translated incorrectly
 
 
Q