How to handle plurals in localisation objective-c iOS

I’m going through this page to see how to handle plurals.

I’ve added an english.stringsdict which contains the following.

<plist version="1.0">
        <key>%d file(s) remaining</key>
                <string>%d file remaining</string>
                <string>%d files remaining</string>

I’ve set the localisation property in the file inspector to english
I have a Localizable.strings also set to english which contains the following.

/* Message shown for remaining files */
"%d file(s) remaining" = "%d file(s) remaining";

I’ve set application language in schema to english.

I’m setting label text like this

self.label.text = [NSString localizedStringWithFormat:NSLocalizedString(@"%d file(s) remaining", @"Message shown for remaining files"), count];

What is being displayed is “5 file(s) remaining”

What I want to display is 5 files remaining or 1 file remaining if there is one file.

Source: ios

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.