Time Zone names in local language
You can use babel package
import pytz
from babel.dates import get_timezone_location
for tz in pytz.common_timezones_set:
print(get_timezone_location(tz, locale='es'))
No, unfortunately there are no translations for the timezone names. The names are part of the Olson timezone database (not part of Python or pytz
). New ones are added from time to time, so any potential translation project would have to stay in sync with that database.
pytz.common_timezones_set
returns a set of timezone ids in the tz database. They are designed to be human readable but they are not translatable.
PyICU provides access to the localized timezone names:
>>> from datetime import datetime
>>> import icu
>>> df = icu.DateFormat.createDateTimeInstance(icu.DateFormat.SHORT, icu.DateFormat.FULL, icu.Locale.getFrance())
>>> df.format(datetime.now(icu.ICUtzinfo.getDefault()))
'27/01/2015 21:01:01 heure normale d’Europe centrale'