Localization and plural rules revisited
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