[magicsearch] update to match new i18n API: config.translations[lang] now returns a couple of function stable
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Tue, 22 Sep 2009 09:50:45 +0200
branchstable
changeset 3362 2a2dcfb379a0
parent 3361 be0605689fed
child 3363 d3736311d0c4
[magicsearch] update to match new i18n API: config.translations[lang] now returns a couple of function
web/test/unittest_magicsearch.py
web/views/magicsearch.py
--- a/web/test/unittest_magicsearch.py	Tue Sep 22 09:44:35 2009 +0200
+++ b/web/test/unittest_magicsearch.py	Tue Sep 22 09:50:45 2009 +0200
@@ -31,9 +31,12 @@
     u'address' : u"adresse",
     u'use_email' : u"adel",
     }
+
 def _translate(msgid):
     return translations.get(msgid, msgid)
 
+def _ctxtranslate(ctx, msgid):
+    return _translate(msgid)
 
 from cubicweb.web.views.magicsearch import translate_rql_tree, QSPreProcessor, QueryTranslator
 
@@ -43,7 +46,7 @@
     def setUp(self):
         super(QueryTranslatorTC, self).setUp()
         self.req = self.env.create_request()
-        self.vreg.config.translations = {'en': _translate}
+        self.vreg.config.translations = {'en': (_translate, _ctxtranslate)}
         proc = self.vreg['components'].select('magicsearch', self.req)
         self.proc = [p for p in proc.processors if isinstance(p, QueryTranslator)][0]
 
@@ -67,7 +70,7 @@
     """test suite for QSPreProcessor"""
     def setUp(self):
         super(QSPreProcessorTC, self).setUp()
-        self.vreg.config.translations = {'en': _translate}
+        self.vreg.config.translations = {'en': (_translate, _ctxtranslate)}
         self.req = self.request()
         proc = self.vreg['components'].select('magicsearch', self.req)
         self.proc = [p for p in proc.processors if isinstance(p, QSPreProcessor)][0]
@@ -185,7 +188,7 @@
 
     def setUp(self):
         super(ProcessorChainTC, self).setUp()
-        self.vreg.config.translations = {'en': _translate}
+        self.vreg.config.translations = {'en': (_translate, _ctxtranslate)}
         self.req = self.request()
         self.proc = self.vreg['components'].select('magicsearch', self.req)
 
--- a/web/views/magicsearch.py	Tue Sep 22 09:44:35 2009 +0200
+++ b/web/views/magicsearch.py	Tue Sep 22 09:50:45 2009 +0200
@@ -119,7 +119,7 @@
         return TRANSLATION_MAPS[lang]
     except KeyError:
         assert lang in config.translations, '%s %s' % (lang, config.translations)
-        tr = config.translations[lang]
+        tr, ctxtr = config.translations[lang]
         langmap = {}
         for etype in schema.entities():
             etype = str(etype)