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
=== modified file 'lib/lp/translations/model/potemplate.py'
--- lib/lp/translations/model/potemplate.py 2013-01-07 02:40:55 +0000
+++ lib/lp/translations/model/potemplate.py 2013-04-04 06:55:27 +0000
@@ -768,6 +768,10 @@
768 # Update cache to reflect the change.768 # Update cache to reflect the change.
769 template._cached_pofiles_by_language[language_code] = pofile769 template._cached_pofiles_by_language[language_code] = pofile
770770
771 # Set dummy translations for translation credits in this POFile.
772 for credits in template.getTranslationCredits():
773 credits.setTranslationCreditsToTranslated(pofile)
774
771 def newPOFile(self, language_code, create_sharing=True, owner=None):775 def newPOFile(self, language_code, create_sharing=True, owner=None):
772 """See `IPOTemplate`."""776 """See `IPOTemplate`."""
773 # Make sure we don't already have a PO file for this language.777 # Make sure we don't already have a PO file for this language.
774778
=== modified file 'lib/lp/translations/tests/test_pofile.py'
--- lib/lp/translations/tests/test_pofile.py 2012-11-09 16:34:45 +0000
+++ lib/lp/translations/tests/test_pofile.py 2013-04-04 06:55:27 +0000
@@ -1035,6 +1035,39 @@
1035 self.assertNotEqual(None, stable_potemplate.getPOFileByLang('eo'))1035 self.assertNotEqual(None, stable_potemplate.getPOFileByLang('eo'))
1036 self.assertNotEqual(None, stable_potemplate.getPOFileByLang('de'))1036 self.assertNotEqual(None, stable_potemplate.getPOFileByLang('de'))
10371037
1038 def test_pofile_creation_sharing_with_credits(self):
1039 # When pofiles are created due to sharing, any credits messages
1040 # in the new pofiles are translated, even if they have different
1041 # names.
1042 devel_potemplate = self.factory.makePOTemplate(
1043 productseries=self.foo_devel, name="messages")
1044 stable_potemplate = self.factory.makePOTemplate(
1045 productseries=self.foo_stable, name="messages")
1046 devel_credits = self.factory.makePOTMsgSet(
1047 potemplate=devel_potemplate, singular=u'translator-credits')
1048 stable_credits = self.factory.makePOTMsgSet(
1049 potemplate=stable_potemplate, singular=u'translation-credits')
1050
1051 # Create one language from the devel end, and the other from
1052 # stable.
1053 devel_eo = devel_potemplate.newPOFile('eo')
1054 stable_eo = stable_potemplate.getPOFileByLang('eo')
1055 stable_is = stable_potemplate.newPOFile('is')
1056 devel_is = devel_potemplate.getPOFileByLang('is')
1057
1058 # Even though the devel and stable credits msgids are different,
1059 # both are translated for both languages.
1060 for ms, po in [
1061 (devel_credits, devel_eo),
1062 (devel_credits, devel_is),
1063 (stable_credits, stable_eo),
1064 (stable_credits, stable_is)]:
1065 self.assertIsNot(
1066 None,
1067 ms.getCurrentTranslation(
1068 po.potemplate, po.language,
1069 po.potemplate.translation_side))
1070
10381071
1039class TestTranslationCredits(TestCaseWithFactory):1072class TestTranslationCredits(TestCaseWithFactory):
1040 """Test generation of translation credits."""1073 """Test generation of translation credits."""