Hey Yossi,

sorry for the late reply; I saw your message just now.

I don't think ICU's number formatting can do what you're looking for, so you'll have to do this yourself, maybe with some kind of helper or wrapper method that checks if (int)$amount == $amount.

- David


On 07.03.2010, at 12:36, Yossi Ben Haim wrote:

Hi David,

What I am trying to do is drop the fractional part of the number if it's value is 0.
By default it outputs 2 fractional digits even if they are zeros.

I've looked at a url from a comment on AgaviDecimalFormatter : 
http://icu.sourceforge.net/apiref/icu4c/classDecimalFormat.html
and I am still unable to change that through the format.

I also looked at the code... but it still eludes me.

Thanks,
Yossi.


Message: 2
Date: Wed, 3 Mar 2010 22:14:26 +0100
From: David Z?lke <[email protected]>
Subject: Re: [Agavi-Users] How can I control the format of $tm->_c()
To: Agavi Users Mailing List <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"; Format="flowed";
       DelSp="yes"

Do you want to control just the currency symbol, or the number format
pattern?

Those patterns are defined for all locales in the CLDR data we use,
and they should be correct.

If not, you'd do this:

<currency_formatter>
       <ae:parameter name="format">
               <ae:parameter name="en">?#,##0.00</ae:parameter>
               <ae:parameter name="de">#.##0,00 ?</ae:parameter>
       </ae:parameter>
</currency_formatter>

And so forth. It's exactly like for a number formatter, with the only
exception that the "?" symbol (U+00A4, 
http://www.fileformat.info/info/unicode/char/00a4/index.htm)
 is used as the placeholder for the currency symbol.

If you simply want to format a value using a different currency than
the one currently set on the active locale, do $tm->_c(123.45,
'some.domain', '@currency=GBP'); You can of course also define the
locale in translations.xml to use a different currency than the
default for that locale.

- David


On 02.03.2010, at 22:54, Yossi Ben Haim wrote:

> Hello,
>
> Was wondering if anyone can give me quick guidelines on how I can
> control the format of numbers generated by the translation manager
> ($tm->_c()).
>
> I have looked at the FAQ but it doesn't contain an example for
> currency formatting.
> I have can define a filter function (which works) so I can control
> the output and format it in a round about way... but obviously there
> must be better ways to do this.
>
> here is a the relevant code from my translations xml:
>
> <currency_formatter>
>
>       <ae:parameters>
>                                        <ae:parameter
> name="type">currency</ae:parameter>
>                                        <ae:parameter
> name="format">number</ae:parameter>
>                                      </ae:parameters>
>                                         <filters>
>
> <filter>xxxxxXxxxxTranslationFilters::currencyFilter</filter>
>                                         </filters>
>                                 </currency_formatter>
>
> I have tried to edit the type and format parameters in many ways,
> without getting any results or even exceptions...
>
> I'd appreciate any help.
>
> Thank you,
> Yossi.
_______________________________________________
users mailing list
[email protected]
http://lists.agavi.org/mailman/listinfo/users

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
users mailing list
[email protected]
http://lists.agavi.org/mailman/listinfo/users

Reply via email to