l18n: Internationalization for pytz timezones and territories
l18n is a Python library providing internationalization (i18n) and localization (l10n) services specifically for `pytz` timezones and territory names. It offers lazy translations for names used for localization purposes, such as cities and full timezone names, by fetching them from the CLDR (Unicode's Common Locale Data Repository) database. The latest version, 2021.3, was released in November 2021. Its versioning strategy aims to align with `pytz` releases to ensure consistency with timezone names.
Warnings
- gotcha The library's last release (2021.3) was in November 2021. While it declared compatibility with Python 2.7 and Python 3.5+ at the time of release, compatibility with modern Python versions (3.10+) or very recent `pytz` versions has not been explicitly confirmed or updated. Python 3.9 reached End-of-Life in October 2025.
- gotcha l18n's versioning is designed to align with `pytz`. If `l18n` and `pytz` versions are significantly mismatched, there may be missing or incorrect translations, particularly if new timezones or territory names have been introduced in `pytz` that `l18n` hasn't yet processed from CLDR.
- gotcha The library fetches translations from the CLDR database. If CLDR is updated with new or changed locale data and the `l18n` library is not updated accordingly, its translations may become outdated or incomplete.
Install
-
pip install l18n
Imports
- l18n
import l18n
- tz_cities
l18n.tz_cities
- tz_fullnames
l18n.tz_fullnames
- set_language
l18n.set_language('fr')
Quickstart
import l18n
import os
# Set the language to French (for demonstration)
l18n.set_language('fr')
# Get translated city name for a timezone
easter_island_city_fr = l18n.tz_cities['Pacific/Easter']
print(f"Easter Island (French): {easter_island_city_fr}")
# Switch to English
l18n.set_language('en')
easter_island_city_en = l18n.tz_cities['Pacific/Easter']
print(f"Easter Island (English): {easter_island_city_en}")
# Get full translated timezone name
london_timezone_en = l18n.tz_fullnames['Europe/London']
print(f"London timezone (English): {london_timezone_en}")
l18n.set_language('de')
london_timezone_de = l18n.tz_fullnames['Europe/London']
print(f"London timezone (German): {london_timezone_de}")