[Zope3-checkins] CVS: Zope3/src/zope/tal - talinterpreter.py:1.5

Barry Warsaw barry@wooz.org
Tue, 25 Mar 2003 15:21:29 -0500


Update of /cvs-repository/Zope3/src/zope/tal
In directory cvs.zope.org:/tmp/cvs-serv25905/src/zope/tal

Modified Files:
	talinterpreter.py 
Log Message:
Add an ITranslator interface and a Translator implementation of that
interface.  This is basically a glue class for specifying the domain,
context, and locale in one packet and then providing a translate()
method which just takes the message id and mapping.

Glue this into the Zope app's page template engine.

Also removed some unused code and fix some typos.


=== Zope3/src/zope/tal/talinterpreter.py 1.4 => 1.5 ===
--- Zope3/src/zope/tal/talinterpreter.py:1.4	Tue Mar 25 11:22:29 2003
+++ Zope3/src/zope/tal/talinterpreter.py	Tue Mar 25 15:21:29 2003
@@ -527,7 +527,6 @@
         # We only care about the evaluated contents if we need an implicit
         # message id.  All other useful information will be in the i18ndict on
         # the top of the i18nStack.
-
         default = normalize(tmpstream.getvalue())
         if msgid == '':
             msgid = default
@@ -543,23 +542,22 @@
         # want to escape stuff like ${name} <= "<b>Timmy</b>".
         #s = escape(xlated_msgid)
         s = xlated_msgid
-
-        # watch out for unknown translation message id
-        # The Plone people would like the i18n translation to return
-        # the default text when the message ID is not found in the
-        # translation table and there is an explicit message ID.
-        # example:
-        # <span i18n:translate="explict id">default text</span>
-        # will return
-        # <span>default text</span>
-        # if "explicit id" is not in the translation table
-        
+        # Watch out for unknown translation message id.  In this case, and
+        # when both an explicit message id and default text are given, the
+        # Plone people want the default text, so by Papal Edict this is what
+        # we return.  For example:
+        #
+        #     <span i18n:translate="explict id">default text</span>
+        #
+        # returns
+        #
+        #     <span>default text</span>
         if s is None:
             s = default or msgid
-
             # log that an unknown id was found
-            logging.warn('TAL/i18n: Message id %s was not found in the translation table; using default text.' % msgid)
-            
+            logging.warn('TAL/i18n: Message id %s was not found in the '
+                         'translation table; using default text: %s' %
+                         (msgid, default))
         # If there are i18n variables to interpolate into this string, better
         # do it now.
         self._stream_write(s)