[Checkins] SVN: zope.tal/trunk/ In talgettext.POEngine.translate, print a warning if a msgid already exists

Vincent Fretin vincent.fretin at gmail.com
Sun Oct 11 10:41:47 EDT 2009


Log message for revision 105014:
  In talgettext.POEngine.translate, print a warning if a msgid already exists
  in the domain with a different default.
  

Changed:
  U   zope.tal/trunk/CHANGES.txt
  U   zope.tal/trunk/src/zope/tal/talgettext.py

-=-
Modified: zope.tal/trunk/CHANGES.txt
===================================================================
--- zope.tal/trunk/CHANGES.txt	2009-10-11 12:08:53 UTC (rev 105013)
+++ zope.tal/trunk/CHANGES.txt	2009-10-11 14:41:46 UTC (rev 105014)
@@ -5,7 +5,8 @@
 3.5.2 (unreleased)
 ------------------
 
-- ...
+- In talgettext.POEngine.translate, print a warning if a msgid already exists
+  in the domain with a different default.
 
 
 3.5.1 (2009-03-08)

Modified: zope.tal/trunk/src/zope/tal/talgettext.py
===================================================================
--- zope.tal/trunk/src/zope/tal/talgettext.py	2009-10-11 12:08:53 UTC (rev 105013)
+++ zope.tal/trunk/src/zope/tal/talgettext.py	2009-10-11 14:41:46 UTC (rev 105014)
@@ -115,11 +115,9 @@
                   # interface
                   position=None):
 
-        # Make the message is a Message object, if the default differs
-        # from the value, so that the POT generator can put the default
-        # text into a comment.
-        if default is not None and normalize(default) != msgid:
-            msgid = Message(msgid, default=default)
+        if default is not None:
+            default = normalize(default)
+        msgid = Message(msgid, default=default)
 
         if domain not in self.catalog:
             self.catalog[domain] = {}
@@ -127,6 +125,16 @@
 
         if msgid not in domain:
             domain[msgid] = []
+        else:
+            msgids = domain.keys()
+            idx = msgids.index(msgid)
+            existing_msgid = msgids[idx]
+            if msgid.default != existing_msgid.default:
+                references = '\n'.join([location[0]+':'+str(location[1]) for location in domain[msgid]])
+                print >> sys.stderr, "Warning: msgid '%s' in %s already exists " \
+                         "with a different default (bad: %s, should be: %s)\n" \
+                         "The references for the existent value are:\n%s\n" % \
+                         (msgid, self.file+':'+str(position), msgid.default, existing_msgid.default, references)
         domain[msgid].append((self.file, position))
         return 'x'
 



More information about the checkins mailing list