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
=== modified file 'lib/lp/translations/doc/vpoexport.txt'
--- lib/lp/translations/doc/vpoexport.txt 2011-02-24 14:31:46 +0000
+++ lib/lp/translations/doc/vpoexport.txt 2013-03-28 05:25:26 +0000
@@ -139,9 +139,11 @@
139 >>> for row in trunk_pofile.getTranslationRows():139 >>> for row in trunk_pofile.getTranslationRows():
140 ... print describe_poexport_row(row)140 ... print describe_poexport_row(row)
141 1 1 een141 1 1 een
142 2 2 None
142143
143In an export for stable, only the stable message shows up.144In an export for stable, only the stable message shows up.
144145
145 >>> for row in stable_pofile.getTranslationRows():146 >>> for row in stable_pofile.getTranslationRows():
146 ... print describe_poexport_row(row)147 ... print describe_poexport_row(row)
147 2 2 twee148 2 2 twee
149 1 1 None
148150
=== modified file 'lib/lp/translations/model/pofile.py'
--- lib/lp/translations/model/pofile.py 2013-01-07 02:40:55 +0000
+++ lib/lp/translations/model/pofile.py 2013-03-28 05:25:26 +0000
@@ -1233,13 +1233,17 @@
12331233
1234 flag_name = getUtility(ITranslationSideTraitsSet).getForTemplate(1234 flag_name = getUtility(ITranslationSideTraitsSet).getForTemplate(
1235 self.potemplate).flag_name1235 self.potemplate).flag_name
1236 template_id = quote(self.potemplate)
1236 params = {1237 params = {
1237 'flag': flag_name,1238 'flag': flag_name,
1238 'language': quote(self.language),1239 'language': quote(self.language),
1240 'template': template_id,
1239 }1241 }
1240 query = main_select + """1242 query = main_select + """
1241 FROM TranslationTemplateItem1243 FROM TranslationTemplateItem
1242 LEFT JOIN TranslationMessage ON1244 LEFT JOIN TranslationMessage ON
1245 (TranslationMessage.potemplate IS NULL
1246 OR TranslationMessage.potemplate = %(template)s) AND
1243 TranslationMessage.potmsgset =1247 TranslationMessage.potmsgset =
1244 TranslationTemplateItem.potmsgset AND1248 TranslationTemplateItem.potmsgset AND
1245 TranslationMessage.%(flag)s IS TRUE AND1249 TranslationMessage.%(flag)s IS TRUE AND
@@ -1252,12 +1256,7 @@
1252 query += "LEFT JOIN POTranslation AS %s ON %s.id = %s\n" % (1256 query += "LEFT JOIN POTranslation AS %s ON %s.id = %s\n" % (
1253 alias, alias, field)1257 alias, alias, field)
12541258
1255 template_id = quote(self.potemplate)1259 conditions = ["TranslationTemplateItem.potemplate = %s" % template_id]
1256 conditions = [
1257 "TranslationTemplateItem.potemplate = %s" % template_id,
1258 "(TranslationMessage.potemplate IS NULL OR "
1259 "TranslationMessage.potemplate = %s)" % template_id,
1260 ]
12611260
1262 if ignore_obsolete:1261 if ignore_obsolete:
1263 conditions.append("TranslationTemplateItem.sequence <> 0")1262 conditions.append("TranslationTemplateItem.sequence <> 0")