Code review comment for lp:~jtv/launchpad/recife-findtranslationmessage

Revision history for this message
Edwin Grubbs (edwin-grubbs) wrote :

Hi Jeroen,

This is a nice branch. I just have one comment below that we already discussed on IRC.

-Edwin

>=== modified file 'lib/lp/translations/model/potmsgset.py'
>--- lib/lp/translations/model/potmsgset.py 2010-08-26 08:51:48 +0000
>+++ lib/lp/translations/model/potmsgset.py 2010-09-01 14:11:25 +0000
>@@ -560,25 +562,39 @@
> potranslations = {}
> # Set all POTranslations we can have (up to MAX_PLURAL_FORMS)
> for pluralform in xrange(TranslationConstants.MAX_PLURAL_FORMS):
>- if (pluralform in translations and
>- translations[pluralform] is not None):
>+ translation = translations.get(pluralform)
>+ if translation is not None:
> # Find or create a POTranslation for the specified text
>- translation = translations[pluralform]
> potranslations[pluralform] = (
> POTranslation.getOrCreateTranslation(translation))
> else:
> potranslations[pluralform] = None
> return potranslations
>
>- def _findTranslationMessage(self, pofile, potranslations,
>- prefer_shared=True):
>- """Find a matching message in this `pofile`.
>+ def findTranslationMessage(self, pofile, translations=None,
>+ potranslations=None, prefer_shared=False):

The potranslations parameter can be removed.

>+ """Find the best matching message in this `pofile`.
>
> The returned message matches exactly the given `translations`
> strings (except plural forms not supported by `pofile`, which
>- are ignored).
>-
>- :param potranslations: A list of translation strings.
>+ are ignored in the comparison).
>+
>+ :param translations: A dict mapping plural forms to translation
>+ strings.
>+ :param prefer_shared: Whether to prefer a shared match over a
>+ diverged one.
>+ """
>+ potranslations = self._findPOTranslations(translations)
>+ return self._findMatchingTranslationMessage(
>+ pofile, potranslations, prefer_shared=prefer_shared)

review: Approve (code)

« Back to merge proposal