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


PHP PO::export_to_file方法代码示例

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


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

示例1: xgettext

 function xgettext($project, $dir, $output_file, $placeholders = array(), $excludes = array(), $includes = array())
 {
     $meta = array_merge($this->meta['default'], $this->meta[$project]);
     $placeholders = array_merge($meta, $placeholders);
     $meta['output'] = $this->realpath_missing($output_file);
     $placeholders['year'] = date('Y');
     $placeholder_keys = array_map(create_function('$x', 'return "{".$x."}";'), array_keys($placeholders));
     $placeholder_values = array_values($placeholders);
     foreach ($meta as $key => $value) {
         $meta[$key] = str_replace($placeholder_keys, $placeholder_values, $value);
     }
     $originals = $this->extractor->extract_from_directory($dir, $excludes, $includes);
     $pot = new PO();
     $pot->entries = $originals->entries;
     $pot->set_header('Project-Id-Version', $meta['package-name'] . ' ' . $meta['package-version']);
     $pot->set_header('Report-Msgid-Bugs-To', $meta['msgid-bugs-address']);
     $pot->set_header('POT-Creation-Date', gmdate('Y-m-d H:i:s+00:00'));
     $pot->set_header('MIME-Version', '1.0');
     $pot->set_header('Content-Type', 'text/plain; charset=UTF-8');
     $pot->set_header('Content-Transfer-Encoding', '8bit');
     $pot->set_header('PO-Revision-Date', date('Y') . '-MO-DA HO:MI+ZONE');
     $pot->set_header('Last-Translator', 'FULL NAME <EMAIL@ADDRESS>');
     $pot->set_header('Language-Team', 'LANGUAGE <LL@li.org>');
     $pot->set_comment_before_headers($meta['comments']);
     $pot->export_to_file($output_file);
     return true;
 }
开发者ID:boonebgorges,项目名称:develop.wordpress,代码行数:27,代码来源:makepot.php

示例2: generate_pot

 /**
  * POT generator
  *
  * @param string $project "woocommerce" or "woocommerce-admin"
  * @return bool true on success, false on error
  */
 public function generate_pot($project = 'woocommerce')
 {
     // Unknown project
     if (empty($this->projects[$project])) {
         return false;
     }
     // Project config
     $config = $this->projects[$project];
     // Extract translatable strings from the WooCommerce plugin
     $originals = $this->extractor->extract_from_directory($this->woocommerce_path, $config['excludes'], $config['includes']);
     // Build POT file
     $pot = new PO();
     $pot->entries = $originals->entries;
     $pot->set_header('Project-Id-Version', 'WooCommerce ' . $this->woocommerce_version() . ' ' . $config['title']);
     $pot->set_header('Report-Msgid-Bugs-To', 'https://github.com/woothemes/woocommerce/issues');
     $pot->set_header('POT-Creation-Date', gmdate('Y-m-d H:i:s+00:00'));
     $pot->set_header('MIME-Version', '1.0');
     $pot->set_header('Content-Type', 'text/plain; charset=UTF-8');
     $pot->set_header('Content-Transfer-Encoding', '8bit');
     $pot->set_header('PO-Revision-Date', gmdate('Y') . '-MO-DA HO:MI+ZONE');
     $pot->set_header('Last-Translator', 'FULL NAME <EMAIL@ADDRESS>');
     $pot->set_header('Language-Team', 'LANGUAGE <EMAIL@ADDRESS>');
     // Write POT file
     $result = $pot->export_to_file($config['file']);
     // Add plugin header
     if ($project == 'woocommerce-admin') {
         $potextmeta = new PotExtMeta();
         $potextmeta->append($this->woocommerce_path . 'woocommerce.php', $config['file']);
     }
     return $result;
 }
开发者ID:joshquila,项目名称:demo2-youse,代码行数:37,代码来源:makepot.php

