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


PHP PO::add_entry方法代码示例

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


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

示例1: PO

 function export_as_po()
 {
     if (!isset($this->project) || !$this->project) {
         $this->project = GP::$project->get($this->project_id);
     }
     // TODO: rename locale column to locale_slug and use freely $this->locale as the locale object
     $locale = GP_Locales::by_slug($this->locale);
     $po = new PO();
     // TODO: add more meta data in the project: language team, report URL
     // TODO: last updated for a translation set
     $po->set_header('PO-Revision-Date', gmdate('Y-m-d H:i:s+0000'));
     $po->set_header('MIME-Version', '1.0');
     $po->set_header('Content-Type', 'text/plain; charset=UTF-8');
     $po->set_header('Content-Transfer-Encoding', '8bit');
     $po->set_header('Plural-Forms', "nplurals={$locale->nplurals}; plural={$locale->plural_expression};");
     $po->set_header('X-Generator', 'GlotPress/' . gp_get_option('version'));
     $entries = GP::$translation->for_translation($this->project, $this, 'no-limit', array('status' => 'current'));
     foreach ($entries as $entry) {
         $po->add_entry($entry);
     }
     $po->set_header('Project-Id-Version', $this->project->name);
     return $po->export();
 }
开发者ID:rmccue,项目名称:GlotPress,代码行数:23,代码来源:translation-set.php

示例2: 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

示例3: update

 /**
  * Update with the provided data.
  *
  * @since 1.0.0
  *
  * @param array $data    The data to update with.
  * @param bool  $replace Optional Replace all headers/entries/metadata with those provided?
  */
 public function update($data, $replace = false)
 {
     // Update headers if present
     if (isset($data['headers'])) {
         if ($replace) {
             // empty all headers
             $this->po->headers = array();
         }
         $this->po->set_headers($data['headers']);
     }
     // Update entries if present
     if (isset($data['entries'])) {
         if ($replace) {
             // empty all entries
             $this->po->entries = array();
         }
         foreach ($data['entries'] as $entry) {
             $this->po->add_entry($entry);
         }
     }
     // Update metadata if present
     if (isset($data['metadata'])) {
         if ($replace) {
             // Delete all properties other than headers or entries
             foreach (get_object_vars($this->po) as $prop => $value) {
                 if ($prop !== 'headers' && $prop !== 'entries') {
                     unset($this->po->{$prop});
                 }
             }
         }
         foreach ($data['metadata'] as $prop => $value) {
             $this->po->{$prop} = $value;
         }
     }
 }
开发者ID:dougwollison,项目名称:pomo-editor,代码行数:43,代码来源:class-pomoeditor-project.php


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