0
1..2のような範囲を含む文字列をローカライズしようとしています。私はString.localizedStringWithFormat
を使用しています:String.localizedStringWithFormatが間違った結果を返します
func testLocalizableString() -> String {
let lowerBound = 1
let upperBound = 2
return String.localizedStringWithFormat(
NSLocalizedString("Unit.Meters.Range", value:"%d-%dm", comment: ""),
[lowerBound, upperBound]
)
}
しかし、私は奇妙な結果を得る: "103,413,600-0mを"。
1つの引数(「%dm」のみで、「%d-%dm」ではなく)を使用して1つの数値だけを渡すと、すべて問題ありません。
私のコードに間違いがあり、CVarArg引数でローカライズ可能な文字列を適切にフォーマットする方法はありますか?
func testLocalizableString() -> String {
let lowerBound = 1
let upperBound = 2
return String.localizedStringWithFormat(
NSLocalizedString("Unit.Meters.Range", value:"%ld-%ldm", comment: ""),
lowerBound, upperBound
)
}
注