Bug 7514

Summary: Choose OPAC language with URL parameter
Product: Koha Reporter: Katrin Fischer <katrin.fischer>
Component: I18N/L10NAssignee: Frédéric Demians <f.demians>
Status: CLOSED FIXED QA Contact: Ian Walls <koha.sekjal>
Severity: enhancement    
Priority: P5 - low CC: jonathan.druart, paul.poulain, semarie
Version: 3.6   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: Proposed patch
Bug 7514 Choose OPAC language with URL parameter
[SIGNED-OFF] Bug 7514 Choose OPAC language with URL parameter

Description Katrin Fischer 2012-02-09 09:26:36 UTC
At the moment we are using browser detection and cookies to detect the right language to show to the user. 

It would be good if you could craft an URL to circumvent browser detection and open the OPAC in the specified language directly.
Comment 1 Sébastien Marie 2012-02-09 09:44:37 UTC
Currently, it exists 'changelanguage.pl' which use 'language' parameter for set the language cookie, and redirect to REFERER.

See: http://opac/cgi-bin/koha/changelanguage.pl?language=fr-FR
Or: koha-git-tree/opac/changelanguage.pl

So perhaps just need to use a 'url' parameter for redirect, and if no parameter, fallback to referer... (or if no referer, go to http://opac/)
Comment 2 Frédéric Demians 2012-02-09 10:05:02 UTC
(In reply to comment #1)
> Currently, it exists 'changelanguage.pl' which use 'language' parameter for set
> the language cookie, and redirect to REFERER.

Exactly what I was saying on IRC... patch coming.
Comment 3 Frédéric Demians 2012-02-09 10:05:24 UTC Comment hidden (obsolete)
Comment 4 Katrin Fischer 2012-02-09 10:20:23 UTC
Wow - that was fast. Thank you Frédéric and Frère Sébastien Marie! 

Only so I get it right for testing later: Will this change only affect http://opac/cgi-bin/koha/changelanguage.pl?language=fr-FR or should the parameter work for any page after applying the patch?
Comment 5 Sébastien Marie 2012-02-09 10:28:46 UTC
(In reply to comment #4)
> Only so I get it right for testing later: Will this change only affect
> http://opac/cgi-bin/koha/changelanguage.pl?language=fr-FR or should the
> parameter work for any page after applying the patch?

The patch of Frederic permit to use the "changelanguage.pl" script directly (without need of referer [setted when called from a link to "changelanguage.pl" for example])

So after called "http://opac/cgi-bin/koha/changelanguage.pl?language=fr-FR" in your browser, the cookie is setted for the rest of the session to fr-FR language.

As cookie check is done before browser language detection, the use of this url permit to circumvent the browser default language.
Comment 6 Frédéric Demians 2012-02-09 10:52:47 UTC
Yes. It means that when linking to the OPAC from the outside, the
library CMS for example, if you want to bypass language selection via
browser language ordered choices, you don't link to:

  http://myopac

but:

  http://myopac/cgi-bin/koha/changelanguage.pl?language=fr-FR

After that, you don't have/can't append 'language' parameter to any OPAC
page.
Comment 7 Katrin Fischer 2012-02-09 11:01:23 UTC
Thanks for the explanations - I will test asap.
Comment 8 Katrin Fischer 2012-02-12 19:39:01 UTC Comment hidden (obsolete)
Comment 9 Katrin Fischer 2012-02-12 19:39:44 UTC
Created attachment 7591 [details] [review]
[SIGNED-OFF] Bug 7514 Choose OPAC language with URL parameter

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>

Tested:
- with and without cookie set
- different language codes

http://.../cgi-bin/koha/opac-changelanguage.pl?language=de-DE
will directly open the German OPAC.

http://.../cgi-bin/koha/opac-changelanguage.pl?language=en
will directly open the English OPAC.
Comment 10 Jonathan Druart 2012-02-15 15:49:38 UTC
Marked as Passed QA. Nothing to say, simple patch.
Initialize $url variable to '/' if it is not set.
Comment 11 Jared Camins-Esakov 2012-05-23 13:03:13 UTC
This fix was included in the 3.6.x branch prior to 3.6.4.