diff --git a/openstack_dashboard/dashboards/settings/user/forms.py b/openstack_dashboard/dashboards/settings/user/forms.py index 1c1f58dfaa..651091ea5b 100644 --- a/openstack_dashboard/dashboards/settings/user/forms.py +++ b/openstack_dashboard/dashboards/settings/user/forms.py @@ -13,6 +13,7 @@ # under the License. from datetime import datetime +import logging import string import zoneinfo @@ -29,6 +30,9 @@ from horizon import messages from horizon.utils import functions +LOG = logging.getLogger(__name__) + + class UserSettingsForm(forms.SelfHandlingForm): max_value = settings.API_RESULT_LIMIT language = forms.ChoiceField(label=_("Language")) @@ -82,8 +86,12 @@ class UserSettingsForm(forms.SelfHandlingForm): elif tz == "GMT": tz_name = _("GMT") else: - tz_label = babel.dates.get_timezone_location( - tz, locale=babel_locale) + try: + tz_label = babel.dates.get_timezone_location( + tz, locale=babel_locale) + except LookupError as e: + LOG.info('Failed to fetch locale for timezone: %s', e) + # Translators: UTC offset and timezone label tz_name = _("%(offset)s: %(label)s") % {"offset": utc_offset, "label": tz_label}