Index: trunk/admin/include/languages.class.php
===================================================================
--- trunk/admin/include/languages.class.php	(revision 9514)
+++ trunk/admin/include/languages.class.php	(revision 9518)
@@ -81,6 +81,8 @@
         $query = '
 INSERT INTO '.LANGUAGES_TABLE.'
-  (id, name)
-  VALUES(\''.$language_id.'\', \''.$this->fs_languages[$language_id].'\')
+  (id, version, name)
+  VALUES(\''.$language_id.'\',
+         \''.$this->fs_languages[$language_id]['version'].'\',
+         \''.$this->fs_languages[$language_id]['name'].'\')
 ;';
         pwg_query($query);
@@ -158,19 +160,58 @@
 
     $dir = opendir(PHPWG_ROOT_PATH.'language');
-
     while ($file = readdir($dir))
     {
-      $path = PHPWG_ROOT_PATH.'language/'.$file;
-      if (!is_link($path) and is_dir($path) and file_exists($path.'/iso.txt'))
-      {
-        list($language_name) = @file($path.'/iso.txt');
-
-        $languages[$file] = convert_charset($language_name, 'utf-8', $target_charset);
+      if ($file!='.' and $file!='..')
+      {
+        $path = PHPWG_ROOT_PATH.'language/'.$file;
+        if (is_dir($path) and !is_link($path)
+            and preg_match('/^[a-zA-Z0-9-_]+$/', $file )
+            and file_exists($path.'/common.lang.php')
+            )
+        {
+          $language = array(
+              'code'=>$file,
+              'version'=>'0',
+              'uri'=>'',
+              'author'=>'',
+            );
+          $plg_data = implode( '', file($path.'/common.lang.php') );
+
+          if ( preg_match("|Language Name: (.*)|", $plg_data, $val) )
+          {
+            $language['name'] = trim( $val[1] );
+            $language['name'] = convert_charset($language['name'], 'utf-8', $target_charset);
+          }
+          if (preg_match("|Version: (.*)|", $plg_data, $val))
+          {
+            $language['version'] = trim($val[1]);
+          }
+          if ( preg_match("|Language URI: (.*)|", $plg_data, $val) )
+          {
+            $language['uri'] = trim($val[1]);
+          }
+          if ( preg_match("|Author: (.*)|", $plg_data, $val) )
+          {
+            $language['author'] = trim($val[1]);
+          }
+          if ( preg_match("|Author URI: (.*)|", $plg_data, $val) )
+          {
+            $language['author uri'] = trim($val[1]);
+          }
+          if (!empty($language['uri']) and strpos($language['uri'] , 'extension_view.php?eid='))
+          {
+            list( , $extension) = explode('extension_view.php?eid=', $language['uri']);
+            if (is_numeric($extension)) $language['extension'] = $extension;
+          }
+          // IMPORTANT SECURITY !
+          $language = array_map('htmlspecialchars', $language);
+          $this->fs_languages[$file] = $language;
+        }
       }
     }
     closedir($dir);
-    @asort($languages);
-
-    return $languages;
+    @uasort($this->fs_languages, 'name_compare');
+
+    return $this->fs_languages;
   }
 
@@ -193,5 +234,5 @@
    * Retrieve PEM server datas to $server_languages
    */
-  function get_server_languages()
+  function get_server_languages($new=false)
   {
     global $user;
@@ -224,4 +265,14 @@
     {
       return false;
+    }
+
+    // Languages to check
+    $languages_to_check = array();
+    foreach($this->fs_languages as $fs_language)
+    {
+      if (isset($fs_language['extension']))
+      {
+        $languages_to_check[] = $fs_language['extension'];
+      }
     }
 
@@ -234,4 +285,15 @@
       )
     );
+    if (!empty($languages_to_check))
+    {
+      if ($new)
+      {
+        $get_data['extension_exclude'] = implode(',', $languages_to_check);
+      }
+      else
+      {
+        $get_data['extension_include'] = implode(',', $languages_to_check);
+      }
+    }
 
     if (fetchRemote($url, $result, $get_data))
@@ -244,10 +306,10 @@
       foreach ($pem_languages as $language)
       {
-        if (preg_match('/^.*? \[[A-Z]{2}\]$/', $language['extension_name'])
-          and !in_array($language['extension_name'], $this->fs_languages))
-        {
-          $this->server_languages[] = $language;
-        }
-      }
+        if (preg_match('/^.*? \[[A-Z]{2}\]$/', $language['extension_name']))
+        {
+          $this->server_languages[$language['extension_name']] = $language;
+        }
+      }
+      @ksort($this->server_languages);
       return true;
     }
