• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Localization and plural rules revisited
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Localization and plural rules revisited


  • Subject: Localization and plural rules revisited
  • From: Ricky Sharp <email@hidden>
  • Date: Mon, 19 May 2008 22:02:08 -0500

There was a very short thread on NSLocalizedString regarding plural rules:

<http://lists.apple.com/archives/cocoa-dev/2007/Oct/msg01208.html>


My app is mainly localization ready, but I still need to modify some problem code regarding plurals. Specifically, I have code which takes some quantity 'n' and pulls an appropriate localized string.


But, in English, there are only two plural rules and thus I currently only have two separate strings. While this exact code would work for a few languages (e.g. Spanish), it would fail for languages with different quantities of plural rules.

I looked at several of Apple's apps (iTunes, Address Book, Safari) and there seems to be a different strategy regarding plural rules. For example, in English .strings, you have this:

1 song
%d songs

In Russian (which has three plural rules), they kind of "cheated" by still only having two strings:

1 song
songs: %d


Is this really the common practice? To basically force all languages to just use two strings?



I thought of doing the following instead:

Figure out plural rules for given locale. This rule theoretically could be an entry in the .strings file itself that could be parsed to denote a function. Such a function would return the ordinal "plural rule" value given some quantity "n". The ordinal value would then get appended to the base key.

So, in languages with two rules, you'd have something like this:

"%d song_0" = "%d song";
"%d song_1" = "%d songs";

In languages with 5 plural rules, you'd then have 5 keys ("%d song_0" .. "%d song_4").

Has anyone else tackled this problem?

___________________________________________________________
Ricky A. Sharp         mailto:email@hidden
Instant Interactive(tm)   http://www.instantinteractive.com

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Localization and plural rules revisited
      • From: Horst Hoesel <email@hidden>
  • Prev by Date: Re: Cocoa et al as HCI usability problem
  • Next by Date: Re: NSStream, NSInputStream, NSOutputStream
  • Previous by thread: Re: Cocoa-dev Digest, Vol 5, Issue 837
  • Next by thread: Re: Localization and plural rules revisited
  • Index(es):
    • Date
    • Thread