|  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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: eskwayrd at gmail dot com
New email:
PHP Version: OS:


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

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

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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-12-23 19:11 UTC]
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]
-Status: Open +Status: Not a bug
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Aug 03 21:01:24 2020 UTC