I am trying to implement plural rules localisation. i.e., I expect "One file..." when the argument is 1, "2 files..." when the argument is 2 and likewise.
I followed the Apple guidelines. But I always get the results for plural, even for 1 i.e, "1 files...".
I've created a Localizable.stringsdict file with the following content (exactly like the apple guidelines).
<?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>%d messages in your inbox</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@messages@ in your inbox</string>
<key>messages</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>d</string>
<key>one</key>
<string>One message is</string>
<key>other</key>
<string>%d messages are</string>
</dict>
</dict>
</dict>
</plist>
This is how I use this key in code
NSLog(@"%@", [NSString localizedStringWithFormat:NSLocalizedString(@"%d messages in your inbox", @"Message shown for remaining files"), 1]);
What could be the problem?. Here is the sample code I have tried so far.
While debugging, I've noticed that Localization.stringsdict
file is just ignored. When I've recreated it, everything started to work properly. I guess the original file was created with the wrong type: the correct type should be Property List
.
I've sent a pull request as you suggested.