[Zope3-checkins] CVS: Zope3/lib/python/Zope/I18n - GettextMessageCatalog.py:1.4 IMessageCatalog.py:1.6 ITranslationService.py:1.6 SimpleTranslationService.py:1.3

Florent Guillaume fg@nuxeo.com
Sun, 6 Oct 2002 13:44:40 -0400


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

Modified Files:
	GettextMessageCatalog.py IMessageCatalog.py 
	ITranslationService.py SimpleTranslationService.py 
Log Message:
Modified translation service and message catalog interface to be able to
return None when no translation is available.


=== Zope3/lib/python/Zope/I18n/GettextMessageCatalog.py 1.3 => 1.4 ===
--- Zope3/lib/python/Zope/I18n/GettextMessageCatalog.py:1.3	Sun Jun 16 14:25:13 2002
+++ Zope3/lib/python/Zope/I18n/GettextMessageCatalog.py	Sun Oct  6 13:44:39 2002
@@ -61,8 +61,6 @@
         text = self.__translation_object.ugettext(id)
         if text != id:
             return text
-        if default is None:
-            default = id
         return default
 
     def getLanguage(self):


=== Zope3/lib/python/Zope/I18n/IMessageCatalog.py 1.5 => 1.6 ===
--- Zope3/lib/python/Zope/I18n/IMessageCatalog.py:1.5	Sun Jun 16 14:25:13 2002
+++ Zope3/lib/python/Zope/I18n/IMessageCatalog.py	Sun Oct  6 13:44:39 2002
@@ -51,9 +51,7 @@
     def queryMessage(msgid, default=None):
         """Look for the appropriate text for the given message id.
 
-        If the message id is not found, no exception is raised.  Instead
-        default is returned, but if default is None, then msgid itself is
-        returned.
+        If the message id is not found, default is returned.
         """
 
     def getLanguage():


=== Zope3/lib/python/Zope/I18n/ITranslationService.py 1.5 => 1.6 ===
--- Zope3/lib/python/Zope/I18n/ITranslationService.py:1.5	Fri Aug 23 14:07:21 2002
+++ Zope3/lib/python/Zope/I18n/ITranslationService.py	Sun Oct  6 13:44:39 2002
@@ -60,6 +60,8 @@
                   context=None, target_language=None):
         """Return the translation for the message referred to by msgid.
 
+        Return None if no translation is found.
+
         However, the method does a little more than a vanilla translation.
         The method also looks for a possible language to translate to.
         After a translation it also replaces any $name variable variables


=== Zope3/lib/python/Zope/I18n/SimpleTranslationService.py 1.2 => 1.3 ===
--- Zope3/lib/python/Zope/I18n/SimpleTranslationService.py:1.2	Wed Jun 12 16:58:13 2002
+++ Zope3/lib/python/Zope/I18n/SimpleTranslationService.py	Sun Oct  6 13:44:39 2002
@@ -73,7 +73,7 @@
                 target_language = negotiator.getLanguage(langs, context)
 
         # Make a raw translation without interpolation
-        text = self.messages.get((domain, target_language, msgid), msgid)
+        text = self.messages.get((domain, target_language, msgid))
 
         # Now we need to do the interpolation
         return self.interpolate(text, mapping)
@@ -89,6 +89,10 @@
 
     def interpolate(self, text, mapping):
         """Insert the data passed from mapping into the text"""
+
+        # If no translation was found, there is nothing to do.
+        if text is None:
+            return None
 
         # If the mapping does not exist, make a "raw translation" without
         # interpolation.