linea21-utils
[ class tree: linea21-utils ] [ index: linea21-utils ] [ all elements ]

Source for file lang.php

Documentation is available at lang.php

  1. <?php
  2. /**
  3.  * @package linea21.utils
  4.  * @subpackage lib
  5.  * @author linea21 <info@linea21.com>
  6.  * @version $id SVN
  7.  * @access public
  8.  * @license http://opensource.org/licenses/gpl-3.0.html
  9.  */
  10.  
  11. /**
  12.  * IncludeLang()
  13.  * Fait les includes de fichiers de langue en fonction de la rubrique active ( partie publique )
  14.  *
  15.  * @return void (include)
  16.  */
  17. function IncludeLang()
  18. {
  19.   $language U_L;
  20.   include_once('../languages/' $language '/lang_common.' CHARSET '.php');
  21.  
  22.   if (ActiveItemAlias($GLOBALS['activeitem']== 'directory'{
  23.     include_once('../languages/' $language '/lang_yellowpages.' CHARSET '.php');
  24.   }
  25.   if (ActiveItemAlias($GLOBALS['activeitem']== 'dashboard'{
  26.     include_once('../languages/' $language '/lang_sdi.' CHARSET '.php');
  27.     include_once('../languages/' $language '/lang_dashboard.' CHARSET '.php');
  28.   }
  29.   if (ActiveItemAlias($GLOBALS['activeitem']== 'workgroup'{
  30.     include_once('../languages/' $language '/lang_workshop.' CHARSET '.php');
  31.     include_once('../languages/' $language '/lang_workshoprep.' CHARSET '.php');
  32.     include_once('../languages/' $language '/lang_publication.' CHARSET '.php');
  33.     include_once('../languages/' $language '/lang_system.' CHARSET '.php');
  34.   }
  35.   if (ActiveItemAlias($GLOBALS['activeitem']== 'project'{
  36.     include_once('../languages/' $language '/lang_project.' CHARSET '.php');
  37.   }
  38.   if (ActiveItemAlias($GLOBALS['activeitem']== 'publication'{
  39.     include_once('../languages/' $language '/lang_publication.' CHARSET '.php');
  40.   }
  41.   if (ActiveItemAlias($GLOBALS['activeitem']== 'user-prefs'{
  42.     include_once('../languages/' $language '/lang_user.' CHARSET '.php');
  43.   }
  44.   if (ActiveItemAlias($GLOBALS['activeitem']== 'news'{
  45.     include_once('../languages/' $language '/lang_news.' CHARSET '.php');
  46.   }
  47.   if (ActiveItemAlias($GLOBALS['activeitem']== 'subscribe-newsletter'{
  48.     include_once('../languages/' $language '/lang_newsletter.' CHARSET '.php');
  49.   }
  50.   if (ActiveItemAlias($GLOBALS['activeitem']== 'search'{
  51.     include_once('../languages/' $language '/lang_search.' CHARSET '.php');
  52.   }
  53.   if (ActiveItemAlias($GLOBALS['activeitem']== 'workgroup-subscription'{
  54.     include_once('../languages/' $language '/lang_workshop.' CHARSET '.php');
  55.     include_once('../languages/' $language '/lang_user.' CHARSET '.php');
  56.   }
  57.  
  58.   $GLOBALS['lang'$lang;
  59. }
  60.  
  61. /**
  62.  * IncludeAdminLang()
  63.  * Fait les includes de fichiers de langue en fonction de la rubrique active ( partie admin )
  64.  *
  65.  * @return void (include)
  66.  */
  67. function IncludeAdminLang($rubrique)
  68. {
  69.   $language U_L;
  70.   include_once('../languages/' $language '/lang_common.' CHARSET '.php');
  71.   include_once('../languages/' $language '/lang_' $rubrique '.' CHARSET '.php');
  72.  
  73.   if ($rubrique === 'dashboard'{
  74.     include_once('../languages/' $language '/lang_sdi.' CHARSET '.php');
  75.   }
  76.   if ($rubrique === 'sdi'{
  77.     include_once('../languages/' $language '/lang_dashboard.' CHARSET '.php');
  78.   }
  79.  
  80.   $GLOBALS['lang'$lang;
  81.  
  82. }
  83.  
  84. /**
  85.  * _t()
  86.  * Translate item
  87.  * @param string $scope 
  88.  * @param string $item 
  89.  * @return string 
  90.  ***/
  91. function _t($scope$item)
  92. {
  93.   if(isset($GLOBALS['lang'][$scope][$item])) {
  94.     return $GLOBALS['lang'][$scope][$item];
  95.   }
  96.   else {
  97.     if(MOD_DEBUG == 1{
  98.       return '<span class="debug_alert">_t(\''.$scope."', '".$item.'\') does not exist</span>';
  99.     else {
  100.       return $scope." ".$item;
  101.     }
  102.   }
  103. }
  104.  
  105. /**
  106.  * _def()
  107.  * Define a user language variable
  108.  * override previous value if already defined
  109.  * @param string $scope 
  110.  * @param string $item 
  111.  * @param string $str 
  112.  * @return string 
  113.  ***/
  114. function _def($scope$item$str)
  115. {
  116.   if(isset($GLOBALS['lang'][$scope][$item])) unset($GLOBALS['lang'][$scope][$item]);
  117.  
  118.   $GLOBALS['lang'][$scope][$item$str;
  119. }
  120.  
  121. /**
  122.  * IncludeUserfiles()
  123.  * Include user files prefixed by '_' from languages folders
  124.  *
  125.  * @return void (include)
  126.  */
  127. function IncludeUserfiles({
  128.   $language U_L;
  129.   $paths glob('../languages/' $language '/_*.php');
  130.   if(CURRENT_APP == 'admin'{
  131.     $pattern THEME_ADMIN_PATH.'override/languages/' $language '/_*.php';
  132.   else {
  133.     $pattern THEME_PUBLIC_PATH.'override/languages/' $language '/_*.php';
  134.   }
  135.   $paths array_merge($pathsglob($pattern));
  136.   if($paths != false{
  137.     foreach ($paths as $filename{
  138.       _debug('Including user defined language files : '$filename);
  139.       include_once($filename);
  140.     }
  141.   }
  142. }
  143.  
  144. /**
  145.  * IncludeLanguagesPluginfiles()
  146.  * Include plugin files from specific plugin languages folders
  147.  * @param object $plugin 
  148.  * @return void (include)
  149.  */
  150. function IncludeLanguagesPluginfiles($plugin{
  151.  
  152.   // we try to include the current culture
  153.   $paths glob('../plugins/'.$plugin->getVar('name').'/languages/' U_L '/*.php');
  154.   // if current culture not found, we include default language files
  155.   if(count($paths)==0$paths glob('../plugins/'.$plugin->getVar('name').'/languages/' $plugin->getVar('default_language''/*.php');
  156.  
  157.   if($paths != false{
  158.     foreach ($paths as $filename{
  159.       _debug('Including <em>'.$plugin.'</em> plugin language files : '$filename);
  160.       include_once($filename);
  161.     }
  162.   }
  163.   return true;
  164. }
  165. ?>

Documentation generated on Fri, 01 Apr 2011 09:31:51 +0200 by phpDocumentor 1.4.1