php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #79219 Intl MessageFormatter does not consider "other" as a default parameter
Submitted: 2020-02-04 11:13 UTC Modified: 2021-06-15 11:26 UTC
From: matthewsmeets at gmail dot com Assigned: cmb (profile)
Status: Wont fix Package: intl (PECL)
PHP Version: 7.4.2 OS: Linux
Private report: No CVE-ID: None
 [2020-02-04 11:13 UTC] matthewsmeets at gmail dot com
Description:
------------
---
From manual page: https://php.net/messageformatter.create
---

When using the formatter, it expects me to pass all paramters within a select block. This is while the select block itself requires an "other" keyword (otherwise I will get a U_DEFAULT_KEYWORD_MISSING).

I would expect that, when not passing a parameter into select, it will just use the value from "other" as default.

Please note that in the code found below, I am basing this off of the Symfony implementation of the IntlFormatter, calling the \MessageFormatter.

Test script:
---------------
{0, plural,
  =1 {Day}
  other {Days}
}

$message = $formatter->format([]); 

echo $message; // prints "{0}"

Expected result:
----------------
{0, plural,
  =1 {Day}
  other {Days}
}

$message = $formatter->format([]); 

echo $message; // prints "Days"


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-06-15 11:26 UTC] cmb@php.net
-Status: Open +Status: Wont fix -Assigned To: +Assigned To: cmb
 [2021-06-15 11:26 UTC] cmb@php.net
Even if ICU allows to specify a default value (I don't know
whether that's the case), it would still be confusing to be able
to give fewer arguments than defined in the pattern.

If you feel that this feature would be a good addition, please 
pursue the RFC process[1].

[1] <https://wiki.php.net/rfc/howto>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 13:01:31 2024 UTC