[development] code proposal: localization of currency, ...

Ivan Sergio Borgonovo mail at webthatworks.it
Thu Oct 18 11:51:06 UTC 2007


On Wed, 17 Oct 2007 23:38:04 +0200
Wim Leers <work at wimleers.com> wrote:

> > I gave a look at the code. I think something a bit more
> > generalised could gain more acceptance. I'm thinking about
> > position of the sign and relaying on a more general number format.
> > People may not want to follow ISO but just output their stuff
> > accordingly to traditions.

> Sign positioning was not yet needed, not even requested. But it
> could obviously be added with ease. IIRC, there's no such thing as
> CCK formatter settings though. This means that you'd have to
> provide formatters such as: "format: <ISO code> <sign> <amount>",
> "format: <sign> <ISO code> <amount>", "format: <symbol> <sign>
> <amount>", etc. As you can see, the number of formatters becomes
> overwhelming. Ideally, you would be able to define your own
> formatters (with drag and drop). But that's something CCK currently
> doesn't support (again, AFAIK).

First I'd let the user free to chose if he want the iso code or
whatever... even in Klingon currency.

I'd just use a simple replace with a form similar to:

Numbers:

grouping:
Number of digit: [3]
Digit separator: [.]

Decimal separator: [,]

Currency:

decimals: [2]

format: [%s \( %S %d \)]
%d is amount, %s is sign, %S is symbol, characters preceded by \ will
be printed just if the sign is negative.
example: %s \( %S %d \) will output something like - ( $ 1.234,00 )
or $ 1.234,00.

I'm not aware of the thousands variations you could have but this
should cover most needs.

function will be something like
format_currency($number, $symbol, $language=null)
So you could override the default language in a i18n website when
needed.
To provide overriding I've to learn how to access variables of
languages different from the one user is logged in... this seems to
be an interface problem in i18n too since when you've to set localised
variables you've to switch the language. It doesn't seem a blocker
and it has impact just on i18n enabled websites.

I still would like to have an idea of the acceptance of such stuff
and if people have any suggestion to make it more core or i18n
friendly.

thx

-- 
Ivan Sergio Borgonovo
http://www.webthatworks.it



More information about the development mailing list