I'm currently trying to understand why this little piece of code doesn't work as expected:
// ContentView.swift (before var body: some View)
let name = "Emma"
// ContentView.swift (inside var body: some View)
Text("hello-name \(name)")
// Localizable.strings
"hello-name %@" = "Hello, my name is %@";
I have also tried using NSLocalizedString
as sometimes it does the trick:
// ContentView.swift (inside var body: some View)
Text(String(format: NSLocalizedString("hello-name %@", comment: "Name"), name))
Text(String(format: NSLocalizedString("hello-name %@", comment: "Name"), name as String))
Text(String(format: NSLocalizedString("hello-name %@", comment: "Name"), name as CVarArg))
But still I don't get Hello, my name is Emma
. Do you know why? Thanks!