Bug 1023258

Summary: Copy Trans not using the most current translation.
Product: [Retired] Zanata Reporter: Carlos Munoz <camunoz>
Component: Component-CopyTransAssignee: Carlos Munoz <camunoz>
Status: CLOSED CURRENTRELEASE QA Contact: Ding-Yi Chen <dchen>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 3.1CC: dchen, ecohen, irooskov, mospina, sflaniga, ykatabam, zanata-bugs
Target Milestone: ---   
Target Release: 3.1   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 3.1.3-SNAPSHOT (20131118-0023) Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-11-27 03:23:42 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Carlos Munoz 2013-10-25 03:24:20 UTC
Description of problem:
Copy trans is not using the most current translation in all cases.
The following scenario describes what happens: 
Assume that there is a translation for a given string (lets call it 'trans') and given locale in all versions mentioned below:

Project A, version A.1 Created and translated on 2013
Project B, version B.1 Created and translated on 2012

Modify the translation for 'trans' in version B.1 making it the most recent translation for the source 'trans'

Create a new Project and version C and C.1. which contains the exact source string 'trans'.
Run copy trans on it.
The expected result is that the most recent translation (the one from B.1) is taken. Instead, the copied translation is the one from A.1.

This is due to the algorithm being used in copy trans, it only takes into account the order the translation was created, but not the last modification date.

Version-Release number of selected component (if applicable):
3.1

How reproducible:
Always when the above conditions are met.

Steps to Reproduce:
See Description of problem.

Additional info:
When running copy trans in the test scenario make sure the copy trans settings allow for all translations in all projects to be considered.

Comment 1 Carlos Munoz 2013-10-25 03:29:39 UTC
Correction to the workflow described above: The step that translates B.1 is incorrect.

Project A, version A.1 Created and translated on 2013
Project B, version B.1 Created and translated on 2012

Create a new Project and version C and C.1. which contains the exact source string 'trans'.
Run copy trans on it.
The expected result is that the most recent translation (the one from A.1) is taken. Instead, the copied translation is the one from B.1.

Comment 2 Ding-Yi Chen 2013-10-25 07:35:31 UTC
Yuko / Einav


Do you think that as long as the string matches, the newest strings should be used even if it come from other projects? or it should pick the newest translation in the same project? 

In other words, suppose:

Project A, version 1: Document ReadME, has TransA1 (translated in 2013)
Project B, version 1: Document ShowME, has TransB1 (translated in 2012)
Project C, version 1: Document ShowME, has TransC1 (translated in 2011)

The Project C, version 2 is created,
Which translation should Document ShowME used?
Is it TransA1 (the newest in the whole system)
or TransB1 (the newest that share the document name)
or TransC1 (the newest in the same document within same project)

