my ($language, $country) = split(/_/, $shortlang);
push(@options, $language);
+ # Add English as fallback
+ push(@options, "en");
+
foreach my $option (@options) {
return $option if (-e "${General::swroot}/langs/$option.pl");
}
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;