Merge lp:~danilo/launchpad/bug-548375 into lp:launchpad

Proposed by Данило Шеган
Status: Merged
Merged at revision: 11501
Proposed branch: lp:~danilo/launchpad/bug-548375
Merge into: lp:launchpad
To merge this branch: bzr merge lp:~danilo/launchpad/bug-548375
Reviewer Review Type Date Requested Status
Launchpad code reviewers Pending
Review via email: mp+34607@code.launchpad.net

Description of the change

= Bug #548375 =

Ignore empty translations on import (always). We've also considered
keeping the ability to revert translations with non-published uploads,
but it would be more work for dubious benefit. For now, what users
want is for imports to simply not introduce empty messages. We get that
here.

Most of the changes are cleanups and lint fixes. Basically, only the change

@@ -449,7 +449,9 @@ class FileImporter(object):
             # store English strings in an IPOFile.
             return None

- if not message.translations:
+ if (not message.translations or
+ set(message.translations) == set([u'']) or
+ set(message.translations) == set([None])):
             # We don't have anything to import.
             return None

is important here. Since message.translations is never going to be
more than 6 items, I didn't bother optimizing this (i.e. do a
set(message.translations) once and use that in further comparisons).

The tests are split into two methods so it's clearer what we do for
both cases (I've first written tests which assert previous behavior,
then unified the code using a helper private method).

== Tests ==

bin/test -cvvt storeTranslationsInDatabase_empty

== Demo and Q/A ==

= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/translations/utilities/tests/test_translation_importer.py
  lib/lp/translations/utilities/tests/test_file_importer.py
  lib/lp/translations/utilities/translation_import.py

To post a comment you must log in.