template: print warning message and use DEFAULT_LOCALE on bad locale

This commit is contained in:
Goffi 2017-07-12 19:06:28 +02:00
commit d8080c8ad2

View file

@ -219,7 +219,13 @@ class Renderer(object):
def setLocale(self, locale_str):
if locale_str == self._locale_str:
return
locale = Locale.parse(locale_str)
try:
locale = Locale.parse(locale_str)
except ValueError as e:
log.warning(_(u"invalid locale value: {msg}").format(msg=e))
locale_str = self._locale_str = DEFAULT_LOCALE
locale = Locale.parse(locale_str)
locale_str = unicode(locale)
if locale_str != DEFAULT_LOCALE:
try: