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
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: eskwayrd at gmail dot com
New email:
PHP Version: OS:

 

 [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: Wed Apr 24 15:01:30 2024 UTC