diff options
author | Vincent Fretin <vincent.fretin@gmail.com> | 2009-10-11 14:41:46 +0000 |
---|---|---|
committer | Vincent Fretin <vincent.fretin@gmail.com> | 2009-10-11 14:41:46 +0000 |
commit | 54797e0ffda208d5d5a5e81c5b13c87aadeb9c99 (patch) | |
tree | d6782a3cce95fb8014e9ca61612b81a1d2b023e9 | |
parent | cac0418eb9957fdce3b98ef507f0a15bf7fc24b3 (diff) | |
download | zope-tal-54797e0ffda208d5d5a5e81c5b13c87aadeb9c99.tar.gz |
In talgettext.POEngine.translate, print a warning if a msgid already exists
in the domain with a different default.
-rw-r--r-- | CHANGES.txt | 3 | ||||
-rw-r--r-- | src/zope/tal/talgettext.py | 18 |
2 files changed, 15 insertions, 6 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index da2b6a4..a16260a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -5,7 +5,8 @@ CHANGES 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) diff --git a/src/zope/tal/talgettext.py b/src/zope/tal/talgettext.py index 2a0d794..1db2c71 100644 --- a/src/zope/tal/talgettext.py +++ b/src/zope/tal/talgettext.py @@ -115,11 +115,9 @@ class POEngine(DummyEngine): # 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 @@ class POEngine(DummyEngine): 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' |