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)
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' translations/ model/potmsgset .py 2010-08-26 08:51:48 +0000 translations/ model/potmsgset .py 2010-09-01 14:11:25 +0000 TranslationCons tants.MAX_ PLURAL_ FORMS): pluralform] is not None): get(pluralform) pluralform] pluralform] = ( getOrCreateTran slation( translation) ) pluralform] = None nMessage( self, pofile, potranslations, shared= True): Message( self, pofile, translations=None, None, prefer_ shared= False):
>--- lib/lp/
>+++ lib/lp/
>@@ -560,25 +562,39 @@
> potranslations = {}
> # Set all POTranslations we can have (up to MAX_PLURAL_FORMS)
> for pluralform in xrange(
>- if (pluralform in translations and
>- translations[
>+ translation = translations.
>+ if translation is not None:
> # Find or create a POTranslation for the specified text
>- translation = translations[
> potranslations[
> POTranslation.
> else:
> potranslations[
> return potranslations
>
>- def _findTranslatio
>- prefer_
>- """Find a matching message in this `pofile`.
>+ def findTranslation
>+ potranslations=
The potranslations parameter can be removed.
>+ """Find the best matching message in this `pofile`. nslations( translations) ingTranslationM essage( shared= prefer_ shared)
>
> 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._findPOTra
>+ return self._findMatch
>+ pofile, potranslations, prefer_