Singular/Plural and the strings file


I notice that my Raiseman app asks “1 people will be removed.” This should obviously be “1 person will be removed.” I assume you cannot put logic in the strings file? If not, is the only option to put the logic to pick the correct string ala:


Then call stringToUse in alertWithMessageText?

Is there a more elegant way to do this?


Unfortunately I don’t think there is a more graceful way of handling this. However, due to how genstrings works, you would need to do it like this if you want to use genstrings (recall that genstrings scans the file for NSLocalizedString occurrences):

if ([selectedPeople count] == 1) str = NSLocalizedString(@"REMOVE_MSG",@""); else str = NSLocalizedString(@"REMOVE_MSG_PLURAL",@"");


Ah, good point. Thanks for the clarification.


Thank you for this post, and explanation. In making the changes to RaiseMan outlined in ch. 16, I chose to use Spanish, since I speak the language. Also, I chose to use appropriate singular/plural grammar, as pointed out in this post. And so, I was faced with the following situation:



As you can see, the English string has two format substitutions, whereas the Spanish one has four. So I am glad for Adam’s suggestions; although, of course, I wish Cocoa had a more clever way to handle this in-line.

Just sharing my situation; not asking a question.