Get the System language
struct ContentView: View {
var locale: Locale
var localeIdentifier: String = Locale.current.identifier.lowercased().replacingOccurrences(of: "_", with: "-")
// get system language
public init(locale: Locale = .autoupdatingCurrent) {
self.locale = locale
}
public init(localeIdentifier: String) {
self.locale = Locale(identifier: localeIdentifier)
}
public var body: some View {
VStack(spacing: 35.0) {
Text(self.locale.description)
.font(.system(size: 25, weight: .bold, design: .default))
Text(self.localeIdentifier)
.font(.system(size: 25, weight: .bold, design: .default))
}
}
}