]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/commitdiff
webif: Find correct language file when locale is in format xx_XX.utf8
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 30 Aug 2014 19:10:32 +0000 (21:10 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 30 Aug 2014 19:10:32 +0000 (21:10 +0200)
config/cfgroot/header.pl
config/cfgroot/lang.pl

index acccfc834756baad04abc0c1b430a28b73d2047a..cf895bf246a01946ab4930b62bc329719d36bc0e 100644 (file)
@@ -59,12 +59,12 @@ if ($ENV{'SERVER_ADDR'} && $ENV{'HTTPS'} ne 'on') {
 &General::readhash("${swroot}/main/settings", \%settings);
 &General::readhash("${swroot}/ethernet/settings", \%ethsettings);
 &General::readhash("${swroot}/ppp/settings", \%pppsettings);
-$language = $settings{'LANGUAGE'};
 $hostname = $settings{'HOSTNAME'};
 $hostnameintitle = 0;
 
 ### Initialize language
-if ($language =~ /^(\w+)$/) {$language = $1;}
+require "${swroot}/lang.pl";
+$language = &Lang::FindWebLanguage($settings{"LANGUAGE"});
 
 ### Read English Files
 if ( -d "/var/ipfire/langs/en/" ) {
index 707b28d11e2b3c237c5c9cad072b20a705b50f34..3b001ad9d433ad2fe354e29369f017294dcd5137 100644 (file)
@@ -50,8 +50,8 @@ $language = $settings{'LANGUAGE'};
 # (it is a developper options)
 #
 sub reload {
+    my $LG = &FindWebLanguage(shift);
 
-    my ($LG) = @_;
     %Lang::tr = ();    # start with a clean array
 
     # Use CacheLang if present & not empty.
@@ -157,4 +157,23 @@ sub BuildCacheLang {
     &General::log ("WARNING: cannot build cachelang file for [$missed].") if ($error);
     return $error;
 }
+
+sub FindWebLanguage() {
+       my $lang = shift;
+
+       my @options = ($lang);
+
+       my ($shortlang, $encoding) = split(/\./, $lang);
+       push(@options, $shortlang);
+
+       my ($language, $country) = split(/_/, $shortlang);
+       push(@options, $language);
+
+       foreach my $option (@options) {
+               return $option if (-e "${General::swroot}/langs/$option.pl");
+       }
+
+       return undef;
+}
+
 1;