Mercurial > libervia-backend
changeset 2323:2dae79990122
template: print warning message and use DEFAULT_LOCALE on bad locale
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 12 Jul 2017 19:06:28 +0200 |
parents | 310a454c8657 |
children | fe922e6fabd4 |
files | src/tools/common/template.py |
diffstat | 1 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/tools/common/template.py Wed Jul 12 19:05:33 2017 +0200 +++ b/src/tools/common/template.py Wed Jul 12 19:06:28 2017 +0200 @@ -219,7 +219,13 @@ 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: