Mercurial > libervia-backend
comparison src/tools/common/template.py @ 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 | 084a75b8aa7a |
children | d14c1a3e3244 |
comparison
equal
deleted
inserted
replaced
2322:310a454c8657 | 2323:2dae79990122 |
---|---|
217 self.env.install_null_translations(True) | 217 self.env.install_null_translations(True) |
218 | 218 |
219 def setLocale(self, locale_str): | 219 def setLocale(self, locale_str): |
220 if locale_str == self._locale_str: | 220 if locale_str == self._locale_str: |
221 return | 221 return |
222 locale = Locale.parse(locale_str) | 222 try: |
223 locale = Locale.parse(locale_str) | |
224 except ValueError as e: | |
225 log.warning(_(u"invalid locale value: {msg}").format(msg=e)) | |
226 locale_str = self._locale_str = DEFAULT_LOCALE | |
227 locale = Locale.parse(locale_str) | |
228 | |
223 locale_str = unicode(locale) | 229 locale_str = unicode(locale) |
224 if locale_str != DEFAULT_LOCALE: | 230 if locale_str != DEFAULT_LOCALE: |
225 try: | 231 try: |
226 translations = self.translations[locale] | 232 translations = self.translations[locale] |
227 except KeyError: | 233 except KeyError: |