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
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: 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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 11:01:30 2024 UTC