Skip to content

Commit

Permalink
Fixed example for localization
Browse files Browse the repository at this point in the history
Just translating words isn't enough. The resulting strings are still not correctly localized, but that's a problem with setLocalizedDateFormatFromTemplate itself.

Correct would be "23. Juni 2015, 16:56", but that would require changing the template from "yyyyMMMMddhhmm" to "yyyyMMMMddHHmm".
  • Loading branch information
Robert Wünsch committed Sep 14, 2015
1 parent ceb42dd commit c7f9e86
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion 2015-06-22-ios9.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,12 @@ shortFormatter.stringFromDate(now)
fullFormatter.locale = NSLocale(localeIdentifier: "de_DE")
shortFormatter.locale = NSLocale(localeIdentifier: "de_DE")

// set the date formats again, because other languages use different formats
fullFormatter.setLocalizedDateFormatFromTemplate("yyyyMMMMddhhmm")
shortFormatter.setLocalizedDateFormatFromTemplate("yyMMMM")

fullFormatter.stringFromDate(now)
// "Juni 23, 2015, 4:56 nachm."
// "23. Juni 2015, 4:56 nachm."
shortFormatter.stringFromDate(now)
// "Juni 15"
```
Expand Down

0 comments on commit c7f9e86

Please sign in to comment.