Non-existent timezone fix

Closes-Bug: #2085126
Change-Id: I37c5462be8de39a7280208d55b64fc0430d0c584
This commit is contained in:
Owen McGonagle 2025-01-17 11:59:29 -05:00 committed by Tatiana Ovchinnikova
parent eb51c5d2fc
commit 5190d6e554

@ -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}