当前位置: 首页>>代码示例>>PHP>>正文


PHP Translation::generateFileTranslationPlugin方法代码示例

本文整理汇总了PHP中Translation::generateFileTranslationPlugin方法的典型用法代码示例。如果您正苦于以下问题:PHP Translation::generateFileTranslationPlugin方法的具体用法?PHP Translation::generateFileTranslationPlugin怎么用?PHP Translation::generateFileTranslationPlugin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Translation的用法示例。


在下文中一共展示了Translation::generateFileTranslationPlugin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: LoadTranslationPlugins

 /**
  * Function LoadTranslationPlugins
  * It generates a global Translation variable for plugins
  *
  * Per script
  *
  * @author Brayan Pereyra <cochalo>. <brayan@colosa.com>
  * @access public
  * @param  string lang
  * @param  array list plugins active
  * @return void
  */
 public function LoadTranslationPlugins($lang = SYS_LANG, $listPluginsActive)
 {
     if (!is_array($listPluginsActive)) {
         return null;
     }
     foreach ($listPluginsActive['_aPluginDetails'] as $key => $value) {
         $namePlugin = trim($key);
         $translation = array();
         if (!file_exists(PATH_LANGUAGECONT . $namePlugin . '.en')) {
             Translation::generateFileTranslationPlugin($namePlugin, 'en');
         }
         if ($lang != 'en' && !file_exists(PATH_LANGUAGECONT . $namePlugin . '.' . $lang)) {
             Translation::generateFileTranslationPlugin($namePlugin, $lang);
         }
         if (file_exists(PATH_LANGUAGECONT . $namePlugin . '.' . $lang)) {
             eval('global $translation' . $namePlugin . ';');
             require_once PATH_LANGUAGECONT . $namePlugin . '.' . $lang;
         } else {
             if (file_exists(PATH_LANGUAGECONT . $namePlugin . '.en')) {
                 eval('global $translation' . $namePlugin . ';');
                 require_once PATH_LANGUAGECONT . $namePlugin . '.en';
             }
         }
     }
     return true;
 }
开发者ID:norahmollo,项目名称:processmaker,代码行数:38,代码来源:class.bootstrap.php

示例2: updateLanguagePlugin

 public function updateLanguagePlugin($plugin, $idLanguage)
 {
     if (!file_exists(PATH_PLUGINS . $plugin)) {
         throw new Exception('The plugin ' . $plugin . ' not exist');
         die;
     }
     if (!file_exists(PATH_PLUGINS . $plugin . PATH_SEP . 'translations' . PATH_SEP . 'translations.php')) {
         throw new Exception('Translations.php not exist in plugin ' . $plugin);
     }
     if (!file_exists(PATH_PLUGINS . $plugin . PATH_SEP . 'translations' . PATH_SEP . $plugin . '.' . $idLanguage . '.po')) {
         throw new Exception('The file ' . $plugin . '.' . $idLanguage . '.po not exists');
         die;
     }
     $languageFile = PATH_PLUGINS . $plugin . PATH_SEP . 'translations' . PATH_SEP . $plugin . '.' . $idLanguage . '.po';
     try {
         G::LoadSystem('i18n_po');
         $POFile = new i18n_PO($languageFile);
         $POFile->readInit();
         $POHeaders = $POFile->getHeaders();
         $oTranslation = new Translation();
         $countItems = 0;
         $countItemsSuccess = 0;
         $errorMsg = '';
         while ($rowTranslation = $POFile->getTranslation()) {
             $countItems++;
             if (!isset($POFile->translatorComments[0]) || !isset($POFile->translatorComments[1]) || !isset($POFile->references[0])) {
                 throw new Exception('The .po file doesn\'t have valid directives for Processmaker!');
             }
             foreach ($POFile->translatorComments as $a => $aux) {
                 $identifier = '';
                 $context = '';
                 $aux = trim($aux);
                 if ($aux == 'TRANSLATION') {
                     $identifier = $aux;
                 } else {
                     $var = explode('/', $aux);
                     if ($var[0] == 'LABEL') {
                         $context = $aux;
                     }
                     if ($var[0] == 'JAVASCRIPT') {
                         $context = $aux;
                     }
                 }
                 if ($identifier == '' && $context == '') {
                     $context = $aux;
                 }
                 if (preg_match('/^([\\w-]+)\\/([\\w-]+\\/*[\\w-]*\\.xml\\?)/', $aux, $match)) {
                     $identifier = $aux;
                 } else {
                     if (preg_match('/^([\\w-]+)\\/([\\w-]+\\/*[\\w-]*\\.xml$)/', $aux, $match)) {
                         $context = $aux;
                     }
                 }
             }
             $reference = $POFile->references[0];
             if ($identifier != 'TRANSLATION') {
                 $xmlForm = $context;
                 //erik: expresion to prevent and hable correctly dropdown values like -1, -2 etc.
                 preg_match('/^([\\w_]+)\\s-\\s([\\w_]+)\\s*-*\\s*([\\w\\W]*)$/', $reference, $match);
                 if (!file_exists(PATH_PLUGINS . $plugin . PATH_SEP . $xmlForm)) {
                     $errorMsg .= 'file doesn\'t exist: ' . PATH_PLUGINS . $plugin . $xmlForm . "\n";
                     continue;
                 }
                 if (count($match) < 4) {
                     $near = isset($rowTranslation['msgid']) ? $rowTranslation['msgid'] : (isset($rowTranslation['msgstr']) ? $rowTranslation['msgstr'] : '');
                     $errorMsg .= "Invalid Translation reference: \"{$reference}\",  near -> " . strip_tags($near) . "\n";
                     continue;
                 }
                 G::LoadSystem('dynaformhandler');
                 $dynaform = new dynaFormHandler(PATH_PLUGINS . $plugin . PATH_SEP . $xmlForm);
                 $fieldName = $match[2];
                 $codes = explode('-', $reference);
                 if (sizeof($codes) == 2) {
                     //is a normal node
                     $dynaform->addChilds($fieldName, array($idLanguage => stripcslashes(str_replace(chr(10), '', $rowTranslation['msgstr']))));
                 } elseif (sizeof($codes) > 2) {
                     //is a node child for a language node
                     $name = $match[3] == "''" ? '' : $match[3];
                     $childNode = array(array('name' => 'option', 'value' => $rowTranslation['msgstr'], 'attributes' => array('name' => $name)));
                     $dynaform->addChilds($fieldName, array($idLanguage => null), $childNode);
                 }
                 $countItemsSuccess++;
             }
         }
         $trn = new Translation();
         $trn->generateFileTranslationPlugin($plugin, $idLanguage);
         $trn->addTranslationEnvironmentPlugins($plugin, $idLanguage, $POHeaders, $countItemsSuccess);
         $languageID = isset($languageID) ? $languageID : $idLanguage;
         //fill the results
         $results = new stdClass();
         $results->recordsCount = $countItems;
         $results->recordsCountSuccess = $countItemsSuccess;
         $results->lang = $languageID;
         $results->headers = $POHeaders;
         $results->errMsg = $errorMsg;
         return $results;
     } catch (Exception $oError) {
         throw $oError;
     }
 }
开发者ID:emildev35,项目名称:processmaker,代码行数:100,代码来源:Language.php


注:本文中的Translation::generateFileTranslationPlugin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。