Localizing Dynamic Plural Noun messages (e.g. “5 Items Processed”) on iPhone using Objective-C

后端 未结 4 1086
故里飘歌
故里飘歌 2020-12-22 23:50

In my current app, I have code that displays a message, e.g. \"5 Items Processed.\" To keep the phrase grammatically correct, i.e. whether or not it should be \"5 Item\" or

4条回答
  •  [愿得一人]
    2020-12-23 00:36

    I would consider alternative ways to display the same information, perhaps something like:

    @"Items processed: %d"
    

    MDC has a long, comprehensive list of pluralisation rules if you're interested, but I really don't think it is worth the effort to implement all these rules. Another thing you might have to consider is if any languages would have the number appear after the pluralisation, as it would throw your format string off (I can't think of any languages that would off the top of my head, but perhaps a place for caution in any of your more complicated localised strings with numbers involved).

提交回复
热议问题