Skip to content

Commit

Permalink
Bug 16776: Do not forget external language choice in language switcher
Browse files Browse the repository at this point in the history
If language is set by external link language switcher does not work

To reproduce:

- Have a multilingual koha installation, let's say en, de-CH, fr-FR and it-IT
- Create external links e.g. from your multilingual library website to each language variant of OPAC:

...cgi-bin/koha/opac-main.pl?language=en
...cgi-bin/koha/opac-main.pl?language=de-CH
...cgi-bin/koha/opac-main.pl?language=fr-FR
...cgi-bin/koha/opac-main.pl?language=it-IT

Each link opens fine displaying the language as appropriate.

Now try to switch language on the page you just opened via the external link.

It won't work, it will always stay on the language defined by the external link.

To test:
- Apply patch
- Repeat steps above
- Verify that the language switcher works
- Verify in browser address field that after switching language, the param 'language= 'has vanished from url string
- Try links with multiple params and with params containing 'language', e.g.
  ...cgi-bin/koha/opac-search.pl?language=fr-FR&q=language&mylanguage=test
- Verify that only the parameter 'language=' vanishes

Tested counter patch, works as well.
Signed-off-by: Marc <[email protected]>

Signed-off-by: Katrin Fischer <[email protected]>

Signed-off-by: Kyle M Hall <[email protected]>
  • Loading branch information
joubu authored and kylemhall committed Aug 10, 2016
1 parent 5dd9a25 commit 62d16aa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion changelanguage.pl
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@
my $language = $query->param('language');
my $url = $query->referer();

#warn "Language : $query // $language // $url";
$url =~ s|(.)language=[\w-]*&?|$1|;
$url =~ s|(&\|\?)$||; # Remove extraneous ? or &

C4::Templates::setlanguagecookie( $query, $language, $url );
7 changes: 7 additions & 0 deletions opac/opac-changelanguage.pl
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,11 @@
my $url = $query->referer() || '/';

# warn "Language : $query // $language // $url";

# If language was set by an external URL the parameter
# 'language=' should be removed from url string, otherwise
# the language picker will not work
$url =~ s|(.)language=[\w-]*&?|$1|;
$url =~ s|(&\|\?)$||; # Remove extraneous ? or &

C4::Templates::setlanguagecookie( $query, $language, $url );

0 comments on commit 62d16aa

Please sign in to comment.