[Bug 41989] New: addbook shows the translated interface
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41989 Bug ID: 41989 Summary: addbook shows the translated interface Initiative type: --- Sponsorship --- status: Product: Koha Version: unspecified Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: Staff interface Assignee: jonathan.druart@gmail.com Reporter: jonathan.druart@gmail.com QA Contact: testopia@bugs.koha-community.org CC: gmcharlt@gmail.com I was navigating thought Koha and once I hit addbook the UI switched to French (my browser set Accept-Language en-GB,fr;q=0.9,es;q=0.8,en;q=0.7) I don't have the cookie lang. No idea what happened but I think the "$lang" variable in the controller might conflict with... a global $lang? I don't have time to investigate more at the moment. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41989 Jonathan Druart <jonathan.druart@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41989 --- Comment #1 from Jonathan Druart <jonathan.druart@gmail.com> --- Created attachment 194442 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=194442&action=edit Bug 41989: Rename $lang in addbooks I was navigating thought Koha and once I hit addbook the UI switched to French (my browser set Accept-Language en-GB,fr;q=0.9,es;q=0.8,en;q=0.7) I don't have the cookie lang. No idea what happened but I think the "$lang" variable in the controller might conflict with... a global $lang? It actually switched to French then Italian and German... -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41989 --- Comment #2 from Jonathan Druart <jonathan.druart@gmail.com> --- See screenrecord posted on MatterMost: https://chat.koha-community.org/koha-community/pl/m6ketiy9ypfxbryujdr3eq4qgw -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41989 Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |caroline.cyr-la-rose@inlibr | |o.com --- Comment #3 from Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com> --- Unfortunately, I'm not able to recreate the problem. I tried to follow the video as a test plan, but I don't get the same result. 1. Have more than one language installed, but not activated (on a fresh KTD, I have English enabled and fr-CA installed but not enabled) 2. Go to Cataloging 3. Search for 'a' 4. Search for 'b' 5. Search for 'c' 6. Click on a random record 7. Repeat steps 2-6 8. Repeat steps 2-6 --> In the video, the language starts to change here. But mine stays in English If it helps, I use Firefox on Ubuntu. My OS and my browser are in English. I don't think it changes anything, but I tried on both zebra and es8 (I was trying to get the same search results as the video, but was not able to.) -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41989 --- Comment #4 from Jonathan Druart <jonathan.druart@gmail.com> --- Created attachment 194642 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=194642&action=edit Bug 41989: Call getlanguage after get_template_and_user This patch prevents the UI to randomly change the language when reaching addbooks The problem is that getlanguage is called BEFORE get_template_and_user, without, and "interface" (C4::Context->interface) is not set yet. Open C4/Languages.pm, search "sub getlanguage" We first read the cache, then if there is no interface we reach GetTranslatedLanguages that does return languages in a random order, then we pick the first one 765 @languages = map { $_->{rfc4646_subtag} } @{ getTranslatedLanguages( $interface, $theme ) }; 783 $language = shift @languages unless $language; We must call getlanguage AFTER that the cache is populated. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41989 --- Comment #5 from Jonathan Druart <jonathan.druart@gmail.com> --- (In reply to Caroline Cyr La Rose from comment #3)
Unfortunately, I'm not able to recreate the problem. I tried to follow the video as a test plan, but I don't get the same result.
I do recreate the problem maybe try with more languages installed? As it's a random error, the more you will have, the easiest it will be to get the random behaviour. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41989 --- Comment #6 from Jonathan Druart <jonathan.druart@gmail.com> --- I think I found another bug, easier to test: Have another language than English for "OPACLanguages" (Yes, OPAC!), and have it first. I have : x Deutsch (de-DE) x English (en) Català (ca-ES) Français Français Canada (fr-CA) Français France (fr-FR) ქართული (ka) Eλληνικά (el-GR) Italiano (it-IT) हिन्दी (hi) Español (es-ES) Then reload plack: koha-plack --reload kohadev and open /cgi-bin/koha/cataloguing/addbooks.pl?q=a -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41989 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dcook@prosentient.com.au -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41989 --- Comment #7 from David Cook <dcook@prosentient.com.au> --- Hmm I can't reproduce either. My Accept-Language header is "en-GB,en-US;q=0.9,en;q=0.8" I was thinking... wouldn't $lang need to be set before get_user_and_template so that the correct template gets fetched? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41989 Jonathan Druart <jonathan.druart@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #194442|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41989 --- Comment #8 from Jonathan Druart <jonathan.druart@gmail.com> --- (In reply to David Cook from comment #7)
Hmm I can't reproduce either.
My Accept-Language header is "en-GB,en-US;q=0.9,en;q=0.8"
I was thinking... wouldn't $lang need to be set before get_user_and_template so that the correct template gets fetched?
Did you try the test plan from the previous comment (comment #6)? It's easier to recreate. It has nothing to do with the client's config, everything happens server-side. Also note that I actually forgot to obsolete the first version of the fix! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41989 --- Comment #9 from David Cook <dcook@prosentient.com.au> --- (In reply to Jonathan Druart from comment #8)
(In reply to David Cook from comment #7)
Hmm I can't reproduce either.
My Accept-Language header is "en-GB,en-US;q=0.9,en;q=0.8"
I was thinking... wouldn't $lang need to be set before get_user_and_template so that the correct template gets fetched?
Did you try the test plan from the previous comment (comment #6)?
It's easier to recreate.
Yep, that was the one I tried :/.
It has nothing to do with the client's config, everything happens server-side.
Also note that I actually forgot to obsolete the first version of the fix!
I was wondering about that heh. -- I'll take another look at this... -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41989 --- Comment #10 from David Cook <dcook@prosentient.com.au> --- (In reply to David Cook from comment #9)
(In reply to Jonathan Druart from comment #8)
(In reply to David Cook from comment #7)
Hmm I can't reproduce either.
My Accept-Language header is "en-GB,en-US;q=0.9,en;q=0.8"
I was thinking... wouldn't $lang need to be set before get_user_and_template so that the correct template gets fetched?
Did you try the test plan from the previous comment (comment #6)?
It's easier to recreate.
Yep, that was the one I tried :/.
Oh wait, maybe I thought I was following that one and I didn't... argh. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41989 --- Comment #11 from David Cook <dcook@prosentient.com.au> --- (In reply to David Cook from comment #10)
Oh wait, maybe I thought I was following that one and I didn't... argh.
Hmm yeah no - no luck. But I'm going to just look at the code and see if I can see what you described there anyway. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41989 --- Comment #12 from David Cook <dcook@prosentient.com.au> --- Digging into the code and looking at C4::Languages::getlanguage and this is where my language is getting set to "en" when I visit /cgi-bin/koha/cataloguing/addbooks.pl?q=a without the patch: # HTTP_ACCEPT_LANGUAGE if ( !$language && $ENV{HTTP_ACCEPT_LANGUAGE} ) { $language = accept_language( $ENV{HTTP_ACCEPT_LANGUAGE}, getTranslatedLanguages( $interface, $theme ) ); } So I don't think your bug will ever work for me as it's going to pick up "en" from my Accept-Language header. However... your comment about the interface being set incorrectly gave me an idea which should easily reproduce the bug that you're fixing. On KTD: - install the following: de-DE, fr-CA, fr-FR - For OPACLanguages, checkbox every option but "English" - sudo koha-plack --restart kohadev - Go to /cgi-bin/koha/cataloguing/addbooks.pl?q=a - Note that the interface is in the first selected language from OpacLanguages - If you do another search, it'll revert back to English. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41989 --- Comment #13 from David Cook <dcook@prosentient.com.au> --- Since $C4::Context::context is a global variable, that's empty after the restart but it gets set properly after that first bad page load... riiight. Interesting. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41989 --- Comment #14 from David Cook <dcook@prosentient.com.au> --- I'm tempted to push this straight through to Passed QA since it's a 1 line change and it's quite clear what's going on now. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41989 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41989 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #194642|0 |1 is obsolete| | --- Comment #15 from David Cook <dcook@prosentient.com.au> --- Created attachment 195106 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=195106&action=edit Bug 41989: Call getlanguage after get_template_and_user This patch prevents the UI to randomly change the language when reaching addbooks The problem is that getlanguage is called BEFORE get_template_and_user, without, and "interface" (C4::Context->interface) is not set yet. Open C4/Languages.pm, search "sub getlanguage" We first read the cache, then if there is no interface we reach GetTranslatedLanguages that does return languages in a random order, then we pick the first one 765 @languages = map { $_->{rfc4646_subtag} } @{ getTranslatedLanguages( $interface, $theme ) }; 783 $language = shift @languages unless $language; We must call getlanguage AFTER that the cache is populated. Signed-off-by: David Cook <dcook@prosentient.com.au> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41989 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- QA Contact|testopia@bugs.koha-communit |dcook@prosentient.com.au |y.org | Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41989 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |martin.renvoize@openfifth.c | |o.uk Text to go in the| |Fixes an issue with release notes| |templates that meant | |incorrect translations | |could be shown on the | |addbook page. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41989 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Pushed to main Version(s)| |26.05.00 released in| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41989 --- Comment #16 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Thanks for all the hard work! Pushed to main for the next 26.05.00 release as RM Assistant -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41989 Chloé Zermatten <chloe.zermatten@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)|26.05.00 |26.05.00,25.11.04 released in| | Status|Pushed to main |Pushed to stable -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41989 --- Comment #17 from Chloé Zermatten <chloe.zermatten@openfifth.co.uk> --- All pushed to 25.11.x Thanks all! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41989 Laura Escamilla <Laura.escamilla@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to stable |Pushed to oldstable Version(s)|26.05.00,25.11.04 |26.05.00,25.11.04,25.05.11 released in| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41989 --- Comment #18 from Laura Escamilla <Laura.escamilla@bywatersolutions.com> --- Nice work everyone! Pushed to main for 25.05.09 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41989 --- Comment #19 from Laura Escamilla <Laura.escamilla@bywatersolutions.com> --- Correction: this was pushed for 25.05.11. --LE -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41989 Baptiste Wojtkowski (bwoj) <baptiste.wojtkowski@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)|26.05.00,25.11.04,25.05.11 |26.05.00,25.11.04,25.05.11, released in| |24.11.16 CC| |baptiste.wojtkowski@biblibr | |e.com Status|Pushed to oldstable |Needs documenting --- Comment #20 from Baptiste Wojtkowski (bwoj) <baptiste.wojtkowski@biblibre.com> --- Pushed into 24.11.x for 24.11.16 nice work everyone -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org