php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63724 MessageFormatter buggy when using select formats with nested parameters
Submitted: 2012-12-07 23:11 UTC Modified: 2012-12-23 19:11 UTC
From: eskwayrd at gmail dot com Assigned:
Status: Not a bug Package: I18N and L10N related
PHP Version: 5.4.9 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
45 - 17 = ?
Subscribe to this entry?

 
 [2012-12-07 23:11 UTC] eskwayrd at gmail dot com
Description:
------------
When a message formatter formats selects with nested variables, its behaviour is 
buggy.

Test script:
---------------
// attempting to translate file size
$locale = 'en_US';
$args = array(1.23435, 'M');
$format = "{1, select, k {{0} kB} M {{0} MB} other {{0} B}}";
echo "#1: ". msgfmt_format_message($locale, $format, $args) ."\n";

$format = "{1, select, k {{0} kB} M {{0, number, #.##} MB} other {{0} B}}";
echo "#2: ". msgfmt_format_message($locale, $format, $args) ."\n";
echo "Error? ". intl_get_error_message() ."\n";

Expected result:
----------------
#1: 1.23435 MB
#2: 1.23 MB
Error? U_ZERO_ERROR


Actual result:
--------------
#1: 1.23435 MB
#2: 
Error? Creating message formatter failed: U_ARGUMENT_TYPE_MISMATCH

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-12-23 19:11 UTC] felipe@php.net
If it's really a problem, it occurred on ICU. See a related bug #62673

Using "{1, select, k {{0, number} kB} M {{0, number, #.##} MB} other {{0, number} B}}" does the job, somehow just like suggested in the bug I pointed out above.
 [2012-12-23 19:11 UTC] felipe@php.net
-Status: Open +Status: Not a bug
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 09:01:28 2024 UTC