Localizable.strings 适用于字符串,但不适用于双精度和整数 32

Localizable.strings works for String, but not for Double and Integer 32

作为 Swift 新手,我正在尝试将 a simple SwiftUI and Core Data project 本地化为 Github:

我已将以下 en.lproj/Localizable.strings 文件添加到我的项目中:

"elo-rating %@" = "Elo rating: %@";
"avg-time %@" = "Average time: %@";
"avg-score %@" = "Average score: %@";

在我的自定义 SwiftUI 视图中 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";

它根本不起作用:-)请帮我找出我的错误。

仅使用 %d%d 是整数类型

"elo-rating %d" = "Elo rating: %d";

对于平均分,使用%lf

"avg-score %lf" = "Average score: %lf";