It looks to me as if we may be exporting the wrong diverged TranslationMessages as part of language packs.
The POExport view joins a TranslationMessage to all POTemplates that use its POTMsgSet. It keeps a separate "diverged" FK to TranslationMessage.potemplate. That's good design, but I don't see anything to filter out cases where diverged is neither null nor equal to potemplate. Then POFile._getMessages gives precedence to diverged messages—but doesn't check that they are diverged to the current POTemplate rather than to some other POTemplate that it shares with.
We could solve this in at least two ways:
1. In the view: "WHERE diverged IS NULL OR diverged = potemplate." May make the SQL slower but will also return fewer rows, which is good.
2. In POFile._getMessages:
if row.diverged == row.potemplate: diverged_messages.append(msg_key)
elif row.diverged is None:
# This message is shared.
if msg_key in diverged_messages: continue
else:
# This diverged message belongs to a different template.
continue
If it doesn't upset the applecart too much I'd prefer the SQL solution.
It looks to me as if we may be exporting the wrong diverged TranslationMessages as part of language packs.
The POExport view joins a TranslationMessage to all POTemplates that use its POTMsgSet. It keeps a separate "diverged" FK to TranslationMess age.potemplate. That's good design, but I don't see anything to filter out cases where diverged is neither null nor equal to potemplate. Then POFile._getMessages gives precedence to diverged messages—but doesn't check that they are diverged to the current POTemplate rather than to some other POTemplate that it shares with.
We could solve this in at least two ways:
1. In the view: "WHERE diverged IS NULL OR diverged = potemplate." May make the SQL slower but will also return fewer rows, which is good.
2. In POFile. _getMessages:
diverged_ messages. append( msg_key)
continue
if row.diverged == row.potemplate:
elif row.diverged is None:
# This message is shared.
if msg_key in diverged_messages:
else:
# This diverged message belongs to a different template.
continue
If it doesn't upset the applecart too much I'd prefer the SQL solution.