Bug 22236 - Translation should generate tags with consistent attribute order
Summary: Translation should generate tags with consistent attribute order
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Templates (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Marcel de Rooy
QA Contact: Josef Moravec
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-30 15:34 UTC by Marcel de Rooy
Modified: 2019-02-25 09:41 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Who signed the patch off:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 22236: Translation should generate tags with consistent attribute order (1.92 KB, patch)
2019-01-30 15:41 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 22236: Translation should generate tags with consistent attribute order (1.94 KB, patch)
2019-02-01 19:50 UTC, Pierre-Marc Thibault
Details | Diff | Splinter Review
Bug 22236: Translation should generate tags with consistent attribute order (2.00 KB, patch)
2019-02-02 08:43 UTC, Josef Moravec
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Marcel de Rooy 2019-01-30 15:34:40 UTC
When running misc/translator/translate, the order of attributes in the translated templates is not consistent and may vary. This is caused by the random order of hash keys in perl.

This causes things like this in run 1:
<input type="submit" class="btn" value="Plaats aanvraag" />
And this in run 2:
<input value="Plaats aanvraag" type="submit" class="btn" />
As you can see, there is actually no difference apart from the order.

When comparing the result of various translation runs, I would rather get rid of such noise and only see the real changes.

The needed change is not trivial to find, but only requires a simple addition to a sort operation in tmpl_process3.pl. The current sort only makes sure that the '/' comes at the end. We should sort the names of the keys too when this value is 0 (just meaning: no end tag symbol).
Comment 1 Marcel de Rooy 2019-01-30 15:41:09 UTC
Created attachment 84532 [details] [review]
Bug 22236: Translation should generate tags with consistent attribute order

When running misc/translator/translate, the order of attributes in the translated templates is not consistent and may vary. This is caused by the random order of hash keys in perl.

This causes things like this in run 1:
<input type="submit" class="btn" value="Plaats aanvraag" />
And this in run 2:
<input value="Plaats aanvraag" type="submit" class="btn" />
As you can see, there is actually no difference apart from the order.

When comparing the result of various translation runs, I would rather get rid of such noise and only see the real changes.

The needed change is not trivial to find, but only requires a simple addition to a sort operation in tmpl_process3.pl. The current sort only makes sure that the '/' comes at the end. We should sort the names of the keys too when this value is 0 (just meaning: no end tag symbol).

Test plan:
[1] Run a translation without this patch and set a few templates aside.
[2] Run a translation with this patch.
[3] Run a compare (diff) on the templates copied in step 1. Verify that the
    only changes are found in the sort order of attributes in html tags.
Comment 2 Pierre-Marc Thibault 2019-02-01 19:50:44 UTC
Created attachment 84652 [details] [review]
Bug 22236: Translation should generate tags with consistent attribute order

When running misc/translator/translate, the order of attributes in the translated templates is not consistent and may vary. This is caused by the random order of hash keys in perl.

This causes things like this in run 1:
<input type="submit" class="btn" value="Plaats aanvraag" />
And this in run 2:
<input value="Plaats aanvraag" type="submit" class="btn" />
As you can see, there is actually no difference apart from the order.

When comparing the result of various translation runs, I would rather get rid of such noise and only see the real changes.

The needed change is not trivial to find, but only requires a simple addition to a sort operation in tmpl_process3.pl. The current sort only makes sure that the '/' comes at the end. We should sort the names of the keys too when this value is 0 (just meaning: no end tag symbol).

Test plan:
[1] Run a translation without this patch and set a few templates aside.
[2] Run a translation with this patch.
[3] Run a compare (diff) on the templates copied in step 1. Verify that the
    only changes are found in the sort order of attributes in html tags.

Signed-off-by: Pierre-Marc Thibault <pierre-marc.thibault@inLibro.com>
Comment 3 Josef Moravec 2019-02-02 08:43:20 UTC
Created attachment 84655 [details] [review]
Bug 22236: Translation should generate tags with consistent attribute order

When running misc/translator/translate, the order of attributes in the translated templates is not consistent and may vary. This is caused by the random order of hash keys in perl.

This causes things like this in run 1:
<input type="submit" class="btn" value="Plaats aanvraag" />
And this in run 2:
<input value="Plaats aanvraag" type="submit" class="btn" />
As you can see, there is actually no difference apart from the order.

When comparing the result of various translation runs, I would rather get rid of such noise and only see the real changes.

The needed change is not trivial to find, but only requires a simple addition to a sort operation in tmpl_process3.pl. The current sort only makes sure that the '/' comes at the end. We should sort the names of the keys too when this value is 0 (just meaning: no end tag symbol).

Test plan:
[1] Run a translation without this patch and set a few templates aside.
[2] Run a translation with this patch.
[3] Run a compare (diff) on the templates copied in step 1. Verify that the
    only changes are found in the sort order of attributes in html tags.

Signed-off-by: Pierre-Marc Thibault <pierre-marc.thibault@inLibro.com>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 4 Marcel de Rooy 2019-02-02 15:17:49 UTC
(In reply to Josef Moravec from comment #3)
> Signed-off-by: Pierre-Marc Thibault <pierre-marc.thibault@inLibro.com>
> 
> Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Thanks Pierre-Marc and Josef !
Comment 5 Nick Clemens 2019-02-04 17:47:33 UTC
Awesome work all!

Pushed to master for 19.05
Comment 6 Martin Renvoize 2019-02-11 13:34:54 UTC
Nice fix, Pushed to 18.11.x for 18.11.03
Comment 7 Lucas Gass 2019-02-12 17:08:14 UTC
backported to 18.05.x for 18.05.09
Comment 8 Fridolin SOMERS 2019-02-25 09:41:24 UTC
I prefer not risk backporting to oldoldstable 17.11.x