@@ -281,6 +343,6 @@
           foreach ($list as $file)
           {
-            // we search iso.txt in archive
-            if (basename($file['filename']) == 'iso.txt'
+            // we search common.lang.php in archive
+            if (basename($file['filename']) == 'common.lang.php'
               and (!isset($main_filepath)
               or strlen($file['filename']) < strlen($main_filepath)))
@@ -291,5 +353,5 @@
           if (isset($main_filepath))
           {
-            $root = basename(dirname($main_filepath)); // iso.txt path in archive
+            $root = basename(dirname($main_filepath)); // common.lang.php path in archive
             if (preg_match('/^[a-z]{2}_[A-Z]{2}$/', $root))
             {
Index: trunk/admin/languages_installed.php
===================================================================
--- trunk/admin/languages_installed.php	(revision 9514)
+++ trunk/admin/languages_installed.php	(revision 9518)
@@ -55,11 +55,7 @@
 $tpl_languages = array();
 
-foreach($languages->fs_languages as $language_id => $language_name)
+foreach($languages->fs_languages as $language_id => $language)
 {
-  $language = array(
-    'id' => $language_id,
-    'name' => $language_name,
-    'u_action' => $base_url.'&amp;language='.$language_id,
-    );
+  $language['u_action'] = add_url_params($base_url, array('language' => $language_id));
 
   if (in_array($language_id, array_keys($languages->db_languages)))
Index: trunk/admin/languages_new.php
===================================================================
--- trunk/admin/languages_new.php	(revision 9514)
+++ trunk/admin/languages_new.php	(revision 9518)
@@ -108,5 +108,5 @@
 // |                     start template output                             |
 // +-----------------------------------------------------------------------+
-if ($languages->get_server_languages())
+if ($languages->get_server_languages(true))
 {
   foreach($languages->server_languages as $language)
Index: trunk/install.php
===================================================================
--- trunk/install.php	(revision 9514)
+++ trunk/install.php	(revision 9518)
@@ -193,5 +193,5 @@
   $language = 'en_UK';
   // Try to get browser language
-  foreach ($languages->fs_languages as $language_code => $language_name)
+  foreach ($languages->fs_languages as $language_code => $fs_language)
   {
     if (substr($language_code,0,2) == @substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2))
@@ -341,5 +341,5 @@
 
     // fill languages table
-    foreach ($languages->get_fs_languages() as $language_code => $language_name)
+    foreach ($languages->get_fs_languages() as $language_code => $fs_language)
     {
       $languages->perform_action('activate', $language_code);
@@ -418,5 +418,5 @@
 $dbengines = available_engines();
 
-foreach ($languages->fs_languages as $language_code => $language_name)
+foreach ($languages->fs_languages as $language_code => $fs_language)
 {
   if ($language == $language_code)
@@ -424,5 +424,5 @@
     $template->assign('language_selection', $language_code);
   }
-  $languages_options[$language_code] = $language_name;
+  $languages_options[$language_code] = $fs_language['name'];
 }
 $template->assign('language_options', $languages_options);
Index: trunk/install/db/90-database.php
===================================================================
--- trunk/install/db/90-database.php	(revision 9514)
+++ trunk/install/db/90-database.php	(revision 9518)
@@ -50,5 +50,5 @@
 $languages = new languages(PWG_CHARSET);
 
-foreach ($languages->fs_languages as $language_code => $language_name)
+foreach ($languages->fs_languages as $language_code => $fs_language)
 {
   $languages->perform_action('activate', $language_code);
Index: trunk/install/php5_apache_configuration.php
===================================================================
--- trunk/install/php5_apache_configuration.php	(revision 9514)
+++ trunk/install/php5_apache_configuration.php	(revision 9518)
@@ -175,8 +175,8 @@
     <td>
       <select name="language" onchange="document.location = \''.$script.'.php?language=\'+this.options[this.selectedIndex].value;">';
-  foreach ($languages->fs_languages as $code => $name)
+  foreach ($languages->fs_languages as $code => $fs_language)
   {
     echo '
-      <option label="'.$name.'" value="'.$code.'" '.($code == $language ? 'selected="selected"' : '') .'>'.$name.'</option>';
+      <option label="'.$fs_language['name'].'" value="'.$code.'" '.($code == $language ? 'selected="selected"' : '') .'>'.$fs_language['name'].'</option>';
   }
   echo '
Index: trunk/upgrade.php
===================================================================
--- trunk/upgrade.php	(revision 9514)
+++ trunk/upgrade.php	(revision 9518)
@@ -160,5 +160,5 @@
   $language = 'en_UK';
   // Try to get browser language
-  foreach ($languages->fs_languages as $language_code => $language_name)
+  foreach ($languages->fs_languages as $language_code => $fs_language)
   {
     if (substr($language_code,0,2) == @substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2))
@@ -401,5 +401,5 @@
   $languages = new languages();
   
-  foreach ($languages->fs_languages as $language_code => $language_name)
+  foreach ($languages->fs_languages as $language_code => $fs_language)
   {
     if ($language == $language_code)
@@ -407,5 +407,5 @@
       $template->assign('language_selection', $language_code);
     }
-    $languages_options[$language_code] = $language_name;
+    $languages_options[$language_code] = $fs_language['name'];
   }
   $template->assign('language_options', $languages_options);
