Re: Localization and plural rules revisited
Re: Localization and plural rules revisited
- Subject: Re: Localization and plural rules revisited
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Wed, 21 May 2008 00:20:24 +0200
On 20 May 2008, at 23:03, email@hidden wrote:
On May 20, 2008, at 12:08 PM, Peter Edberg wrote:
CLDR (Common Locale Data Repository) has some draft data on plural
forms for various languages. See
<http://unicode.org/cldr/data/charts/supplemental/
language_plural_rules.html
for specific rules
and
<http://unicode.org/draft/reports/tr35/
tr35.html#Language_Plural_Rules> for background info.
These are by far the best references I've seen to date. Thanks! Very
interesting that Ukrainian has a special rule for fractional values
vs. integers.
Anyhow, what follows is a summary of what I've learned, and what
approach I plan to take. I'll also mention a few things regarding
other replies to this thread.
First, the MessageFormat and ChoiceFormat classes from the ICU project
just won't cut it. Too limited to handle various languages. There is
a followup class named PluralFormat which does work, but the syntax is
quite difficult. And, what Horst Hoesel brought up, you don't want to
cause difficulties for translators.
In this case you might use in your scheme below a typical value
instead of the Icu category, e.g. in Russian use PluralForm5 instead
of PluralFormMANY. Or PluralForm2 instead of PluralFormOTHER in English.
I'm going to modify my code to create a utility object that will build
up appropriate keys based upon what locale the user is currently using
for my app's interface. Each time I add another language to the list
of localizations, I'll add in an appropriate rule function. The
function simply takes the quantity (n) and spits out what category
should be used. Category is the term used by the unicode.org links
above.
Anyhow, imagine a key which is typically the original English phrase.
I currently have:
"Move 1 unit to the right." = "Move 1 unit to the right.";
"Move %d units to the right." = "Move %d units to the right.";
Change will be:
"PluralFormONE_Move %d unit(s) to the right." = "Move 1 unit to the
right.";
"PluralFormOTHER_Move %d unit(s) to the right." = "Move %d units to
the right.";
i.e. the base key is now common to all entries. I then prefix
"PluralForm" which gives translators something to search on.
Following that prefix would be category as shown on the unicode.org
link above.
Finally, calling code would be something like this:
NSLocalizedString ([MyUtility keyForPluralRuleWithBaseKey:@"Move %d
unit(s) to the right."
quantity:someValue],
@"localization context comment goes here");
To keep things generic, the quantity param can be an NSNumber
representing either an integer or fractional value. Or, just overload
the API; one with int, one with float/double.
What is to be done for "Move %d units to the right and %d steps up" ?
Kind regards,
Gerriet.
_______________________________________________
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