In my iPhone app, I need to display object counts which I then localize, since English makes the distinction of singular and plural, I do the following
// pseudocode
I just posted JJPluralForm, an adaptation for Mozilla's PluralForm.
With that, you wouldn't have to worry about doing all the if-else
, switch-case
code to do localizing in your code, which becomes impossible to maintain as your number of localizations grow.
Something like the example you gave could be handled with:
[[JJPluralForm sharedManager] pluralStringForNumber:numberOfObjects
withPluralForms:NSLocalizedString(@"N_OBJECTS_PLURAL_STRING", @"")
localizeNumeral:YES];
Each Localizable.strings file then localize N_OBJECTS_PLURAL_STRING
as a semicolon separated list of plural forms. For English, that would be "%@ object;%@ objects"
.
Check out the project for more details.