[sugar] Localized number formatting

Benjamin M. Schwartz bmschwar
Mon Nov 5 12:42:25 EST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Erik Blankinship wrote:
> Did you make any progress with this?
Yes.  It works.  For example, Acoustic Tape Measure calls 'import locale' at the
top of the file.  During __init__(), after calling activity.Activity.__init__,
it initiates locale with 'locale.setlocale(locale.LC_ALL, '')'.  Numbers are
then formatted using 'locale.format("%.2f", x)'.  For more info, see
http://docs.python.org/lib/module-locale.html

Note that locale.format will localize the decimal separator and thousands
separator, but does not change the numerals used.  It seems that no one has ever
attempted systematic numeral localization in Python.

For printing dates and times in the Clock activity I used time.strftime. The
time.strftime function provides similar automatically localized formatting.

- --Ben
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHL1YBUJT6e6HFtqQRAqWcAKCOOcS/N+5FhHLSzYtS3Z2Pw0F8CgCfazSF
brb3JLcq66ZlMgx3+aoLKLc=
=Tv26
-----END PGP SIGNATURE-----



More information about the Sugar-devel mailing list