I want to get localized week day. On xCode, my app has only english language for the moment and I set the application region to "French".
When I run this code :
print("\(Calendar.current.locale)")
print("\(Calendar.current.shortWeekdaySymbols)")
I have this output:
Optional(en_FR (current))
["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
I understand "en_FR" as "en" because my only language is english, and FR is the region. But why shortWeekdaySymbols is not consistent with my FR region?
Then read them
let prefLanguage = Locale.preferredLanguages[0]
and replace
calendar.locale = NSLocale(localeIdentifier: "fr_FR") as Locale
with
let prefLanguage = Locale.preferredLanguages[0]
var calendar = Calendar(identifier: .gregorian)
calendar.locale = NSLocale(localeIdentifier: prefLanguage) as Locale