ZF-9491: format option does not work

Description


$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

Fix

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.

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 ;)

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?

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

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.

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

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.

{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. :/

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.

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

Implemented with r21609