From a26258e4185fc13c46fc5ec7251e3491c3e432ad Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Mon, 6 Aug 2018 02:38:07 +0200 Subject: [PATCH] [mod] fallback on english on failure --- moulinette/core.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/moulinette/core.py b/moulinette/core.py index 7c372886..8bf53d89 100644 --- a/moulinette/core.py +++ b/moulinette/core.py @@ -88,13 +88,15 @@ class Translator(object): - key -- The key to translate """ + failed_to_format = False if key in self._translations.get(self.locale, {}): try: return self._translations[self.locale][key].encode('utf-8').format(*args, **kwargs) except KeyError as e: logger.exception("Failed to format translated string '%s' with error: %s" % (key, e)) + failed_to_format = True - if self.default_locale != self.locale and key in self._translations.get(self.default_locale, {}): + if failed_to_format or (self.default_locale != self.locale and key in self._translations.get(self.default_locale, {})): logger.info("untranslated key '%s' for locale '%s'", key, self.locale)