Bug 7514 - Choose OPAC language with URL parameter
: Choose OPAC language with URL parameter
Status: RESOLVED FIXED
Product: Koha
Classification: Unclassified
Component: I18N/L10N
: 3.6
: All All
: P5 - low enhancement
Assigned To: Frédéric Demians
: Ian Walls
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-02-09 09:26 UTC by Katrin Fischer
Modified: 2012-10-15 03:53 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---


Attachments
Proposed patch (805 bytes, patch)
2012-02-09 10:05 UTC, Frédéric Demians
Details | Diff | Splinter Review
Bug 7514 Choose OPAC language with URL parameter (1.10 KB, patch)
2012-02-12 19:39 UTC, Katrin Fischer
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 7514 Choose OPAC language with URL parameter (1.11 KB, patch)
2012-02-12 19:39 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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 Frère 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
Created attachment 7523 [details] [review]
Proposed patch
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 Frère 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
Created attachment 7590 [details] [review]
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 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.