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


PHP MO::export_to_file方法代码示例

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


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

示例1: wpll_create_mofile

function wpll_create_mofile()
{
    global $wpll_pofile, $wpll_mofile;
    include_once ABSPATH . WPINC . '/pomo/po.php';
    $po = new PO();
    if (!@$po->import_from_file($wpll_pofile)) {
        return;
    }
    foreach ($po->entries as $key => $entry) {
        if (!empty($entry->references)) {
            $entry->references = array_filter($entry->references, 'wpll_filter_references');
            if (empty($entry->references)) {
                unset($po->entries[$key]);
                continue;
            }
        }
        if (!empty($entry->translations)) {
            if ($entry->singular == $entry->translations[0]) {
                unset($po->entries[$key]);
            }
        }
    }
    $mo = new MO();
    $mo->headers = $po->headers;
    $mo->entries = $po->entries;
    $mo->export_to_file($wpll_mofile);
    die;
}
开发者ID:slaFFik,项目名称:l10n-ru,代码行数:28,代码来源:wplang-lite.php

示例2: array

 function test_export_mo_file()
 {
     $entries = array();
     $entries[] = new Translation_Entry(array('singular' => 'pink', 'translations' => array('розов')));
     $no_translation_entry = new Translation_Entry(array('singular' => 'grey'));
     $entries[] = new Translation_Entry(array('singular' => 'green', 'plural' => 'greens', 'translations' => array('зелен', 'зелени')));
     $entries[] = new Translation_Entry(array('singular' => 'red', 'context' => 'color', 'translations' => array('червен')));
     $entries[] = new Translation_Entry(array('singular' => 'red', 'context' => 'bull', 'translations' => array('бик')));
     $entries[] = new Translation_Entry(array('singular' => 'maroon', 'plural' => 'maroons', 'context' => 'context', 'translations' => array('пурпурен', 'пурпурни')));
     $mo = new MO();
     $mo->set_header('Project-Id-Version', 'Baba Project 1.0');
     foreach ($entries as $entry) {
         $mo->add_entry($entry);
     }
     $mo->add_entry($no_translation_entry);
     $temp_fn = $this->temp_filename();
     $mo->export_to_file($temp_fn);
     $again = new MO();
     $again->import_from_file($temp_fn);
     $this->assertEquals(count($entries), count($again->entries));
     foreach ($entries as $entry) {
         $this->assertEquals($entry, $again->entries[$entry->key()]);
     }
 }
开发者ID:rmccue,项目名称:GlotPress,代码行数:24,代码来源:test_mo.php

示例3: MO

 /**
  * change language : if language file not exist return false
  * if language file not in THEME_LANGUAGE_PATH copy it from DEFAULT_LANG to THEME_LANGUAGE_PATH
  * @since 1.0
  */
 function change_language()
 {
     $lang = $_REQUEST['lang_name'];
     if (!in_array($lang, $this->get_language_list())) {
         wp_send_json(array('success' => false));
     }
     if (!in_array($lang, get_available_languages(THEME_LANGUAGE_PATH))) {
         $mo = new MO();
         $mo->set_header('Project-Id-Version', THEME_NAME . 'v' . ET_VERSION);
         $mo->set_header('Report-Msgid-Bugs-To', ET_URL);
         $mo->set_header('MO-Creation-Date', gmdate('Y-m-d H:i:s+00:00'));
         $mo->set_header('MIME-Version', '1.0');
         $mo->set_header('Content-Type', 'text/plain; charset=UTF-8');
         $mo->set_header('Content-Transfer-Encoding', '8bit');
         $mo->set_header('MO-Revision-Date', '2010-MO-DA HO:MI+ZONE');
         $mo->set_header('Last-Translator', 'JOB <EMAIL@ADDRESS>');
         $mo->set_header('Language-Team', 'ENGINETHEMES.COM <enginethemes@enginethemes.com>');
         $mo->import_from_file(DEFAULT_LANGUAGE_PATH . '/' . $lang . '.mo');
         $mo->export_to_file(THEME_LANGUAGE_PATH . '/' . $lang . '.mo');
     }
     $this->set_site_language($lang);
     wp_send_json(array('success' => true, 'data' => array('ID' => $lang, 'lang_name' => $lang)));
 }
开发者ID:rinodung,项目名称:wp-question,代码行数:28,代码来源:class-ae-languages.php

示例4: array

 function test_export_should_not_include_empty_translations()
 {
     $entries = array();
     $mo = new MO();
     $mo->add_entry(array('singular' => 'baba', 'translations' => array('', '')));
     $temp_fn = $this->temp_filename();
     $mo->export_to_file($temp_fn);
     $again = new MO();
     $again->import_from_file($temp_fn);
     $this->assertEquals(0, count($again->entries));
 }
开发者ID:boonebgorges,项目名称:develop.wordpress,代码行数:11,代码来源:mo.php

示例5: compilePo

 public static function compilePo($po_file, $mo_file)
 {
     $po = new \PO();
     $po->import_from_file($po_file);
     $mo = new \MO();
     $mo->headers = $po->headers;
     $mo->entries = $po->entries;
     $mo->export_to_file($mo_file);
 }
开发者ID:wemakecustom,项目名称:wp-pot-generator,代码行数:9,代码来源:Translatable.php

示例6: export

 /**
  * Save the PO file and compile corresponding MO file.
  *
  * @since 1.2.0 Removed .bak creation, added destination directory generating.
  * @since 1.0.0
  *
  * @uses \PO::export_to_file() to save the updated PO file.
  * @uses \MO::export_to_file() to compile the MO file.
  *
  * @param string $file Optional The file path/name to use.
  */
 public function export($file = null)
 {
     // Override file property with provided filename
     if ($file) {
         $this->filename = $file;
     }
     // Fail if no filename is available
     if (!$this->filename) {
         throw new Exception('No path specified to save to.');
     }
     // Load necessary libraries
     require_once ABSPATH . WPINC . '/pomo/mo.php';
     $mo = new \MO();
     // Create the .po and .mo filenames appropriately
     if (substr($this->filename, -3) == '.po') {
         // .po extension exists...
         $po_file = $this->filename;
         // ...replace with .mo
         $mo_file = substr($this->filename, 0, -3) . '.mo';
     } else {
         // No extension, add each
         $po_file = $this->filename . '.po';
         $mo_file = $this->filename . '.mo';
     }
     // Copy all properties from the PO interface to the MO one
     foreach (get_object_vars($this->po) as $key => $val) {
         $mo->{$key} = $val;
     }
     // Ensure the parent directory exists
     wp_mkdir_p(dirname($po_file));
     // Export the PO file
     $this->po->export_to_file($po_file);
     // Compile the MO file
     $mo->export_to_file($mo_file);
 }
开发者ID:dougwollison,项目名称:pomo-editor,代码行数:46,代码来源:class-pomoeditor-project.php


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