Edit report at http://bugs.php.net/bug.php?id=50808&edit=1

 ID:               50808
 Updated by:       s...@php.net
 Reported by:      bschussek at gmail dot com
 Summary:          MessageFormatter buggy when using choice formats with
                   nested parameters
-Status:           Assigned
+Status:           Bogus
 Type:             Bug
 Package:          I18N and L10N related
 Operating System: *
 PHP Version:      5.3, 6
 Assigned To:      stas

 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

Unfortunately, ChoiceFormat it ICU doesn't seem to support formats
inside choice alternatives, see:
http://icu-project.org/apiref/icu4c/classChoiceFormat.html



Split the pattern like this:

$fmt = MessageFormatter::create('en_GB', 'There are {0,choice,0#are
no|1#is one} {1} {0,choice,0#files|1#file} ok');



to make it work.


Previous Comments:
------------------------------------------------------------------------
[2010-01-22 00:48:51] bschussek at gmail dot com

The reproduce code still produces the wrong output for me with this 
build.

------------------------------------------------------------------------
[2010-01-21 18:09:30] s...@php.net

Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

build fixed

------------------------------------------------------------------------
[2010-01-21 12:07:42] j...@php.net

Stas, no compile here either.

------------------------------------------------------------------------
[2010-01-21 10:35:31] bschussek at gmail dot com

The build of your snapshot doesn't work for me. Did I do anything
wrong?



/bin/sh /home/.../php-5.3-latest/libtool --silent --preserve-dup-deps
--mode=compile /home/.../php-5.3-latest/meta_ccld -I/usr/include
-Iext/intl/ -I/home/.../php-5.3-latest/ext/intl/ -DPHP_ATOM_INC
-I/home/.../php-5.3-latest/include -I/home/.../php-5.3-latest/main
-I/home/.../php-5.3-latest -I/home/.../php-5.3-latest/ext/date/lib
-I/home/.../php-5.3-latest/ext/ereg/regex -I/usr/include/libxml2
-I/usr/include/mysql -I/home/.../php-5.3-latest/ext/sqlite3/libsqlite
-I/home/.../php-5.3-latest/TSRM -I/home/.../php-5.3-latest/Zend 
-D_REENTRANT -DTHREAD=1  -I/usr/include -g -O2 -fvisibility=hidden
-pthread -DZTS  -prefer-non-pic -c
/home/.../php-5.3-latest/ext/intl/resourcebundle/resourcebundle_class.c
-o ext/intl/resourcebundle/resourcebundle_class.lo 

/home/.../php-5.3-latest/ext/intl/resourcebundle/resourcebundle_class.c:
In function ‘resourcebundle_ctor’:

/home/.../php-5.3-latest/ext/intl/resourcebundle/resourcebundle_class.c:90:
error: too few arguments to function ‘zend_object_store_get_object’

/home/.../php-5.3-latest/ext/intl/resourcebundle/resourcebundle_class.c:
In function ‘resourcebundle_array_count’:

/home/.../php-5.3-latest/ext/intl/resourcebundle/resourcebundle_class.c:250:
error: too few arguments to function ‘zend_object_store_get_object’

make: *** [ext/intl/resourcebundle/resourcebundle_class.lo] Fehler 1

------------------------------------------------------------------------
[2010-01-20 19:47:55] bschussek at gmail dot com

Description:
------------
When a message formatter formats choices with nested variables, its
behaviour is buggy.



Interestingly, the code below works if you insert the parameter "{1}"
once more outside of the choice:



'There are {0,choice,0#are no {1} files|1#is one {1} file} ok {1}'



produces



There are are no text files ok text

There are is one image file ok image

Reproduce code:
---------------
$fmt = MessageFormatter::create('en_GB', 'There are {0,choice,0#are no
{1} files|1#is one {1} file} ok');



echo $fmt->format(array(0, "text")), "\n";

echo $fmt->format(array(1, "image")), "\n";

Expected result:
----------------
There are are no text files ok

There are is one image file ok

Actual result:
--------------
There are are no {1} files ok

There are is one {1} file ok


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=50808&edit=1

Reply via email to