Re: [PHP-I18N] intl extension

[email protected] (Stanislav Malyshev) Mon, 12 May 2008 17:23:11 -0700
Newsgroups php.i18n
Organization Zend Technologies
Message-ID <[email protected]>
Hi!

> 1.) Gettext way: I call a format_plural($count, '1 comment', '$count 
> comments'), and this function can handle special cases (for example 
> Russian), and the given language file can store multiple plural format.
> 
> 2.) "All-in-one" way: only one string belongs to one string id, and this 
> string holds the different versions of the given word/sentence, and the 
> rules too on which we can decide which version should be used. For example:
> "[0]No comment.|[1]1 comment.|[2,]$count comments."

Here you'd probably want to use {1,number,integer} instead of $count and 
provide $count as parameter, otherwise you'd lose local number formatting.

>  o Maybe the most obvious one is that the rules are repeated in every 
> entry and the fact that the rules belongs to the language not to an 
> entry (so the data model is a little strange, it holds some redundancy).

Yes, that's correct - but you could always isolate it into specific 
printing function - i.e. create function print_comments_count($count) 
and use the pattern there, and then insert it into bigger pattern. 
Depends on how often that pattern repeats, I guess.

>  o My other problem is that for this structure it would be not easy to 
> create a logical/usable user interface for translating.

Well, here I don't have any meaningful experience, but I think since ICU 
uses it there must be some tools that support it. Right now the 
extension does not deal with the question where you get the patterns 
from or how you switch between pattern sets (we planned to add support 
for resource bundles, etc. later). Maybe other people on the list could 
help more with that :)
-- 
Stanislav Malyshev, Zend Software Architect
[email protected]   http://www.zend.com/
(408)253-8829   MSN: [email protected]