0
我試圖讓當前的月份和葡萄牙語書寫得一個月,但NSLocale PT_BR不工作...它的英文:在葡萄牙
let date = NSDate()
let calendar = NSCalendar.currentCalendar()
calendar.locale = NSLocale(localeIdentifier: "pt_BR")
let components = calendar.components([.Month , .Year], fromDate: date)
let dateFormatter: NSDateFormatter = NSDateFormatter()
dateFormatter.locale = NSLocale(localeIdentifier: "pt_BR")
let months = dateFormatter.shortMonthSymbols
let year = components.year
let month = components.month
let monthSymbol = months[month-1] // month - from your date components
Tudo bem。它按預期工作。考慮模擬器的默認語言環境是「en_US」。 – vadian