I'm trying to localize the date in my widget, I want to use the Italian locale "it" that I already used elsewhere in my main application with this exact code but somehow, on my widget both on the simulator and on real devices the locale doesn't change
This is my date formatter in my ViewModel
static let dateFormat: DateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = "EEEE dd"
formatter.locale = Locale(identifier: "it")
return formatter
}()
and this is how I format the date in my View
Text("\(viewModel.nextDay, formatter: ViewModel.dateFormat)")
It is possible to use SwiftUI locale environment key, like

Text(entry.date, style: .date)
.bold()
.environment(\.locale, Locale(identifier: "it"))
Tested with Xcode 12.1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With