Currency management in Plone

Hanno Schlichting plone at
Thu Aug 23 23:19:56 UTC 2007

Hanno Schlichting wrote:
> Wichert Akkerman wrote:
>> I just released version 1.0b1 of a new product: simplon.plone.currency.
>> This is a simple product for Plone 3 that allows you to manage different
>> currencies in your site: you can add and remove currencies and manage
>> their conversion rates. It includes a database with description and symbols
>> for all currencies as well.
>> By itself this product is not very useful. It is intended to be used
>> as a component in products that need to use currencies in some way. If
>> anyone is working on such a product I would love to hear some feedback.
>> You can find more information and a downloadable package in the
>> python package index:
> I have looked at it briefly and wonder why you didn't reuse the currency
> information available in zope.i18n.locales?
> While in Zope2 the current locale is not directly available from
> REQUEST.locale as in Zope3, with Plone3 it is available from the portal
> globals view (
>   >>> portal_state = queryMultiAdapter((context, request),
>   ...     name=u'plone_portal_state')
>   >>> locale = portal_state.locale()
> If you don't want to have the locale in the currently negotiated
> language you can also get a specific one:
>   >>> from zope.i18n.locales import locales
>   >>> en = locales.getLocale('en', 'us', None)
>   >>> pp len(en.numbers.currencies)
>   382
>   >>> pp en.numbers.currencies[u'USD'].__dict__
>   {'displayName': u'US Dollar',
>    'symbol': u'US$',
>    'symbolChoice': False,
>    'type': u'USD'}
> If you use this information for the currency information you can also
> get currency names translated into every language for free :)
> For an example of the latter you can look at the otherwise a bit hairy
> LanguageTableWidget in It defines
> self.languages in the __init__ and latter on uses it in the textForValue
> method. Basically it uses the key of the language to look it up in the
> current locale and gets the displayName for it.

One more thing I forgot to mention. If you want to format some actual
values in the currencies, you might find the following useful:

  >>> from zope.i18n.locales import locales
  >>> nl = locales.getLocale('nl')
  >>> en = locales.getLocale('en')
  >>> nl.numbers.getFormatter('currency').format(1000.14)
  u'\xa4 1.000,14'
  >>> en.numbers.getFormatter('currency').format(1000.14)


More information about the Product-Developers mailing list