Re: Localization and plural rules revisited
Re: Localization and plural rules revisited
- Subject: Re: Localization and plural rules revisited
- From: Horst Hoesel <email@hidden>
- Date: Tue, 20 May 2008 14:21:25 +0200
Hey Ricky,
[snip]
"0 songs" = "No songs";
"1 song" = "1 song";
"2 songs" = "2 songs";
"3 songs" = "3 songs";
"%d songs" = "%d songs"; // 4 or more
This technical works only for certain languages. Plural rules for
Polish, Russian and Arabic get really complex. For example, I've
seen the following expression to figure out the rule for Russian
(0, 1 or 2):
n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <=4 &&
(n % 100 < 10 || n % 100 >= 20) ? 1 : 2
Each key can thus represent a set of specific values (and such
values may not represent a continuous range). I could statically
put in n keys (where n is the maximum number of plural rules I need).
I don't pretend to know the rules for the languages you mention (I've
been involved in some Russian projects, but don't speak the
language), but the code snippet 'smells' like it is used for ordinals
(1st, 2nd, 3rd, 4th, ... 11th but 21st, 31st aso.). Ordinals are a
completely separate and maybe more complex issue. I still believe
(though less firmly now ;) the scheme I sketched is ok for counting
items in languages which are included in Mac OS X.
But the problem becomes that each individual rule drastically
changes from language to language. Although, there would probably
be a separate translator for each language, and instructions could
be provided as to what rule each key represents for that specific
language.
If the rules are that complex, I'd go out to the translators and let
them lay down the general rules in writing and then have dedicated
code and supporting strings for each language. Not that I don't trust
translators to get it right (part of my job is actually doing
localization, so I'm biased here :), but I'd fear the complexity of
maintaining the information in lots of different places. Also once
the issue is solved I'd create a small framework/class/whatever to be
able to reuse it.
Cheers,
Horst
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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