I'm trying to show a formatted date at my device's language but it keeps showing in English (even though the device is set to Portuguese).
At my ViewController I created a date:
let todaysDate: Date = Date()
And I call this function (that it's an extension of Date):
func getFullDate() -> String {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "dd MMMM yyyy"
dateFormatter.calendar = Calendar.current
dateFormatter.locale = Locale.current
return dateFormatter.string(from: self)
}
The output is always in English:
08 March 2019
I also checked if the Locale.current is correct in the terminal and I got:
▿ en_BR (current)
I don't want to define the language hardcoded because I want to support other languages, but it's not working. Could you please give me any tips on how to solve this?
Thank you very much for your help!
I just found out that I only had Localized strings for English and as rmaddy pointed out in this link with iOS 11 I also need to have a Localized string file for the language I want to support (in my case Portuguese).
So I just added support for Portuguese at Language localization section and now it's working correctly! :D