I am trying to get localized string along with singular/plural localization from both Localizable.stringsdict and Localizable.strings using String.localizedStringWithFormat() method. But this method returns string with thousand separator/group separator which I don't want. Is there any way to get localized string along with digit localization without thousand separator? Following is my 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>
My code for getting localized string is:
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
Since I did not find any way to remove the thousand separator but keep digit localization as well as singular/plural localization, I wrote this extension for my project. For now it is serving me well. Hope it will help someone with same requirements.