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


PHP Languages::getTranslationPath方法代码示例

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


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

示例1: createTranslationFile

 /**
  * Creates dictionary file in localization path
  *
  * @param string $dictionary_name
  */
 function createTranslationFile($dictionary_name)
 {
     $dictionary_file = Languages::getDictionaryPath($dictionary_name);
     if (!is_file($dictionary_file)) {
         return false;
     }
     // if
     $translation_file = Languages::getTranslationPath($this, $dictionary_name);
     if (!folder_is_writable(dirname($translation_file))) {
         return false;
     }
     // if
     if (is_file($translation_file)) {
         return true;
     }
     // if
     $dictionary = Languages::getDictionary($dictionary_name);
     $translation = array();
     if (is_foreachable($dictionary)) {
         foreach ($dictionary as $dictionary_word) {
             $translation[$dictionary_word] = '';
         }
         // foreach
     }
     // if
     $result = file_put_contents($translation_file, "<?php return " . var_export($translation, true) . " ?>");
     if (!$result) {
         return false;
     }
     // if
     return true;
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:37,代码来源:Language.class.php

示例2: getTranslation

 /**
  * Returns trnslation for $language and $translation parameter
  *
  * @param Language $language
  * @param string $translation
  * @return array
  */
 function getTranslation($language, $translation)
 {
     $translation_file = Languages::getTranslationPath($language, $translation);
     if (!is_file($translation_file)) {
         return false;
     }
     // if
     return require $translation_file;
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:16,代码来源:Languages.class.php

示例3: import


//.........这里部分代码省略.........
                     $name = $language['language']['info']['name']['value'];
                     $ac_version = $language['language']['info']['ac_version']['value'];
                     $system_version = $this->application->version ? $this->application->version : '1.0';
                     if (!$locale || !$name) {
                         flash_error('Language XML file is corrupted');
                         $this->redirectToReferer($import_url);
                     }
                     // if
                     if (Languages::localeExists($locale)) {
                         flash_error('Language with locale :locale is already installed on system', array('locale' => $locale));
                         $this->redirectToReferer($import_url);
                     }
                     // if
                     if (Languages::nameExists($name)) {
                         flash_error('Language with name :name is already installed on system', array('name' => $name));
                         $this->redirectToReferer($import_url);
                     }
                     // if
                     $attachment = make_attachment($_FILES['xml']);
                     if (!$attachment || is_error($attachment)) {
                         flash_error($attachment->getMessage(), array('name' => $name));
                         $this->redirectToReferer($import_url);
                     }
                     // if
                     if (version_compare($ac_version, $system_version, '=') != true) {
                         $this->wireframe->addPageMessage(lang('Current activeCollab version is <strong>:system_version</strong> and this translation is made for <strong>:ac_version</strong> version. Importing can continue, but this translation may not work on your system', array('system_version' => $system_version, 'ac_version' => $ac_version)), 'warning');
                     }
                     // if
                     $this->smarty->assign(array('language_ac_version' => $ac_version, 'language_name' => $name, 'language_locale' => $locale, 'system_version' => $system_version, 'attachment_id' => $attachment->getId()));
                     $this->setTemplate('import_review');
                     break;
                 case 'finalize':
                     $attachment_id = $this->request->post('attachment_id');
                     $attachment = Attachments::findById($attachment_id);
                     if (!instance_of($attachment, 'Attachment')) {
                         flash_error('There was some unknown error, please try again');
                         $this->redirectTo($import_url);
                     }
                     // if
                     require_once ANGIE_PATH . '/classes/xml/xml2array.php';
                     $language_array = xml2array(file_get_contents(UPLOAD_PATH . '/' . $attachment->getLocation()));
                     if (!$language_array) {
                         flash_error('Uploaded file is not valid XML');
                         $this->redirectToReferer($import_url);
                     }
                     // if
                     $language_locale = $language_array['language']['info']['locale']['value'];
                     $language_name = $language_array['language']['info']['name']['value'];
                     $language_version = $language_array['language']['info']['ac_version']['value'];
                     $language = new Language();
                     $language->setLocale($language_locale);
                     $language->setName($language_name);
                     $result = recursive_mkdir($language->getLocalizationPath(), 0777, LOCALIZATION_PATH);
                     if (!$result) {
                         flash_error('Could not create localization folder');
                         $this->redirectToReferer($import_url);
                     }
                     // if
                     $save = $language->save();
                     if (!$save || is_error($save)) {
                         flash_error($save->getMessage());
                         $this->redirectToReferer($import_url);
                     }
                     // if
                     $info = array('name' => $language_name, 'code' => $language_locale, 'version' => $language_version);
                     $result = file_put_contents($language->getLocalizationPath() . '/info.php', "<?php return " . var_export($info, true) . " ?>");
                     if (is_foreachable($language_array['language']['translations']['module'])) {
                         foreach ($language_array['language']['translations']['module'] as $module_translation) {
                             if (is_foreachable($module_translation['translation'])) {
                                 $module_name = $module_translation['attr']['name'];
                                 $output = array();
                                 foreach ($module_translation['translation'] as $translation) {
                                     if (is_array($translation)) {
                                         $phrase = $translation['attr']['phrase'];
                                         $translation_value = $translation['value'];
                                         $output[$phrase] = $translation_value;
                                     }
                                     // if
                                 }
                                 // foreach
                                 $filename = Languages::getTranslationPath($language, $module_name);
                                 file_put_contents($filename, "<?php return " . var_export($output, true) . " ?>");
                             }
                             // if
                         }
                         // foreach
                     }
                     // if
                     $attachment->delete();
                     flash_success('Language imported successfully');
                     $this->redirectTo('admin_languages');
                     break;
                 default:
                     break;
             }
         }
         // if
     }
     // if
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:101,代码来源:LanguagesAdminController.class.php


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