Changeset 9265
- Timestamp:
- Feb 17, 2011, 5:50:37 PM (14 years ago)
- Location:
- extensions/PHP_Optimisateur
- Files:
-
- 20 added
- 11 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/PHP_Optimisateur/include/functions.php
r9201 r9265 22 22 while ($file = readdir($dh)) { 23 23 if ($file !== '.' && $file !== '..' && is_dir('language/'.$file)) { 24 $languages[] = $file; 24 $name = (file_exists('language/'.$file.'/'.$file.'.txt')) ? file_get_contents('language/'.$file.'/'.$file.'.txt') : $file; 25 $languages[$file] = $name; 25 26 } 26 27 } … … 29 30 // recherche du paramètre get ou session, ou langue du navigateur 30 31 if (isset($_GET['Lang'])) { 31 $_SESSION['Lang'] = $_GET['Lang']; 32 } else if (!isset($_SESSION['Lang']) OR $_SESSION['Lang'] == NULL) { 33 $_SESSION['Lang'] = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'],0,2); 34 } 35 if (!in_array($_SESSION['Lang'], $languages)) { 36 $_SESSION['Lang'] = 'en'; 37 } 38 32 $user_lang = $_GET['Lang']; 33 } else if (isset($_SESSION['Lang']) AND $_SESSION['Lang'] != NULL) { 34 $user_lang = $_SESSION['Lang']; 35 } else { 36 $user_lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'],0,2); 37 } 38 39 // si langue navigateur cherche une correspondance dans la tableau 40 if (strlen($user_lang) == 2) { 41 foreach (array_keys($languages) as $lang) { 42 if ($user_lang == substr($lang,0,2)) { 43 $user_lang = $lang; 44 break; 45 } 46 } 47 } 48 49 // si pas de correspondance OU get faux, langue par défaut 50 if (!in_array($user_lang, array_keys($languages))) { 51 $user_lang = 'en_UK'; 52 } 53 54 $_SESSION['Lang'] = $user_lang; 39 55 return array('user_lang' => $_SESSION['Lang'], 'languages' => $languages); 40 56 } … … 244 260 include('plugins/'.$plugin_id.'/lang/'.$CONF['user_lang'].'.php'); 245 261 } else { 246 include('plugins/'.$plugin_id.'/lang/en .php');262 include('plugins/'.$plugin_id.'/lang/en_UK.php'); 247 263 } 248 264 } -
extensions/PHP_Optimisateur/include/header.php
r9201 r9265 34 34 35 35 <span class="lang">'; 36 foreach ($CONF['languages'] as $key ) {37 echo '<a class="lang" href="index.php?Lang='.$key.'" title="'.$ key.'"><img src="language/'.$key.'/'.$key.'.png" alt="'.$key.'"/></a>';36 foreach ($CONF['languages'] as $key => $name) { 37 echo '<a class="lang" href="index.php?Lang='.$key.'" title="'.$name.'"><img src="language/'.$key.'/'.$key.'.png" alt="'.$name.'"/></a>'; 38 38 } 39 39 echo '</span>
Note: See TracChangeset
for help on using the changeset viewer.