作为一个 Swift 新手,我正在尝试在 Github 本地化一个简单的 SwiftUI 和 Core Data 项目:
我已将以下en.lproj/Localizable.strings文件添加到我的项目中:
"elo-rating %@" = "Elo rating: %@";
"avg-time %@" = "Average time: %@";
"avg-score %@" = "Average score: %@";
在我的自定义 SwiftUI View TopRow.swift中,我尝试使用上述 3 个键:
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)
}
}
然而,只有平均时间的中间文本被正确本地化:
我也尝试了以下几行但没有成功:
"elo-rating %@" = "Elo rating: %ld";
"elo-rating %ld" = "Elo rating: %ld";
"elo-rating %lld" = "Elo rating: %lld";
它只是不起作用:-)请帮助我找到我的错误。