php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60424 String with apostrophe are incorrect with MessageFormatter
Submitted: 2011-12-01 13:37 UTC Modified: 2021-07-13 16:51 UTC
From: gcharneau at gmail dot com Assigned: cmb (profile)
Status: Not a bug Package: I18N and L10N related
PHP Version: 5.3.8 OS: Mac OS X 10.6, Windows 7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: gcharneau at gmail dot com
New email:
PHP Version: OS:

 

 [2011-12-01 13:37 UTC] gcharneau at gmail dot com
Description:
------------
The formatting of strings containing apostrophes is wrong.

Test script:
---------------
$locale = 'fr_FR';
$args = array(1);
$string = "{0, choice, 0<{0} d'eé|1<{0} d'aà}";
echo msgfmt_format_message($locale, $string, $args);
$string = "{0, choice, 0<{0} d''eé|1<{0} d''aà}";
echo msgfmt_format_message($locale, $string, $args);

Expected result:
----------------
1 d'eé

1 d'eé

Actual result:
--------------
1 deé|1<1 daà

1 deé


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-09-13 21:26 UTC] sam at rmcreative dot ru
Apostrophes are used as escaping character. If you need it in the final string, use ''.
 [2021-07-13 16:51 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2021-07-13 16:51 UTC] cmb@php.net
> Apostrophes are used as escaping character. If you need it in
> the final string, use ''.

Right[1].  Note though that using choice is discouraged by ICU,
and that this particular syntax won't work with recent ICU
versions all, but that is another story.

[1] <https://unicode-org.github.io/icu/userguide/format_parse/messages/#quotingescaping>
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jan 22 15:01:31 2025 UTC