|  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
Have you experienced this issue?
Rate the importance of this bug to you:

 [2020-02-04 11:13 UTC] matthewsmeets at gmail dot com
From manual page:

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"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-06-15 11:26 UTC]
-Status: Open +Status: Wont fix -Assigned To: +Assigned To: cmb
 [2021-06-15 11:26 UTC]
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] <>
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jun 13 20:01:31 2024 UTC