[ Index ]

Source Code Reference for V1.00

title

Body

[close]

/modules/system/ -> translate.php (source)

   1  <?php /* $Id: translate.php 141 2008-04-05 16:41:20Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/system/translate.php $ */
   2  if (!defined('W2P_BASE_DIR')) {
   3      die('You should not access this file directly.');
   4  }
   5  
   6  // check permissions
   7  $perms = &$AppUI->acl();
   8  if (!$perms->checkModule('system', 'edit')) {
   9      $AppUI->redirect('m=public&a=access_denied');
  10  }
  11  
  12  $module = w2PgetParam($_REQUEST, 'module', 'admin');
  13  $lang = w2PgetParam($_REQUEST, 'lang', $AppUI->user_locale);
  14  
  15  $AppUI->savePlace('m=system&a=translate&module=' . $module . '&lang=' . $lang);
  16  
  17  // read the installed modules
  18  $modules = arrayMerge($AppUI->readDirs('modules'), array('common' => 'common', 'styles' => 'styles'));
  19  asort($modules);
  20  
  21  // read the installed languages
  22  $locales = $AppUI->readDirs('locales');
  23  
  24  ob_start();
  25  // read language files from module's locale directory preferrably
  26  if (file_exists(W2P_BASE_DIR . '/modules/' . $modules[$module] . '/locales/en.inc')) {
  27      readfile(W2P_BASE_DIR . '/modules/' . $modules[$module] . '/locales/en.inc');
  28  } else {
  29      readfile(W2P_BASE_DIR . '/locales/en/' . $modules[$module] . '.inc');
  30  }
  31  eval("\$english=array(" . ob_get_contents() . "\n'0');");
  32  ob_end_clean();
  33  
  34  $trans = array();
  35  foreach ($english as $k => $v) {
  36      if ($v != '0') {
  37          $trans[(is_int($k) ? $v : $k)] = array('english' => $v);
  38      }
  39  }
  40  
  41  //echo "<pre>";print_r($trans);echo "</pre>";die;
  42  
  43  if ($lang != 'en') {
  44      ob_start();
  45      // read language files from module's locale directory preferrably
  46      if (file_exists(W2P_BASE_DIR . '/modules/' . $modules[$module] . '/locales/' . $lang . '.inc')) {
  47          readfile(W2P_BASE_DIR . '/modules/' . $modules[$module] . '/locales/' . $lang . '.inc');
  48      } else {
  49          readfile(W2P_BASE_DIR . '/locales/' . $lang . '/' . $modules[$module] . '.inc');
  50      }
  51      eval("\$locale=array(" . ob_get_contents() . "\n'0');");
  52      ob_end_clean();
  53  
  54      foreach ($locale as $k => $v) {
  55          if ($v != '0') {
  56              $trans[$k]['lang'] = $v;
  57          }
  58      }
  59  }
  60  ksort($trans);
  61  
  62  $titleBlock = new CTitleBlock('Translation Management', 'rdf2.png', $m, $m . '.' . $a);
  63  $titleBlock->addCell($AppUI->_('Module'), '', '<form action="?m=system&a=translate" method="post" name="modlang">', '');
  64  $titleBlock->addCell(arraySelect($modules, 'module', 'size="1" class="text" onchange="document.modlang.submit();"', $module));
  65  $titleBlock->addCell($AppUI->_('Language'));
  66  $temp = $AppUI->setWarning(false);
  67  $titleBlock->addCell(arraySelect($locales, 'lang', 'size="1" class="text" onchange="document.modlang.submit();"', $lang, true), '', '', '</form>');
  68  $AppUI->setWarning($temp);
  69  
  70  $titleBlock->addCrumb('?m=system', 'system admin');
  71  $titleBlock->show();
  72  ?>
  73  
  74  <form action="?m=system&a=translate_save" method="post" name="editlang">
  75  <input type="hidden" name="module" value="<?php echo $modules[$module]; ?>" />
  76  <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
  77  <table width="100%" border="0" cellpadding="1" cellspacing="1" class="tbl">
  78  <tr>
  79      <th width="15%" nowrap="nowrap"><?php echo $AppUI->_('Abbreviation'); ?></th>
  80      <th width="40%" nowrap="nowrap"><?php echo $AppUI->_('English String'); ?></th>
  81      <th width="40%" nowrap="nowrap"><?php echo $AppUI->_('String') . ': ' . $AppUI->_($locales[$lang]); ?></th>
  82      <th width="5%" nowrap="nowrap"><?php echo $AppUI->_('delete'); ?></th>
  83  </tr>
  84  <?php
  85  $s = '';
  86  $index = 0;
  87  if ($lang == 'en') {
  88      $s .= '<tr>';
  89      $s .= '<td><input type="text" name="trans[' . $index . '][abbrev]" value="" size="20" class="text" /></td>';
  90      $s .= '<td><input type="text" name="trans[' . $index . '][english]" value="" size="40" class="text" /></td>';
  91      $s .= '<td colspan="2">' . $AppUI->_('New Entry') . '</td>';
  92      $s .= '</tr>';
  93  }
  94  
  95  $index++;
  96  foreach ($trans as $k => $langs) {
  97      $s .= '<tr><td>';
  98      if ($k != $langs['english']) {
  99          $k = w2PformSafe($k, true);
 100          if ($lang == 'en') {
 101              $s .= '<input type="text" name="trans[' . $index . '][abbrev]" value="' . $k . '" size="20" class="text" />';
 102          } else {
 103              $s .= $k;
 104          }
 105      } else {
 106          $s .= '&nbsp;';
 107      }
 108      $s .= '</td><td>';
 109      //$langs['english'] = htmlspecialchars( $langs['english'], ENT_QUOTES );
 110      $langs['english'] = w2PformSafe($langs['english'], true);
 111      if ($lang == 'en') {
 112          if (strlen($langs['english']) < 40) {
 113              $s .= '<input type="text" name="trans[' . $index . '][english]" value="' . $langs['english'] . '" size="40" class="text" />';
 114          } else {
 115              $rows = round(strlen($langs['english'] / 35)) + 1;
 116              $s .= '<textarea name="trans[' . $index . '][english]"  cols="40" class="small" rows="' . $rows . '">' . $langs['english'] . '</textarea>';
 117          }
 118      } else {
 119          $s .= $langs['english'];
 120          $s .= '<input type="hidden" name="trans[' . $index . '][english]" value="' . ($k ? $k : $langs['english']) . '" size="20" class="text" />';
 121      }
 122      $s .= '</td><td>';
 123      if ($lang != 'en') {
 124          $langs['lang'] = w2PformSafe($langs['lang'], true);
 125          if (strlen($langs['lang']) < 40) {
 126              $s .= '<input type="text" name="trans[' . $index . '][lang]" value="' . $langs['lang'] . '" size="40" class="text" />';
 127          } else {
 128              $rows = round(strlen($langs['lang'] / 35)) + 1;
 129              $s .= '<textarea name="trans[' . $index . '][lang]" cols="40" class="small" rows="' . $rows . '">' . $langs['lang'] . '</textarea>';
 130          }
 131      }
 132      $s .= '</td><td align="center"><input type="checkbox" name="trans[' . $index . '][del]" /></td></tr>';
 133      $index++;
 134  }
 135  echo $s;
 136  ?>
 137  <tr>
 138      <td colspan="4" align="right">
 139          <input type="submit" value="<?php echo $AppUI->_('submit'); ?>" class="button" />
 140      </td>
 141  </tr>
 142  </form>
 143  </table>


Generated: Thu Jan 8 03:00:03 2009 Cross-referenced by PHPXref 0.7