--- a/cubicweb/req.py Thu Nov 17 10:53:04 2016 +0100
+++ b/cubicweb/req.py Thu Nov 17 10:15:11 2016 +0100
@@ -96,7 +96,15 @@
Raises :exc:`KeyError` if translation doesn't exist.
"""
self.lang = lang
- gettext, pgettext = self.vreg.config.translations[lang]
+ try:
+ gettext, pgettext = self.vreg.config.translations[lang]
+ except KeyError:
+ assert self.vreg.config.mode == 'test'
+ gettext = text_type
+
+ def pgettext(x, y):
+ return text_type(y)
+
# use _cw.__ to translate a message without registering it to the catalog
self._ = self.__ = gettext
self.pgettext = pgettext