Merge lp:~wgrant/launchpad/bug-1158854 into lp:launchpad

Proposed by William Grant
Status: Merged
Merged at revision: 16547
Proposed branch: lp:~wgrant/launchpad/bug-1158854
Merge into: lp:launchpad
Diff against target: 51 lines (+7/-6)
2 files modified
lib/lp/translations/doc/vpoexport.txt (+2/-0)
lib/lp/translations/model/pofile.py (+5/-6)
To merge this branch: bzr merge lp:~wgrant/launchpad/bug-1158854
Reviewer Review Type Date Requested Status
Steve Kowalik (community) code Approve
Review via email: mp+155892@code.launchpad.net

Commit message

Fix POFile.getTranslationRows() to do the message sharing filter in the join condition, since otherwise we end up excluding POTMsgSets that are only translated in another template. Fixes PO exports missing some untranslated strings.

Description of the change

POFile.getTranslationRows was accidentally not returning potmsgsets that were untranslated except in a different template. Translated sets were returned, and entirely untranslated sets were too, but sets with only a diverged translation for another template were missing. This branch fixes the core query in POFile._selectRows to do the message sharing filter in the join condition rather than in the WHERE clause, so a null row can be returned even if there's a non-null row.

To post a comment you must log in.
Revision history for this message
Steve Kowalik (stevenk) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/translations/doc/vpoexport.txt'
2--- lib/lp/translations/doc/vpoexport.txt 2011-02-24 14:31:46 +0000
3+++ lib/lp/translations/doc/vpoexport.txt 2013-03-28 05:25:26 +0000
4@@ -139,9 +139,11 @@
5 >>> for row in trunk_pofile.getTranslationRows():
6 ... print describe_poexport_row(row)
7 1 1 een
8+ 2 2 None
9
10 In an export for stable, only the stable message shows up.
11
12 >>> for row in stable_pofile.getTranslationRows():
13 ... print describe_poexport_row(row)
14 2 2 twee
15+ 1 1 None
16
17=== modified file 'lib/lp/translations/model/pofile.py'
18--- lib/lp/translations/model/pofile.py 2013-01-07 02:40:55 +0000
19+++ lib/lp/translations/model/pofile.py 2013-03-28 05:25:26 +0000
20@@ -1233,13 +1233,17 @@
21
22 flag_name = getUtility(ITranslationSideTraitsSet).getForTemplate(
23 self.potemplate).flag_name
24+ template_id = quote(self.potemplate)
25 params = {
26 'flag': flag_name,
27 'language': quote(self.language),
28+ 'template': template_id,
29 }
30 query = main_select + """
31 FROM TranslationTemplateItem
32 LEFT JOIN TranslationMessage ON
33+ (TranslationMessage.potemplate IS NULL
34+ OR TranslationMessage.potemplate = %(template)s) AND
35 TranslationMessage.potmsgset =
36 TranslationTemplateItem.potmsgset AND
37 TranslationMessage.%(flag)s IS TRUE AND
38@@ -1252,12 +1256,7 @@
39 query += "LEFT JOIN POTranslation AS %s ON %s.id = %s\n" % (
40 alias, alias, field)
41
42- template_id = quote(self.potemplate)
43- conditions = [
44- "TranslationTemplateItem.potemplate = %s" % template_id,
45- "(TranslationMessage.potemplate IS NULL OR "
46- "TranslationMessage.potemplate = %s)" % template_id,
47- ]
48+ conditions = ["TranslationTemplateItem.potemplate = %s" % template_id]
49
50 if ignore_obsolete:
51 conditions.append("TranslationTemplateItem.sequence <> 0")