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: 2016-12-31 00:26 UTC
From: mathieuk at gmail dot com Assigned:
Status: Open Package: intl (PECL)
PHP Version: 5.3.0alpha1 OS: MacOSX
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.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mathieuk at gmail dot com
New email:
PHP Version: OS:

 

 [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
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Sep 19 18:03:37 2021 UTC