我正在尝试从两者Localizable.stringsdict
和Localizable.strings
使用String.localizedStringWithFormat()
方法中获取本地化字符串以及单/复数本地化。但是这个方法返回thousand separator/group separator
我不想要的字符串。有没有办法在没有千位分隔符的情况下获得本地化字符串以及数字本地化?以下是我的Localizable.stringsdict
:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>v1_pineapples_count</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@variable@</string>
<key>variable</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>d</string>
<key>zero</key>
<string>John has no pineapples</string>
<key>one</key>
<string>John has 1 pineapple</string>
<key>other</key>
<string>John has %d pineapples</string>
</dict>
</dict>
</dict>
</plist>
我获取本地化字符串的代码是:
let formatString : String = NSLocalizedString("v1_pineapples_count", comment: "")
let resultString : String = String.localizedStringWithFormat(formatString, 1000)
Current output is John has 1,000/١,٠٠٠ pineapples Expected output is John has 1000/١٠٠٠ pineapples