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


PHP Languages::getDictionaryPath方法代码示例

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


在下文中一共展示了Languages::getDictionaryPath方法的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: getDictionary

 /**
  * Returns dictionary $name. If there is no such dictionary returns false
  *
  * @param string $name
  * @return array
  */
 function getDictionary($name)
 {
     $dictionary_path = Languages::getDictionaryPath($name);
     if (!is_file($dictionary_path)) {
         return false;
     }
     // if
     return require $dictionary_path;
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:15,代码来源:Languages.class.php

示例3: edit_translation_file

 /**
  * Edit translation file in chosen language
  * 
  * @param void
  * @return void
  */
 function edit_translation_file()
 {
     if ($this->active_language->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     $translation_id = $this->request->get('filename');
     if (!$translation_id) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     $dictionary_filename = Languages::getDictionaryPath($translation_id);
     if (!is_file($dictionary_filename)) {
         flash_error('Dictionary does not exists');
         $this->redirectToUrl($this->active_language->getViewUrl());
     }
     // if
     $dictionary = Languages::getDictionary($translation_id);
     $translation_file = Languages::getTranslationPath($this->active_language, $translation_id);
     if (!is_file($translation_file)) {
         flash_error('Translation file does not exists. You need to create it first.');
         $this->redirectToUrl($this->active_language->getViewUrl());
     }
     // if
     $translation_data = Languages::getTranslation($this->active_language, $translation_id);
     $prepared_form_data = $this->request->post('form_data');
     if (!is_array($prepared_form_data)) {
         $prepared_form_data = array();
         foreach ($dictionary as $dictionary_id => $dictionary_value) {
             $prepared_form_data[$dictionary_id] = array("dictionary_value" => $dictionary_value, "translated_value" => array_var($translation_data, $dictionary_value));
         }
         // foreach
         $this->smarty->assign(array("prepared_form_data" => $prepared_form_data));
     }
     // if
     $this->smarty->assign(array("translation_file" => $translation_id, "form_url" => $this->active_language->getEditTranslationFileUrl($translation_id)));
     if ($this->request->isSubmitted()) {
         if (is_foreachable($prepared_form_data)) {
             $new_prepared_data = array();
             $translation_data = array();
             foreach ($prepared_form_data as $prepared_form_data_key => $prepared_form_data_value) {
                 $translation_data[array_var($dictionary, $prepared_form_data_key)] = $prepared_form_data_value;
                 $new_prepared_data[$prepared_form_data_key] = array("dictionary_value" => array_var($dictionary, $prepared_form_data_key), "translated_value" => $prepared_form_data_value);
             }
             // foreach
         }
         // if
         file_put_contents($translation_file, '<?php return ' . var_export($translation_data, true) . ' ?>');
         cache_remove_by_pattern('lang_cache_for_*');
         if (module_loaded('incoming_mail')) {
             // set config option for translation
             if (array_key_exists(EMAIL_SPLITTER, $translation_data)) {
                 $config_option = ConfigOptions::getValue('email_splitter_translations');
                 $config_option[$this->active_language->getLocale()] = $translation_data[EMAIL_SPLITTER];
                 ConfigOptions::setValue('email_splitter_translations', $config_option);
             }
             // if
         }
         // if
         $this->smarty->assign(array("prepared_form_data" => $new_prepared_data));
     }
     // if
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:69,代码来源:LanguagesAdminController.class.php


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