php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #45833 Enable MessageFormatter to select custom currency
Submitted: 2008-08-16 09:32 UTC Modified: 2021-11-11 11:15 UTC
From: mathieuk at gmail dot com Assigned:
Status: Open Package: I18N and L10N related
PHP Version: 5.3.0alpha1 OS: MacOSX
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
45 + 40 = ?
Subscribe to this entry?

 
 [2008-08-16 09:32 UTC] mathieuk at gmail dot com
Description:
------------
Feature Request for the intl extension

The MessageFormatter is capable of formatting a number in a currency 
format. This is only marginally useful because it always uses the 
currency symbol for the locale given to it. 

It probably wouldn't be uncommon to want to display a currency in your 
own currency format, but using a different currency symbol.

Reproduce code:
---------------
<?php

$msgfmt = MessageFormatter::create('nl_NL', 'Price (USD): {0,number,currency}');


/* I'm assuming the format {0,number,currency} is not editable to something like {0,number,currency,USD} because it is defined in a underlying library. So I propose the following new method: */

$msgfmt->setCurrency('USD');

echo $msgfmt->format(array(15.95));

?>



Expected result:
----------------
Price (USD): $ 15,00





Actual result:
--------------
(without the imagined setCurrency call)

Price (USD): ? 15,00





Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-09-13 21:25 UTC] sam at rmcreative dot ru
Do you mean any of existing currencies? If so, you can do it via specifying it in locale string via "@currency". See http://gostash.it/ru/stashes/327.
 [2016-12-31 00:26 UTC] cmb@php.net
-Package: Feature/Change Request +Package: intl
 [2021-11-11 11:15 UTC] nikic@php.net
-Package: intl +Package: I18N and L10N related
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon Nov 28 11:05:53 2022 UTC