]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/commitdiff
captive: Show access page in browser language
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 3 May 2017 13:39:50 +0000 (15:39 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 22 Sep 2017 18:00:04 +0000 (19:00 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Tested-by: Daniel Weismüller <daniel.weismüller@ipfire.org>
config/cfgroot/lang.pl
html/cgi-bin/captive/index.cgi

index c77e0a0665692e0948f265ad2d196ac43d6bdf86..2b09c4a9ff44ab4baf05b3e7439b218c35a28d2b 100644 (file)
@@ -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;
index 4fe6a24cff17c097617c70abe50a40a8b133b709..e9606b1bf84dcfeba195704d8bc0ec2e56bc80dd 100755 (executable)
@@ -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 = ();