From 3d5b4614095fd0b9de37ab3a636e01681ca256b2 Mon Sep 17 00:00:00 2001 From: Alex Root Junior Date: Sat, 30 Jun 2018 17:00:12 +0300 Subject: [PATCH] Raise error when locale is not compiled. --- aiogram/contrib/middlewares/i18n.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/aiogram/contrib/middlewares/i18n.py b/aiogram/contrib/middlewares/i18n.py index 3b60e070..18730cc7 100644 --- a/aiogram/contrib/middlewares/i18n.py +++ b/aiogram/contrib/middlewares/i18n.py @@ -57,6 +57,8 @@ class I18nMiddleware(BaseMiddleware): if os.path.exists(mo_path): with open(mo_path, 'rb') as fp: translations[name] = gettext.GNUTranslations(fp) + elif os.path.exists(mo_path[:-2] + 'po'): + raise RuntimeError(f"Found locale '{name} but this language is not compiled!") return translations