Changeset 1665

Show
Ignore:
Timestamp:
08/05/2007 01:25:08 PM (17 months ago)
Author:
driehle
Message:

implemented multiple language installation

Location:
trunk
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • trunk/lang/lang-admin.de.inc.php

    r1664 r1665  
    147147"m_clean_url"              => "Saubere URLs (mod_rewrite) verwenden? Beispiel: http://example.com/2005/01/firefox", 
    148148"m_metadata"               => "Metadaten", 
     149"m_language"               => "Sprache des Weblogs", 
    149150"m_website"                => "Der Name des Weblogs", 
    150151"m_publisher"              => "Name des Verfassers der EintrÀge", 
  • trunk/lang/lang-admin.en.inc.php

    r1664 r1665  
    147147"m_clean_url"               => "Shall clean URLs (mod_rewrite) be used? Example: http://example.com/2005/01/firefox", 
    148148"m_metadata"                => "Metadata", 
     149"m_language"                => "Language of your weblog", 
    149150"m_website"                 => "Weblog name", 
    150151"m_publisher"               => "Name of the author of the entries", 
  • trunk/lang/lang-admin.it.inc.php

    r1664 r1665  
    147147"m_clean_url"               => "Pulire URLs (mod_rewrite) usati? Esempio: http://example.com/2005/01/firefox", 
    148148"m_metadata"                => "Metadata", 
     149"m_language"                => "Lingua del vostro weblog", 
    149150"m_website"                 => "Nome Weblog", 
    150151"m_publisher"               => "Nome dell'autore della nota", 
  • trunk/scripts/prepend.inc.php

    r1663 r1665  
    1111 
    1212// need this in every page 
    13  require_once(JLOG_BASEPATH.'lang'.DIRECTORY_SEPARATOR.'lang.inc.php'); 
     13 require_once(JLOG_BASEPATH.'lang'.DIRECTORY_SEPARATOR.'lang.'.JLOG_LANGUAGE.'.inc.php'); 
    1414 require_once(JLOG_BASEPATH.'scripts'.DIRECTORY_SEPARATOR.'database.class.php'); 
    1515 require_once(JLOG_BASEPATH.'scripts'.DIRECTORY_SEPARATOR.'bbcode.php'); 
     
    1818 
    1919// need this only on admincenter 
    20  if(defined('JLOG_ADMIN')) require_once(JLOG_BASEPATH.'lang'.DIRECTORY_SEPARATOR.'lang-admin.inc.php'); 
     20 if(defined('JLOG_ADMIN')) require_once(JLOG_BASEPATH.'lang'.DIRECTORY_SEPARATOR.'lang-admin.'.JLOG_LANGUAGE.'.inc.php'); 
    2121 
    2222 // connect database 
  • trunk/scripts/settings.class.php

    r1629 r1665  
    2828                        'JLOG_UPDATE', 
    2929                        'JLOG_VERSION', 
    30                         'JLOG_LOGIN' 
     30                        'JLOG_LOGIN', 
     31                        'JLOG_LANGUAGE' 
    3132                     ); 
    3233     
     
    8788     $this->d['jlog_db_prefix'] = "jlog_"; 
    8889     $this->d['jlog_blogservices'] = "http://rpc.pingomatic.com/"; 
     90     $this->d['jlog_language'] = JLOG_LANGUAGE; 
    8991    } 
    9092     
     
    102104    function form_output() { 
    103105    # returns the filled form 
    104  
     106      
    105107     $data = array_htmlspecialchars($this->d); 
    106  
    107108 
    108109     if(isset($data['jlog_clean_url']) AND ($data['jlog_clean_url'] === 'true' OR $data['jlog_clean_url'] === '1'))  
     
    118119     if(defined("JLOG_ADMIN") AND JLOG_ADMIN === true) $admincenter_password = " ".$this->l['admin']['m_admin_password_admin']; 
    119120     else $admincenter_password = ''; 
    120  
    121     // do the form 
     121   
     122     // get available languages 
     123     $dir = opendir(dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'lang'); 
     124     $languages = array(); 
     125     while(($file = readdir($dir)) !== false) { 
     126      if($file == '.' OR $file == '..') continue; 
     127      if(!preg_match('/lang\.([a-zA-z0-9]+)\.inc\.php/', $file, $matches)) continue; 
     128      $languages[] = $matches[1]; 
     129     } 
     130      
     131    // do the form  
    122132     $form = " 
    123133     <form action='".$_SERVER['PHP_SELF']."' method='post'> 
    124134      <fieldset><legend>".$this->l['admin']['m_metadata']."</legend> 
     135       <p><label for='website'>".$this->l['admin']['m_language']."</label><br /> 
     136          <select class='userdata' id='language' name='jlog_language'>"; 
     137     foreach($languages as $lang) { 
     138      $form .= "<option"; 
     139      if($lang == JLOG_LANGUAGE) $form .= " selected='selected'"; 
     140      $form .= ">$lang</option>"; 
     141     } 
     142           
     143     $form .= "</select> 
     144       </p> 
     145        
    125146       <p><label for='website'>".$this->l['admin']['m_website']."</label><br /> 
    126147          <input class='userdata' id='website' name='jlog_website' type='text' size='20' maxlength='255' value='".$this->get_value($data, 'jlog_website')."' /></p> 
  • trunk/setup.php

    r1663 r1665  
    1616 define("JLOG_WEBSITE", $_SERVER["HTTP_HOST"]); 
    1717 define("JLOG_PATH", dirname("http://".$_SERVER["HTTP_HOST"].$_SERVER["PHP_SELF"])); 
    18  
    19  require('.'.DIRECTORY_SEPARATOR.'lang'.DIRECTORY_SEPARATOR.'lang.inc.php'); 
    20  require('.'.DIRECTORY_SEPARATOR.'lang'.DIRECTORY_SEPARATOR.'lang-admin.inc.php'); 
     18   
     19 $dir = opendir('.'.DIRECTORY_SEPARATOR.'lang'); 
     20 $languages = array(); 
     21 while(($file = readdir($dir)) !== false) { 
     22  if($file == '.' OR $file == '..') continue; 
     23  if(!preg_match('/lang\.([a-zA-z0-9]+)\.inc\.php/', $file, $matches)) continue; 
     24  $languages[] = $matches[1]; 
     25 } 
     26 $lang = getlang($languages, 'de'); 
     27 define('JLOG_LANGUAGE', $lang); 
     28  
     29 require('.'.DIRECTORY_SEPARATOR.'lang'.DIRECTORY_SEPARATOR.'lang.'.$lang.'.inc.php'); 
     30 require('.'.DIRECTORY_SEPARATOR.'lang'.DIRECTORY_SEPARATOR.'lang-admin.'.$lang.'.inc.php'); 
    2131 require('.'.DIRECTORY_SEPARATOR.'scripts'.DIRECTORY_SEPARATOR.'database.class.php'); 
    2232 require('.'.DIRECTORY_SEPARATOR.'scripts'.DIRECTORY_SEPARATOR.'general.func.php');  
     
    245255</html>'; 
    246256 } 
     257  
     258  function getlang ($allowed, $default) { 
     259    $string = $_SERVER['HTTP_ACCEPT_LANGUAGE']; 
     260    if (empty($string)) { 
     261      return $default; 
     262    } 
     263     
     264    $accepted_languages = preg_split('/,\s*/', $string); 
     265     
     266    $cur_l = $default; 
     267    $cur_q = 0; 
     268     
     269    foreach ($accepted_languages as $accepted_language) { 
     270      $res = preg_match ('/^([a-z]{1,8}(?:-[a-z]{1,8})*)'. 
     271                        '(?:;\s*q=(0(?:\.[0-9]{1,3})?|1(?:\.0{1,3})?))?$/i', $accepted_language, $matches); 
     272       
     273      if (!$res) { 
     274        continue; 
     275      } 
     276       
     277      $lang_code = explode ('-', $matches[1]); 
     278       
     279      if (isset($matches[2])) { 
     280        $lang_quality = (float)$matches[2]; 
     281      } else { 
     282        $lang_quality = 1.0; 
     283      } 
     284       
     285      while (count ($lang_code)) { 
     286        if (in_array (strtolower (join ('-', $lang_code)), $allowed)) { 
     287          if ($lang_quality > $cur_q) { 
     288            $cur_l = strtolower (join ('-', $lang_code)); 
     289            $cur_q = $lang_quality; 
     290            break; 
     291          } 
     292        } 
     293        array_pop ($lang_code); 
     294      } 
     295    } 
     296     
     297    return $cur_l; 
     298  } 
    247299 
    248300?>