As a Swift newbie I am trying to localize a simple SwiftUI and Core Data project at Github:
I have added the following en.lproj/Localizable.strings file to my project:
"elo-rating %@" = "Elo rating: %@";
"avg-time %@" = "Average time: %@";
"avg-score %@" = "Average score: %@";
And in my custom SwiftUI View TopRow.swift I am trying to use the above 3 keys:
struct TopRow: View {
let topEntity:TopEntity
var body: some View {
HStack {
DownloadImage(url: topEntity.photo ?? "TODO")
.frame(width: 60, height: 60)
Spacer()
Text(topEntity.given ?? "Unknown Person")
.frame(minWidth: 60, maxWidth: .infinity, alignment: .leading)
Spacer()
VStack {
Text("elo-rating \(topEntity.elo)")
Text("avg-time \(topEntity.avg_time ?? "")")
Text("avg-score \(topEntity.avg_score)")
}.fixedSize(horizontal: true, vertical: false)
}.font(.footnote)
}
}
However only the middle Text with average time is localized properly:
I have also tried the following lines with no success:
"elo-rating %@" = "Elo rating: %ld";
"elo-rating %ld" = "Elo rating: %ld";
"elo-rating %lld" = "Elo rating: %lld";
It just does not work :-) Please help me to find my error.
Use only
%d
.%d
is for an integer typeFor Average score, Use
%lf
.