[Zope-Checkins] CVS: Zope3/lib/python/Zope/I18n - TranslationService.py:1.9 configure.zcml:1.8

Stephan Richter srichter@cbu.edu
Wed, 10 Jul 2002 20:54:03 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/I18n
In directory cvs.zope.org:/tmp/cvs-serv23423/Zope/I18n

Modified Files:
	TranslationService.py configure.zcml 
Log Message:
 Adjustments to DTML and other code


=== Zope3/lib/python/Zope/I18n/TranslationService.py 1.8 => 1.9 ===
 from Persistence.BTrees.OOBTree import OOBTree
 
 from Zope.ComponentArchitecture import createObject
-from Zope.ComponentArchitecture import getService
+from Zope.ComponentArchitecture import getService, queryNextService
 
 from Zope.App.OFS.Container.BTreeContainer import BTreeContainer
 from Zope.App.OFS.Container.IContainer import IContainer
@@ -102,7 +102,6 @@
     def translate(self, domain, msgid, mapping=None, context=None,  
                   target_language=None):
         """See interface ITranslationService"""
-
         if domain is None:
             domain = self.default_domain
 
@@ -122,6 +121,16 @@
         for name in catalog_names:
             catalog = super(TranslationService, self).__getitem__(name)
             text = catalog.queryMessage(msgid)
+
+        # If the message id equals the returned text, then we should look up
+        # a translation server higher up the tree.
+        if text == msgid:
+            ts = queryNextService(self, 'TranslationService')
+            if ts is not None:
+                return ts.translate(domain, msgid, mapping, context,
+                                    target_language)
+            else:
+                return text
 
         # Now we need to do the interpolation
         return self.interpolate(text, mapping)


=== Zope3/lib/python/Zope/I18n/configure.zcml 1.7 => 1.8 ===
      action="TranslationService"  title="Translation Service"
      description="A Persistent Translation Service for TTW development" />
 
-<serviceType id="GlobalTranslationService"
+<serviceType id="TranslationService"
              interface=".ITranslationService." />
 
-<service serviceType="GlobalTranslationService"
+<service serviceType="TranslationService"
            permission="Zope.Public"
            component=".GlobalTranslationService.translationService" />