Changeset 5357


Ignore:
Timestamp:
03/25/10 21:18:28 (10 years ago)
Author:
patdenice
Message:

Feature 1535: Add language manager.

Location:
trunk
Files:
3 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin.php

    r5196 r5357  
    112112    'U_CONFIG_EXTENTS'=> $link_start.'extend_for_templates', 
    113113    'U_CONFIG_MENUBAR'=> $link_start.'menubar', 
     114    'U_CONFIG_LANGUAGES' => $link_start.'languages_installed', 
    114115    'U_CONFIG_THEMES'=> $link_start.'themes_installed', 
    115116    'U_CATEGORIES'=> $link_start.'cat_list', 
  • trunk/admin/include/functions.php

    r5196 r5357  
    19501950    case 'themes_new': 
    19511951    case 'themes_installed': 
     1952    case 'languages_installed': 
    19521953      return 5; 
    19531954  } 
  • trunk/admin/themes/default/default-layout.css

    r5304 r5357  
    3737} 
    3838 
    39 /* Plugins tables */ 
     39/* Plugins, languages tables */ 
    4040TABLE.plugins { min-width: 400px; } 
    4141TABLE.plugins A { border: 0; } 
     
    4343TABLE.plugins TR TD.pluginState { padding: 4px 16px; } 
    4444 
    45 TABLE.plugins TR TD.active { 
     45TABLE.plugins TR TD.active, 
     46TABLE.languages TR TD.active { 
    4647        background: url(icon/plugin_active.gif) no-repeat center left; 
    4748        background-color: inherit; /* IE need it */ 
     
    6364 
    6465TABLE.plugins ul.pluginsActions li { display: inline; } 
     66 
     67TABLE.languages  { min-width: 400px; } 
     68TABLE.languages TR TD { text-align: center; padding: 4px 20px; } 
    6569 
    6670/* categoryOrdering */ 
  • trunk/admin/themes/default/template/admin.tpl

    r5293 r5357  
    8585        <li><a href="{$U_CONFIG_MENUBAR}">{'Menu'|@translate}</a></li> 
    8686        <li><a href="{$U_CONFIG_EXTENTS}">{'Templates'|@translate}</a></li> 
     87        <li><a href="{$U_CONFIG_LANGUAGES}">{'Languages'|@translate}</a></li> 
    8788        <li><a href="{$U_CONFIG_THEMES}">{'Themes'|@translate}</a></li> 
    8889      </ul> 
  • trunk/include/functions.inc.php

    r5335 r5357  
    397397 * @returns array 
    398398 */ 
    399 function get_languages($target_charset = null) 
    400 { 
    401   if ( empty($target_charset) ) 
    402   { 
    403     $target_charset = get_pwg_charset(); 
    404   } 
    405   $target_charset = strtolower($target_charset); 
    406  
    407   $dir = opendir(PHPWG_ROOT_PATH.'language'); 
     399function get_languages() 
     400{ 
     401  $query = ' 
     402SELECT id, name 
     403  FROM '.LANGUAGES_TABLE.' 
     404  ORDER BY name ASC 
     405;'; 
     406  $result = pwg_query($query); 
     407 
    408408  $languages = array(); 
    409  
    410   while ($file = readdir($dir)) 
    411   { 
    412     $path = PHPWG_ROOT_PATH.'language/'.$file; 
    413     if (!is_link($path) and is_dir($path) and file_exists($path.'/iso.txt')) 
    414     { 
    415       list($language_name) = @file($path.'/iso.txt'); 
    416  
    417       $languages[$file] = convert_charset($language_name, $target_charset); 
    418     } 
    419   } 
    420   closedir($dir); 
    421   @asort($languages); 
     409  while ($row = pwg_db_fetch_assoc($result)) 
     410  { 
     411    if (is_dir(PHPWG_ROOT_PATH.'language/'.$row['id'])) 
     412    { 
     413      $languages[ $row['id'] ] = $row['name']; 
     414    } 
     415  } 
    422416 
    423417  return $languages; 
  • trunk/install.php

    r5341 r5357  
    189189include(PHPWG_ROOT_PATH . 'admin/include/functions_upgrade.php'); 
    190190 
     191include(PHPWG_ROOT_PATH . 'admin/include/languages.class.php'); 
     192$languages = new languages('utf-8'); 
     193 
    191194if (isset($_GET['language'])) 
    192195{ 
     
    197200  $language = 'en_UK'; 
    198201  // Try to get browser language 
    199   foreach (get_languages('utf-8') as $language_code => $language_name) 
     202  foreach ($languages->fs_languages as $language_code => $language_name) 
    200203  { 
    201204    if (substr($language_code,0,2) == @substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2)) 
     
    287290      $pwg_db_charset = 'latin1'; 
    288291      $install_charset_collate = ''; 
    289       if ( !array_key_exists($language, get_languages($pwg_charset) ) ) 
     292      if ( !array_key_exists($language, $languages->get_fs_languages($pwg_charset) ) ) 
    290293      { 
    291294        $language='en_UK'; 
     
    376379 
    377380    // fill languages table 
    378     $inserts = array(); 
    379     foreach (get_languages('utf-8') as $language_code => $language_name) 
    380     { 
    381       $inserts[] = array( 
    382         'id' => $language_code, 
    383         'name' => $language_name, 
    384       ); 
    385     } 
    386     mass_inserts(LANGUAGES_TABLE, array('id', 'name'), $inserts); 
     381    foreach ($languages->get_fs_languages($pwg_charset) as $language_code => $language_name) 
     382    { 
     383      $languages->perform_action('activate', $language_code); 
     384    } 
    387385 
    388386    // fill $conf global array 
     
    476474  $dbengines = available_engines(); 
    477475 
    478   foreach (get_languages('utf-8') as $language_code => $language_name) 
     476  foreach ($languages->fs_languages as $language_code => $language_name) 
    479477  { 
    480478    if ($language == $language_code) 
  • trunk/install/db/90-database.php

    r5341 r5357  
    4545 
    4646// Fill table 
    47 $inserts = array(); 
    48 foreach (get_languages('utf-8') as $language_code => $language_name) 
     47include_once(PHPWG_ROOT_PATH.'include/constants.php'); 
     48include_once(PHPWG_ROOT_PATH.'admin/include/languages.class.php'); 
     49 
     50$languages = new languages(PWG_CHARSET); 
     51 
     52foreach ($languages->fs_languages as $language_code => $language_name) 
    4953{ 
    50   $inserts[] = array( 
    51     'id' => $language_code, 
    52     'name' => $language_name, 
    53   ); 
     54  $languages->perform_action('activate', $language_code); 
    5455} 
    55 mass_inserts(PREFIX_TABLE.'languages', array('id', 'name'), $inserts); 
    5656 
    5757echo 
  • trunk/language/en_UK/admin.lang.php

    r5328 r5357  
    750750$lang['Activate field "%s"'] = 'Activate field "%s"'; 
    751751$lang['Photo Properties'] = 'Photo Properties'; 
    752 $lang['Allow user customization'] = 'Allow user customization';  
     752$lang['Allow user customization'] = 'Allow user customization'; 
     753$lang['Languages'] = 'Languages'; 
    753754?> 
  • trunk/language/fr_FR/admin.lang.php

    r5304 r5357  
    752752$lang['Visit Piwigo project website'] = 'Visiter le site web du projet Piwigo'; 
    753753$lang['pLoader stands for <em>Piwigo Uploader</em>. From your computer, pLoader prepares your photos and transfer them to your Piwigo photo gallery.'] = 'pLoader signifie <em>Piwigo Uploader</em>. Depuis votre ordinateur, pLoader prépare vos photos et les transfert vers votre galerie photo Piwigo.'; 
     754$lang['Languages'] = 'Langues'; 
    754755?> 
Note: See TracChangeset for help on using the changeset viewer.