translate / pootle

Online translation tool
http://pootle.translatehouse.org
GNU General Public License v3.0
1.49k stars 288 forks source link

Uploading files can add or remove strings, ‘corrupting’ the translation files #4565

Open huftis opened 8 years ago

huftis commented 8 years ago

When uploading a .po file, the file on Pootle seems to be completely replaced by the uploaded file. So uploading a file can add strings (not existing in the template / original file) or remove strings (make them no longer available for translation). This can be a big problem. Example:

The strings on Pootle are:

msgid "foo"
msgstr "footrans"

msgid "bar"
msgstr "bartrans"

msgid "baz"
msgstr ""

The user uploads a file containing

msgid "foo"
msgstr "footransv2"

msgid "baz"
msgstr "baztrans"

msgid "newstring"
msgstr "newtrans"

msgid "newstring2"
msgstr ""

The resulting file on Pootle will contain the contents of the uploaded file, i.e. 4 strings (2 of them new, 2 of them with updated content, and 1 of the old ones is deleted).

Expected result: Any translations on Pootle will be replaced by the ones in the uploaded file. No strings will be deleted, and no new strings added. So the result should have been:

msgid "foo"
msgstr "footransv2"

msgid "bar"
msgstr "bartrans"

msgid "baz"
msgstr "baztrans"

If the uploaded file instead only contained

msgid "bar"
msgstr ""

The result should have been

msgid "foo"
msgstr "footrans"

msgid "bar"
msgstr ""

msgid "baz"
msgstr ""

That is, the existing translation of ‘bar’ was replaced by the empty ‘translation’ in the uploaded file. (It is sometimes useful to remove (usually bad) translations this way.) Similarly, if the uploaded files contained a fuzzy string, the string on Pootle should be made fuzzy. Basically, the algorithm should be very simple:

For each string in Pootle, check if the same string exists (as a non-obsolete string) in the uploaded file. If it does, replace the translation in Pootle by the translation in the uploaded file (including any fuzzy status or translator comment).

Then the user can neither add new strings or delete old ones, making the PO file out of sync with the templates, but can update any strings (including changing its status or removing its translation). In other words, the user can do exactly the same actions as she/he could do in a normal PO editor. I think this is the expected behaviour for people working offline.

unho commented 8 years ago

This issue consists in a bug and a feature request. Please split them into two separate issues.

ta2-1 commented 8 years ago

Hi @huftis, recently https://github.com/translate/pootle/issues/4302 was fixed where we restricted adding new and removing existing units. Only translation is available. @unho I hope there is no bug any more.

huftis commented 8 years ago

Thank you for the information. I’ll try upgrading to the latest Github version (in the coming days) and take a look and report if everything’s working as expected.