← Back to team overview

launchpad-reviewers team mailing list archive

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

 

William Grant has proposed merging lp:~wgrant/launchpad/bug-503421 into lp:launchpad.

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.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #503421 in Launchpad itself: "Even after fixing translator-credits, some still remain untranslated."
  https://bugs.launchpad.net/launchpad/+bug/503421

For more details, see:
https://code.launchpad.net/~wgrant/launchpad/bug-503421/+merge/157033

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.
-- 
https://code.launchpad.net/~wgrant/launchpad/bug-503421/+merge/157033
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/bug-503421 into lp:launchpad.
=== 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 @@
             # Update cache to reflect the change.
             template._cached_pofiles_by_language[language_code] = pofile
 
+            # Set dummy translations for translation credits in this POFile.
+            for credits in template.getTranslationCredits():
+                credits.setTranslationCreditsToTranslated(pofile)
+
     def newPOFile(self, language_code, create_sharing=True, owner=None):
         """See `IPOTemplate`."""
         # Make sure we don't already have a PO file for this language.

=== 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 @@
         self.assertNotEqual(None, stable_potemplate.getPOFileByLang('eo'))
         self.assertNotEqual(None, stable_potemplate.getPOFileByLang('de'))
 
+    def test_pofile_creation_sharing_with_credits(self):
+        # When pofiles are created due to sharing, any credits messages
+        # in the new pofiles are translated, even if they have different
+        # names.
+        devel_potemplate = self.factory.makePOTemplate(
+            productseries=self.foo_devel, name="messages")
+        stable_potemplate = self.factory.makePOTemplate(
+            productseries=self.foo_stable, name="messages")
+        devel_credits = self.factory.makePOTMsgSet(
+            potemplate=devel_potemplate, singular=u'translator-credits')
+        stable_credits = self.factory.makePOTMsgSet(
+            potemplate=stable_potemplate, singular=u'translation-credits')
+
+        # Create one language from the devel end, and the other from
+        # stable.
+        devel_eo = devel_potemplate.newPOFile('eo')
+        stable_eo = stable_potemplate.getPOFileByLang('eo')
+        stable_is = stable_potemplate.newPOFile('is')
+        devel_is = devel_potemplate.getPOFileByLang('is')
+
+        # Even though the devel and stable credits msgids are different,
+        # both are translated for both languages.
+        for ms, po in [
+                (devel_credits, devel_eo),
+                (devel_credits, devel_is),
+                (stable_credits, stable_eo),
+                (stable_credits, stable_is)]:
+            self.assertIsNot(
+                None,
+                ms.getCurrentTranslation(
+                    po.potemplate, po.language,
+                    po.potemplate.translation_side))
+
 
 class TestTranslationCredits(TestCaseWithFactory):
     """Test generation of translation credits."""