示例3: PO

 function test_export_to_file()
 {
     $po = new PO();
     $entry = new Translation_Entry(array('singular' => 'baba'));
     $entry2 = new Translation_Entry(array('singular' => 'dyado'));
     $po->set_header('Project-Id-Version', 'WordPress 2.6-bleeding');
     $po->set_header('POT-Creation-Date', '2008-04-08 18:00+0000');
     $po->add_entry($entry);
     $po->add_entry($entry2);
     $temp_fn = $this->temp_filename();
     $po->export_to_file($temp_fn, false);
     $this->assertEquals($po->export(false), file_get_contents($temp_fn));
     $temp_fn2 = $this->temp_filename();
     $po->export_to_file($temp_fn2);
     $this->assertEquals($po->export(), file_get_contents($temp_fn2));
 }
开发者ID:rmccue,项目名称:GlotPress,代码行数:16,代码来源:test_po.php

示例4: compilePot

 public function compilePot()
 {
     $this->prepareExport();
     $path = $this->getPath();
     $pot_file = $this->getPotFile();
     $this->makePot($path, $pot_file);
     // remove headers
     $po = new \PO();
     $po->import_from_file($pot_file);
     $po->export_to_file($pot_file, false);
 }
开发者ID:wemakecustom,项目名称:wp-pot-generator,代码行数:11,代码来源:Translatable.php

示例5: generate_pot

 /**
  * POT generator
  *
  * @param string $project "redux" or "redux-admin"
  * @return bool true on success, false on error
  */
 public function generate_pot($project = 'redux')
 {
     // Unknown project
     if (empty($this->projects[$project])) {
         return false;
     }
     // Project config
     $config = $this->projects[$project];
     // Extract translatable strings from the ReduxFramework plugin
     $originals = $this->extractor->extract_from_directory($this->redux_path, $config['excludes'], $config['includes']);
     // Build POT file
     $pot = new PO();
     $pot->entries = $originals->entries;
     $pot->set_header('Project-Id-Version', 'Redux Framework ' . $this->redux_version() . ' ' . $config['title']);
     $pot->set_header('Report-Msgid-Bugs-To', 'https://github.com/ReduxFramework/ReduxFramework/issues');
     $pot->set_header('POT-Creation-Date', gmdate('Y-m-d H:i:s+00:00'));
     $pot->set_header('MIME-Version', '1.0');
     $pot->set_header('Content-Type', 'text/plain; charset=UTF-8');
     $pot->set_header('Content-Transfer-Encoding', '8bit');
     $pot->set_header('PO-Revision-Date', gmdate('Y') . '-MO-DA HO:MI+ZONE');
     $pot->set_header('Last-Translator', 'Dovy Paukstys <dovy@reduxframework.com>');
     $pot->set_header('Language-Team', 'ReduxFramework <language@reduxframework.com>');
     $pot->set_header('Language', 'en_US');
     $pot->set_header('Plural-Forms', 'nplurals=2; plural=(n != 1);');
     $pot->set_header('esc_html_x;_c;_nc', '');
     $pot->set_header('_nx_noop;_ex;esc_attr__;esc_attr_e;esc_attr_x;esc_html__;esc_html_e;', '');
     $pot->set_header('X-Poedit-KeywordsList', '__;_e;__ngettext;_n;__ngettext_noop;_n_noop;_x;_nx;');
     $pot->set_header('X-Poedit-Basepath', '../../');
     $pot->set_header('X-Poedit-SourceCharset', 'UTF-8');
     $pot->set_header('X-Poedit-SearchPath-0', 'ReduxCore');
     $pot->set_header('X-Poedit-SearchPath-1', 'ReduxCore/languages');
     $pot->set_header('X-Poedit-SearchPath-2', '.');
     // Write POT file
     $result = $pot->export_to_file($config['file']);
     // Add plugin header
     if ($project == 'redux-admin') {
         $potextmeta = new PotExtMeta();
         $potextmeta->append($this->redux_path . 'redux-framework.php', $config['file']);
     }
     return $result;
 }
开发者ID:ArgiaCyber,项目名称:alfath,代码行数:47,代码来源:makepot.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


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