Previews Locale - not working

Try to modify Locale in previews, to see how it looks but it didn't work,

Code: import SwiftUI

struct SettingsView: View {     var body: some View {         VStack {             Text("Current Locale : (Locale.current.identifier)")             Text("Hoy es: (dateToString(Date()))")         }     } }

struct SettingsView_Previews: PreviewProvider {     static var previews: some View {             SettingsView()                 .environment(.locale, Locale(identifier: "es_AR"))

            SettingsView()                 .environment(.locale, Locale(identifier: "fr"))     }

}

Replies

Sorry to hear you are having problems getting locale with previews working. This should work if your strings file is called Localizable.string. Could you verify that this is the case in your app?

I forgot the function: //datetoString

func dateToString(_ value: Date) -> String {     let formatter = DateFormatter()     formatter.locale = Locale.current     formatter.dateStyle = .short     return formatter.string(from: value) }

Basically I want to verify how the day is presented based on Locale.current MM/DD/YY or DD/MM/YYYY. and show string of Locale.current.