Search code examples
pythongoogle-app-enginelocale

Currency Formating with Locale in Google App Engine Python


I'm attempting to format currency to the US locale using google app engine with python 2.7. This is the code that I'm using:

    import locale
    locale.setlocale( locale.LC_ALL, 'US')
    tFloatCash = 50.00
    tStringCash = locale.currency(tFloatCash)

This works perfectly in the interactive shell. However, I get this error on GAE itself:

  File "***", line 138, in post
    locale.setlocale( locale.LC_ALL, 'US')
  File "/base/python27_runtime/python27_dist/lib/python2.7/locale.py", line 531, in setlocale
    return _setlocale(category, locale)
  Error: unsupported locale setting

What can I do to resolve this problem? Is there another currency formatting library that I can quickly implement to format my floats?


Solution

  • Google doesn't support locale.

    http://code.google.com/p/googleappengine/issues/detail?id=992

    Try moneyfmt.

    http://docs.python.org/library/decimal.html#recipes