Issues

ZF-9491: format option does not work

Issue Type: Improvement Created: 2010-03-20T16:20:17.000+0000 Last Updated: 2010-03-22T15:12:17.000+0000 Status: Resolved Fix version(s): - 1.10.3 (01/Apr/10)

Reporter: Nils Caspar (pencil) Assignee: Thomas Weidner (thomas) Tags: - Zend_Currency

Related issues: Attachments: - Currency.php.patch

Description

<pre class="highlight">
$currency = new Zend_Currency('de_DE'); 
echo $currency->toCurrency(34567.43212, array('precision' => 0, 'format' => '#,##0')); 

throws an exception: '#,##0' is not a known locale.

Tested with newest version from trunk.

Comments

Posted by Nils Caspar (pencil) on 2010-03-20T16:24:24.000+0000

Fix

Posted by Thomas Weidner (thomas) on 2010-03-20T23:05:36.000+0000

Changing from BUG to IMPROVEMENT.

Since ever format has to be a locale, as it does not make sense for a "currency" to be formatted in a way where users are not able to recognise what it represents.

Posted by Nils Caspar (pencil) on 2010-03-21T01:37:20.000+0000

Documentation says: {quote} format: Defines the format which should be used for displaying numbers. This number-format includes for example the thousand separator. You can either use a default format by giving a locale identifier, or define the number-format manually. {quote}

A bug is a "difference between documentation and the actual product." (wikipedia) and that's exactly the case here. Either the documentation should be changed or the code should be fixed. I prefer the second option ;)

Posted by Thomas Weidner (thomas) on 2010-03-21T09:54:03.000+0000

What would you need the format option for when it would not be used with a locale?

Which format would you want to give which would not be simpler available with the other options?

Posted by Nils Caspar (pencil) on 2010-03-21T10:50:05.000+0000

The format of the swiss (german) locale: ¤ #,##0.00;¤-#,##0.00 I would like to have a space between the currency and the "-" sign (¤ -#,##0.00)...

But why are we discussing the sense of this use case? Documentation says it is possible, but it actually isn't...

Posted by Thomas Weidner (thomas) on 2010-03-21T11:17:29.000+0000

You could simply use "de_CH" as format which already archives this.

And regarding discussion: When I don't see a benefit for a issue I want to know the rationale behind it before closing, changing or implementing it.

Actually I see no benefit for this issue. In my eyes it makes things even a little more complicated.

When you don't want to discuss and give the reasons behind it then just say a word and I will close it.

Posted by Nils Caspar (pencil) on 2010-03-21T11:24:25.000+0000

I'm using "de_CH" but as I said there is a space between the "-" and the currency missing. Expected: Fr. -10.20 Actual: Fr.-10.20

Posted by Thomas Weidner (thomas) on 2010-03-21T11:42:30.000+0000

When you think that CLDR is wrong, then please fill an issue within Unicode (http://unicode.org/cldr)

The space itself can not be used as format... the format option only allows "#", ",", ".", "0" and "-" as input.

For such a format you will need to use a extended class as it's no localized but a customized format.

Posted by Nils Caspar (pencil) on 2010-03-21T11:52:00.000+0000

{quote} When you think that CLDR is wrong, then please fill an issue within Unicode (http://unicode.org/cldr) {quote} I don't want to change the unicode speficication, I just want to use my custom format.

{quote} The space itself can not be used as format... the format option only allows "#", ",", ".", "0" and "-" as input. {quote} But the format for the positive numbers has a space in it (¤ #,##0.00)...

Anyway, if you don't implement this as specified in the manual, consider fixing the documentation. :/

Posted by Thomas Weidner (thomas) on 2010-03-21T12:09:39.000+0000

Looking into the format you will see that this character is no space. It's a different unicode character and not part of the format definition.

Posted by Nils Caspar (pencil) on 2010-03-21T12:20:46.000+0000

True. But the character is displayed as a space in web browsers...

Posted by Thomas Weidner (thomas) on 2010-03-22T15:12:17.000+0000

Implemented with r21609

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts