Skip to main content
Help us improve Python packaging – donate today!

Pyl10n is a localization (l10n) library for python

Project Description


Pyl10n is a localization (l10n) library for python, written in 2008-2010.

BEWARE: This is old code, migrated to git. Previously, this was found at:


Pyl10n intends to replace the standard locale module which is not thread safe (locale.setlocale() updates the entire process’ locale settings). Pyl10n allows you to supply the language setting at conversion function call time or through a callback function that allows you to have a thread-specific language. E.g. for Django you could pass django.utils.translation.get_language which gets the currently selected language.

Its a complement to gettext solutions that do not depend on process-wide language settings.


Pyl10n has been tested with python 2.5 through 2.7 on Debian/Ubuntu Linux systems. It’s been known to work with Python 3 as well.


Import pyl10n as locale:

>>> import pyl10n as locale

Hardcode the current thread locale.

>>> locale.setlocale('nl_NL')
>>> print(locale.currency(12345.67))
€ 12345,67

Usually you’ll want to set a function that returns the current thread locale.

>>> getlocale = lambda: 'en_US'
>>> locale.setlocalefunc(getlocale)
>>> print(locale.format('%f', 12345.67, True, True))

If you’re using your own locale files, you may set up the path like this:

$ ls path/to/locale/en/ -1p
>>> locale.setlocalepath('path/to/locale')
>>> locale.setlocale('en')
>>> locale.teldom2string((31, 50, 1234567))
'(50) 1234567'
>>> locale.setlocale('sv')
>>> locale.teldom2string((31, 50, 1234567))

The data files are stored/read using pickle.


As of this writing, it is not complete yet. It does implement format() and currency() correctly (see ) and it has most of the time formatting support that strftime(3) specifies.

In the near future (ha ha) it will support address formatting functions.

Look at the lists of finished and unfinished functions in the source.

Release history Release notifications

This version
History Node


History Node


History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
pyl10n-1.0.tar.gz (138.5 kB) Copy SHA256 hash SHA256 Source None Mar 17, 2016

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page