Registry / serialization / l18n
library2021.3pypypi✓ verified 23d ago

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.

pip install l18n
INSTALL
IMPORT
SIG · L18N
L
l18n
serializationpythonv2021.3
Install
1.8s avg
Import
37ms
Disk
19MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2021.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.036s · 20.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.8s · import 0.038s · 21MB
19MB installed
● package 19MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

l18n
import l18n
tz_cities
l18n.tz_cities
A read-only dictionary-like object mapping pytz timezones to human-friendly translated city names.
tz_fullnames
l18n.tz_fullnames
A read-only dictionary-like object mapping pytz timezones to human-friendly translated full timezone names.
set_language
l18n.set_language('fr')
Sets the active language for translations. Default is 'en'.

This quickstart demonstrates how to import `l18n`, set the desired language, and retrieve translated city and full timezone names using the `tz_cities` and `tz_fullnames` mappings.

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}")
Debug
Known issues
gotchaThe 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.
fix
Test thoroughly with your target Python and `pytz` versions. Consider contributing updates or forking if you encounter compatibility issues with newer environments.
affects: 2021.3 and older
gotchal18n'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.
fix
Ensure `l18n` is installed with a `pytz` version it was released alongside or a close subsequent version. If issues arise, check for a newer `l18n` release or report an issue on the GitHub repository.
affects: All versions
gotchaThe 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.
fix
Monitor for new `l18n` releases or be prepared to generate updated translation data if you require the absolute latest CLDR information.
affects: All versions, especially older ones
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'l18n'
The 'l18n' library is not installed in your current Python environment.
fix
Install the library using pip: `pip install l18n`
AttributeError: 'Locale' object has no attribute 'some_nonexistent_method'
You are attempting to call a method or access an attribute that does not exist on the 'l18n.Locale' object, likely due to a typo or incorrect API usage.
fix
Consult the l18n documentation for the correct method names and usage, for example, to get a timezone name: `l18n.get_timezone_name('Europe/London', 'en')`.
l18n.core.exceptions.LocaleNotFoundError: Locale 'xx_YY' could not be found.
The requested locale (e.g., 'xx_YY') is not recognized or available in the CLDR data that the l18n library uses.
fix
Ensure the locale identifier is correct and supported by CLDR. You can list available locales using `l18n.get_available_locales()` to verify.
l18n.core.exceptions.TranslationNotFoundError: No translation found for key 'timezone.America/New_York' in locale 'es'.
The l18n library could not find a translation for the specified key (e.g., a timezone or territory name) in the requested locale, even if the locale itself exists.
fix
Check if the requested key exists for the locale, or provide a fallback mechanism. If the translation is expected to exist, consider reporting it as a missing translation to the l18n project or updating your CLDR data source.
Upgrade
Version history
2021.3latest on PyPI · released Nov 12, 2021
Audit
Dependencies
pytzrequiredCore functionality relies on pytz for timezone data and names to translate.
Agent activity
5 hits · last 30 days
node
4
Resources
l18n — pip install l18n · libregistry