Show
Ignore:
Timestamp:
10/05/07 20:07:02 (1 year ago)
Author:
anarcat
Message:

fix a longstanding issue in AlternC: don't show translation links for
which AlternC is not translated

this is done by checking if the locales/LANG directory exists, so it's
not foolproof, but it's better than simply checking if the locale is
configured (which is still done).

a bit of code refactoring was done while i'm here

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • alternc/trunk/bureau/class/lang_env.php

    r1932 r1997  
    11<?php 
    22 
    3 function update_locale() { 
    4   global $locales
     3function update_locale($langpath) { 
     4  $locales=array()
    55  $f=@fopen("/etc/locale.gen","rb"); 
    66  if ($f) { 
    7     $locales=array(); 
    87    while ($s=fgets($f,1024)) { 
    9       if (preg_match("/^([a-z][a-z]_[A-Z][A-Z])/",trim($s),$mat)) { 
     8      if (preg_match("/^([a-z][a-z]_[A-Z][A-Z])/",trim($s),$mat) && file_exists($langpath . '/' . $mat[1])) { 
    109        $locales[$mat[1]]=$mat[1]; 
    1110      } 
     
    1312    fclose($f); 
    1413  } 
     14  return $locales; 
    1515} 
    16  
    1716 
    1817// setlang is on the link at the login page 
     
    2120} 
    2221 
    23 $locales=array("fr_FR"=>"fr_FR","en_US"=>"en_US"); 
     22$langpath = bindtextdomain("alternc", "/var/alternc/bureau/locales"); 
     23 
    2424// Create or update a locale.php file if it is outdated. 
    25 update_locale(); 
     25$locales = update_locale($langpath); 
    2626 
    2727if (!(isset($lang))) {  // Use the browser first preferred language