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

Proposed by William Grant
Status: Merged
Approved by: Steve Kowalik
Approved revision: no longer in the source branch.
Merged at revision: 16552
Proposed branch: lp:~wgrant/launchpad/bug-503421
Merge into: lp:launchpad
Diff against target: 58 lines (+37/-0)
2 files modified
lib/lp/translations/model/potemplate.py (+4/-0)
lib/lp/translations/tests/test_pofile.py (+33/-0)
To merge this branch: bzr merge lp:~wgrant/launchpad/bug-503421
Reviewer Review Type Date Requested Status
Steve Kowalik (community) code Approve
Review via email: mp+157033@code.launchpad.net

Commit message

When creating shared pofiles, ensure that all of their translation credits strings are set to translated. Previously only the credits string in the initial pofile was translated, leaving the others untranslated if their msgids differed, or there was no credit string in the initial template.

Description of the change

Translation credit messages get automatically populated with a dummy translation by newPOFile. Additionally, newPOFile creates corresponding pofiles in sharing templates if they don't already exist. But it doesn't populate translation credit messages in those sharing pofiles, instead assuming that message sharing will sort it out. This works fine until one of the sharing templates has a credits message that doesn't exist in the original template, leaving the credits in those sharing templates untranslated, making it impossible to reach 100% translation.

I've adjusted newPOFile to populate any credits strings in the other pofiles that it creates. We'll have to rerun the existing credit fixing script once this fix is out.

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/model/potemplate.py'
2--- lib/lp/translations/model/potemplate.py 2013-01-07 02:40:55 +0000
3+++ lib/lp/translations/model/potemplate.py 2013-04-04 06:55:27 +0000
4@@ -768,6 +768,10 @@
5 # Update cache to reflect the change.
6 template._cached_pofiles_by_language[language_code] = pofile
7
8+ # Set dummy translations for translation credits in this POFile.
9+ for credits in template.getTranslationCredits():
10+ credits.setTranslationCreditsToTranslated(pofile)
11+
12 def newPOFile(self, language_code, create_sharing=True, owner=None):
13 """See `IPOTemplate`."""
14 # Make sure we don't already have a PO file for this language.
15
16=== modified file 'lib/lp/translations/tests/test_pofile.py'
17--- lib/lp/translations/tests/test_pofile.py 2012-11-09 16:34:45 +0000
18+++ lib/lp/translations/tests/test_pofile.py 2013-04-04 06:55:27 +0000
19@@ -1035,6 +1035,39 @@
20 self.assertNotEqual(None, stable_potemplate.getPOFileByLang('eo'))
21 self.assertNotEqual(None, stable_potemplate.getPOFileByLang('de'))
22
23+ def test_pofile_creation_sharing_with_credits(self):
24+ # When pofiles are created due to sharing, any credits messages
25+ # in the new pofiles are translated, even if they have different
26+ # names.
27+ devel_potemplate = self.factory.makePOTemplate(
28+ productseries=self.foo_devel, name="messages")
29+ stable_potemplate = self.factory.makePOTemplate(
30+ productseries=self.foo_stable, name="messages")
31+ devel_credits = self.factory.makePOTMsgSet(
32+ potemplate=devel_potemplate, singular=u'translator-credits')
33+ stable_credits = self.factory.makePOTMsgSet(
34+ potemplate=stable_potemplate, singular=u'translation-credits')
35+
36+ # Create one language from the devel end, and the other from
37+ # stable.
38+ devel_eo = devel_potemplate.newPOFile('eo')
39+ stable_eo = stable_potemplate.getPOFileByLang('eo')
40+ stable_is = stable_potemplate.newPOFile('is')
41+ devel_is = devel_potemplate.getPOFileByLang('is')
42+
43+ # Even though the devel and stable credits msgids are different,
44+ # both are translated for both languages.
45+ for ms, po in [
46+ (devel_credits, devel_eo),
47+ (devel_credits, devel_is),
48+ (stable_credits, stable_eo),
49+ (stable_credits, stable_is)]:
50+ self.assertIsNot(
51+ None,
52+ ms.getCurrentTranslation(
53+ po.potemplate, po.language,
54+ po.potemplate.translation_side))
55+
56
57 class TestTranslationCredits(TestCaseWithFactory):
58 """Test generation of translation credits."""