Comment 3 Yuko Katabami 2013-10-25 07:40:15 UTC
(In reply to Ding-Yi Chen from comment #2)
> Yuko / Einav
> 
> 
> Do you think that as long as the string matches, the newest strings should
> be used even if it come from other projects? or it should pick the newest
> translation in the same project? 
> 
> In other words, suppose:
> 
> Project A, version 1: Document ReadME, has TransA1 (translated in 2013)
> Project B, version 1: Document ShowME, has TransB1 (translated in 2012)
> Project C, version 1: Document ShowME, has TransC1 (translated in 2011)
> 
> The Project C, version 2 is created,
> Which translation should Document ShowME used?
> Is it TransA1 (the newest in the whole system)
> or TransB1 (the newest that share the document name)
> or TransC1 (the newest in the same document within same project)

Hi Ding-Yi,

Are you referring to Zanata project, not versions within the same project?
If so, we need to keep our strings within the same "ovirt" project.
We don't want any other products' strings to be copied to ours.

Kind regards,

Yuko

Comment 4 Carlos Munoz 2013-10-27 23:16:49 UTC
I think that for the oVirt project this is not an issue because in their copy trans options they are explicitly asking for strings that come from the same project (https://translate.zanata.org/zanata/project/view/ovirt-engine-jrs-branding/copy_trans_opts).

But in general terms, Zanata currently tries to get the 'best match' for any translation. This means: 

1. The match that will be in the 'highest' possible state (i.e. Approved beats fuzzy)
2. The match that meets most of the criteria. So for example, if copy trans is ran with the least conservative options (All conditions are are marked as 'Next Condition'), then copy trans will first try to find a match that meets all three conditions (context, project and document id match); if not found, then one that only meets the last two conditions (project and doc id match); if nothing is found still, then it looks for one with just the last condition, and so forth until it finds something suitable.
3. In the event of finding more than one possible 'best matches', Zanata should (and this is the part that this bug addresses) pick the most recent one.
4. In the very unlikely event of finding more than one possible 'best match' with the exact same translation date, then Zanata just picks one randomly.

Comment 5 Sean Flanigan 2013-10-28 05:01:10 UTC
The problem is that Zanata has been copying translations based on the highest ID, which is equivalent to selecting translations based on their creation time.  We should have been using their modification time instead.

This is what we think happened:

Strings A1 and B1 were uploaded to the Master version in Zanata and translated there, with translation bugs.

Branch 3.2 created, strings A2 and B2 uploaded, copied from Master with bugs.

QA event #1: String A2's translation is corrected *in Branch 3.2*.  The creation time and ID are unchanged, but the modification time is updated.  The buggy translation is still in A1 in Master.

QA event #2: String B1's translation is corrected *in Master*.  The creation time and ID are unchanged, but the modification time is updated.  The buggy translation is still in B2 in Branch 3.2.

If CopyTrans is run at this point, it will select A2 and B2 from Branch 3.2 because their IDs are higher than the Master versions.  It should instead select A2 and B1, because they were the most recently modified.

NB: If CopyTrans is run at this point, it will copy A2 and B2 to create A3 and B3.  After that happens, even a fixed version of CopyTrans would copy these strings (one of them buggy), because they are the most recently modified.

Comment 6 Carlos Munoz 2013-10-31 05:38:19 UTC
Bug-Fix implemented. See:
https://github.com/zanata/zanata-server/pull/253

Technical details:
This fix will mean a slight performance hit for copy trans, but it should be negligible on smaller documents. It also means it's a bit more scalable as the query done to perform copy trans will only return a single "best" result for a text flow.

Testing notes:
Although unit tests are taking care of numerous 'simple' scenarios for copy trans, maybe we should try and set up some manual tests for other more complex ones.

Comment 7 Carlos Munoz 2013-11-13 04:49:24 UTC
This has been merged into both the release and master branches.

Please test the copy trans functionality from both the client and the Web UI.

Comment 8 Ding-Yi Chen 2013-11-14 08:40:18 UTC
VERIFIED with Zanata version 3.2-SNAPSHOT (20131114-0037)

Comment 9 Ding-Yi Chen 2013-11-14 08:42:51 UTC
Note that the 3.1 test servers are down at the moment.

Comment 10 Carlos Munoz 2013-11-14 22:52:13 UTC
Ding, is there a reason why you changed this back to ON_QA from verified?

Comment 11 Ding-Yi Chen 2013-11-14 23:52:31 UTC
As stated in comment 9, I was not able to verify the release branch.

Comment 12 Ding-Yi Chen 2013-11-18 02:53:12 UTC
VERIFIED with Zanata version 3.1.3-SNAPSHOT (20131118-0023)

Comment 13 Sean Flanigan 2013-11-27 03:13:53 UTC
Closing VERIFIED bugs for Zanata versions <= 3.1.

Comment 14 Sean Flanigan 2013-11-27 03:15:46 UTC
Closing VERIFIED bugs for Zanata versions <= 3.1.

Comment 15 Sean Flanigan 2013-11-27 03:19:23 UTC
Closing VERIFIED bugs for Zanata versions <= 3.1.

Comment 16 Sean Flanigan 2013-11-27 03:23:42 UTC
Closing VERIFIED bugs for Zanata versions <= 3.1.

Comment 17 Sean Flanigan 2013-11-27 03:34:08 UTC
Closing VERIFIED bugs for Zanata versions <= 3.1.

Comment 18 Sean Flanigan 2013-11-27 03:36:18 UTC
Closing VERIFIED bugs for Zanata versions <= 3.1.