I am trying to use the new support for more complex localization of plurals in iOS 7. I created a .stringdict file formatted according to the information in the Foundation release notes (and What New In Cocoa WWDC session). I checked that .stringdict is being copied to my application package (and really -[NSBundle pathForResource:...]finds it). However, it +[NSString localizedStringWithFormat:]does not return a string formatted according to the rules in the configuration dictionary.
code:
- (IBAction)textFieldEditingDidEnd:(UITextField *)sender
{
NSInteger numPeople = [sender.text integerValue];
self.textView.text = [NSString localizedStringWithFormat:
NSLocalizedString(@"%d people are in the room", @"%d people are in the room"), (long)numPeople];
}
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>%d people are in the room</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@num_people_in_room@ in the room</string>
<key>num_people_in_room</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>d</string>
<key>zero</key>
<string>No one is</string>
<key>one</key>
<string>A person is</string>
<key>two</key>
<string>Two people are</string>
<key>other</key>
<string>%d people are</string>
</dict>
</dict>
</dict>
</plist>
, : https://www.dropbox.com/s/mfze377g0r1iqde/PluralDemo.zip. , -localizedStringWithFormat:.
- ? - ?