Do you have any idea why the following codes are not working? You can reproduce on your example project by inserting below code snipped somewhere and you are going to see that the result string is based on device language not the set Locale.
Not Working 1
String(localized: "Hello")
Not Working 2
NSLocalizedString("Hello", comment: "")
Working
MainView.swift Reproduce
struct MainView: View {
// MARK: - State properties
@State private var isPresented = false
// MARK: - body
var body: some View {
NavigationView {
VStack {
Image("logo")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 240, height: 100)
Text("Hello")
.fontWeight(.bold)
.padding()
Text("About")
.padding()
Button("Change the language") {
isPresented = true
}
}
.navigationTitle(String(localized: "Hello"))
}
.buttonStyle(AppButtonStyle())
.fullScreenCover(isPresented: $isPresented) {
LangaugeView()
}
}
}
Do you have any idea why the following codes are not working? You can reproduce on your example project by inserting below code snipped somewhere and you are going to see that the result string is based on device language not the set Locale.
Not Working 1
Not Working 2
Working
MainView.swift Reproduce