Bug 20160 - Sort translated languages by code
Summary: Sort translated languages by code
Status: CLOSED INVALID
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: master
Hardware: All All
: P5 - low minor (vote)
Assignee: paxed
QA Contact: Testopia
URL:
Keywords:
Depends on: 20193
Blocks:
  Show dependency treegraph
 
Reported: 2018-02-08 09:29 UTC by paxed
Modified: 2019-10-14 19:57 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 20160: Sort translated languages by code (2.57 KB, patch)
2018-02-08 09:31 UTC, paxed
Details | Diff | Splinter Review
Bug 20160: Sort translated languages by code (3.10 KB, patch)
2018-02-14 06:17 UTC, paxed
Details | Diff | Splinter Review
Bug 20160: Sort translated languages by code (3.15 KB, patch)
2018-02-14 16:44 UTC, Mark Tompsett
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description paxed 2018-02-08 09:29:57 UTC
The language tabs in Change notices -page are in random order, and will rearrange at every page reload. This is quite irritating.

Make getTranslatedLanguages return the languages always in the same order, sorted by the language code. This is better than returning them in a random one.
Comment 1 paxed 2018-02-08 09:31:01 UTC
Created attachment 71333 [details] [review]
Bug 20160: Sort translated languages by code

The language tabs in Change notices -page are in random order, and will
rearrange at every page reload. This is quite irritating.

Make getTranslatedLanguages return the languages always in the same order,
sorted by the language code. This is better than returning them in
a random one.

Test plan:

1) Enable TranslateNotices
2) Install multiple languages
3) Go to Home -> Tools -> Notices & slips
4) Edit any notice
5) Reload the page multiple times. The language tabs will rearrange at random
6) Apply patch
7) Repeat 1-5. The language tabs should now always be in the same order,
   sorted by the language code.

Do the same test to Home -> Tools -> News -> Add News item
(Check the "Display location" dropdown)

Check Home -> Patrons -> Add patron (the "Preferred language for notices"
dropdown)

Check Home -> Administration -> System preferences -> i18n/l10n
(Note the order of languages listed for "language" and "opaclanguages")

Check Home -> Administration -> System preferences -> Local use
(Create a new preference with variable type Languages, check the
language pref listed in the table)

Check Home -> Administration -> Item types -> Add item type
(After the Description-field, there's "Translate into other languages",
click on that. In the pop-up that opens, check the language drop-down)
Comment 2 Mark Tompsett 2018-02-14 05:11:30 UTC
This sort doesn't quite sort. Install multiple regional English languages, and see if it is the order you would expect.
Comment 3 paxed 2018-02-14 05:56:46 UTC
(In reply to M. Tompsett from comment #2)
> This sort doesn't quite sort. Install multiple regional English languages,
> and see if it is the order you would expect.

Good point, didn't think to test that.
Comment 4 paxed 2018-02-14 06:17:43 UTC
Created attachment 71596 [details] [review]
Bug 20160: Sort translated languages by code

The language tabs in Change notices -page are in random order, and will
rearrange at every page reload. This is quite irritating.

Make getTranslatedLanguages return the languages always in the same order,
sorted by the language code. This is better than returning them in
a random one.

Test plan:

1) Enable TranslateNotices
2) Install multiple languages, including multiple regional English languages
3) Go to Home -> Tools -> Notices & slips
4) Edit any notice
5) Reload the page multiple times. The language tabs will rearrange at random
6) Apply patch
7) Repeat 1-5. The language tabs should now always be in the same order,
   sorted by the language code.

Do the same test to Home -> Tools -> News -> Add News item
(Check the "Display location" dropdown)

Check Home -> Patrons -> Add patron (the "Preferred language for notices"
dropdown)

Check Home -> Administration -> System preferences -> i18n/l10n
(Note the order of languages listed for "language" and "opaclanguages")

Check Home -> Administration -> System preferences -> Local use
(Create a new preference with variable type Languages, check the
language pref listed in the table)

Check Home -> Administration -> Item types -> Add item type
(After the Description-field, there's "Translate into other languages",
click on that. In the pop-up that opens, check the language drop-down)
Comment 5 Mark Tompsett 2018-02-14 16:44:23 UTC
Created attachment 71622 [details] [review]
Bug 20160: Sort translated languages by code

The language tabs in Change notices -page are in random order, and will
rearrange at every page reload. This is quite irritating.

Make getTranslatedLanguages return the languages always in the same order,
sorted by the language code. This is better than returning them in
a random one.

Test plan:

1) Enable TranslateNotices
2) Install multiple languages, including multiple regional English languages
3) Go to Home -> Tools -> Notices & slips
4) Edit any notice
5) Reload the page multiple times. The language tabs will rearrange at random
6) Apply patch
7) Repeat 1-5. The language tabs should now always be in the same order,
   sorted by the language code.

Do the same test to Home -> Tools -> News -> Add News item
(Check the "Display location" dropdown)

Check Home -> Patrons -> Add patron (the "Preferred language for notices"
dropdown)

Check Home -> Administration -> System preferences -> i18n/l10n
(Note the order of languages listed for "language" and "opaclanguages")

Check Home -> Administration -> System preferences -> Local use
(Create a new preference with variable type Languages, check the
language pref listed in the table)

Check Home -> Administration -> Item types -> Add item type
(After the Description-field, there's "Translate into other languages",
click on that. In the pop-up that opens, check the language drop-down)

Signed-off-by: Pasi Kallinen <pasi.kallinen@joensuu.fi>

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Comment 6 Julian Maurice 2018-02-16 11:32:36 UTC
Patch works but there is no test. Please write some.
Comment 7 paxed 2018-02-27 12:05:08 UTC
(In reply to Julian Maurice from comment #6)
> Patch works but there is no test. Please write some.

I have no idea how I would go writing test for this, because getTranslatedLanguages wants the translated theme directories present.

Someone else will have to take this.
Comment 8 Julian Maurice 2018-02-27 12:40:30 UTC
I think you can mock _get_language_dirs with Test::MockModule to make it return whatever is needed for the tests. Have a look at t/lib/Mocks.pm for examples of usage.
Comment 9 Jonathan Druart 2018-02-28 13:56:21 UTC
Hum, did you see bug 20115?
Comment 10 paxed 2018-08-23 10:15:47 UTC
Was fixed by bug 20115