> -----Original Message-----
> From: Chris Stockton [mailto:[email protected]]
> Sent: 09 December 2009 20:39
> To: PHP Developers Mailing List
> Subject: [PHP-DEV] Intl extension class MessageFormatter
> instantiation returns NULL
>
> Hello,
>
> I am trying to use ChoiceFormat in the Intl extension. When I
> try to do something like:
>
> $r = new MessageFormatter("en", "There are {0?are no files|1?is one
> file|1<are many files} ok");
> // $r is NULL
>
> This may be a incorrect use, but my thought is that
> regardless null should not be returned because no error code
> or error message can be returned. I also can not think of a
> single case off the top of my head when new does not return a
> object (aside from a exception being thrown on instantiation).
>
> I am struggling to find documentation on plural usage. There
> is no "ChoiceFormatter" class so it is my assumption that
> message formatter parses that format. I would very much
> appreciate if someone was able to point me in the right
> direction. My apologies if this may have been better suited
> on PECL list, but subscribing appears down and I am hastily
> in search for a answer.
>
> -Chris
>
Try...
$fmt = MessageFormatter::create('en_GB', 'There are {0,choice,0#are no
files|1#is one file|1<are many files} ok');
echo $fmt->format(array(0)), "\n";
echo $fmt->format(array(1)), "\n";
echo $fmt->format(array(10101)), "\n";
Best place for documentation is tests, or example code I find.
http://userguide.icu-project.org/formatparse/messages/examples
Jared
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php