I have created a Localizable.strings file in Xcode to handle translating my iOS app into several different languages. I have the following code at one point in the app:
Text("\(tasks.count) Tasks")
In other parts of the code where the string is simply "Tasks", I am able to translate this into Spanish relatively easily using the following localizable.string:
"Tasks" = "Tareas";
This does not work when I try to translate the "(tasks.count) Tasks". The 'Tasks' never gets converted. I tried the following localizable.string:
"%@ Tasks" = "%@ Tareas";
That also didn't work. Has anyone run into a similar problem? How did you fix this issue?
Thanks -
This is really frustrating and I don't really understand why this works and the alternatives I explored don't work. Here is the solution:
Text(String(format: NSLocalizedString("Tasks %d", comment: ""),
tasks.count))
My string was:
"Tasks %d" = "Tareas %d";
I'm hoping someone has a good explanation as to why reformatting a dynamic text string as above is needed instead of using the conventional Text("(xyz) Text")