]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - config/cfgroot/lang.pl
Merge branch 'next' of ssh://git.ipfire.org/pub/git/ipfire-2.x into asterisk-update
[ipfire-2.x.git] / config / cfgroot / lang.pl
index a650706590e958dfb58738e8ddc60aaad1700e51..3b001ad9d433ad2fe354e29369f017294dcd5137 100644 (file)
@@ -13,7 +13,7 @@ require 'CONFIG_ROOT/general-functions.pl';
 use strict;
 
 ### A cache file to avoid long recalculation
-$Lang::CacheLang = '/var/run/cache-lang.pl';
+$Lang::CacheLang = '/var/ipfire/langs/cache-lang.pl';
 
 # When you want to add your own language strings/entries to the ipcop language file,
 # you should create a file with <PREFIX>.<LANG>.pl into CONFIG_ROOT/addon-lang dir
@@ -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;