From: Michael Tremer Date: Wed, 3 May 2017 13:39:50 +0000 (+0200) Subject: captive: Show access page in browser language X-Git-Tag: v2.19-core115~60^2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5f1b9511022bca252c27b9e60284bf4f4486af46;p=people%2Fpmueller%2Fipfire-2.x.git captive: Show access page in browser language Signed-off-by: Michael Tremer Tested-by: Daniel Weismüller --- diff --git a/config/cfgroot/lang.pl b/config/cfgroot/lang.pl index c77e0a0665..2b09c4a9ff 100644 --- a/config/cfgroot/lang.pl +++ b/config/cfgroot/lang.pl @@ -179,4 +179,18 @@ sub FindWebLanguage() { return undef; } +sub DetectBrowserLanguages() { + my $langs = $ENV{"HTTP_ACCEPT_LANGUAGE"}; + my @results = (); + + foreach my $lang (split /[,;]/, $langs) { + # Drop all q= arguments + next if ($lang =~ m/^q=/); + + push(@results, $lang); + } + + return @results; +} + 1; diff --git a/html/cgi-bin/captive/index.cgi b/html/cgi-bin/captive/index.cgi index 4fe6a24cff..e9606b1bf8 100755 --- a/html/cgi-bin/captive/index.cgi +++ b/html/cgi-bin/captive/index.cgi @@ -32,6 +32,10 @@ use HTML::Template; require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; +# Load the most appropriate language from the browser configuration +my @langs = &Lang::DetectBrowserLanguages(); +&Lang::reload(@langs); + my $coupons = "${General::swroot}/captive/coupons"; my %couponhash = ();