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


PHP PO::poify方法代码示例

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


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

示例1: export_headers

 /**
  * Exports headers to a PO entry
  *
  * @return string msgid/msgstr PO entry for this PO file headers, doesn't
  *                contain newline at the end
  */
 public function export_headers()
 {
     $header_string = '';
     foreach ($this->headers as $header => $value) {
         $header_string .= "{$header}: {$value}\n";
     }
     $poified = PO::poify($header_string);
     if ($this->comments_before_headers) {
         $before_headers = PO::prepend_each_line(rtrim($this->comments_before_headers) . "\n", '# ');
     } else {
         $before_headers = '';
     }
     return rtrim("{$before_headers}msgid \"\"\nmsgstr {$poified}");
 }
开发者ID:bohwaz,项目名称:featherbb,代码行数:20,代码来源:PO.php

示例2: test_poify

 function test_poify()
 {
     //simple
     $this->assertEquals('"baba"', PO::poify('baba'));
     //long word
     $this->assertEquals($this->po_a90, PO::poify($this->a90));
     // tab
     $this->assertEquals('"ba\\tba"', PO::poify("ba\tba"));
     // do not add leading empty string of one-line string ending on a newline
     $this->assertEquals('"\\\\a\\\\n\\n"', PO::poify("\\a\\n\n"));
     // backslash
     $this->assertEquals('"ba\\\\ba"', PO::poify('ba\\ba'));
     // random wordpress.pot string
     $src = 'Categories can be selectively converted to tags using the <a href="%s">category to tag converter</a>.';
     $this->assertEquals("\"Categories can be selectively converted to tags using the <a href=\\\"%s\\\">category to tag converter</a>.\"", PO::poify($src));
     $this->assertEquals($this->po_mail, PO::poify($this->mail));
 }
开发者ID:rmccue,项目名称:GlotPress,代码行数:17,代码来源:test_po.php

示例3: export_entry

 /**
  * Builds a string from the entry for inclusion in PO file
  *
  * @static
  * @param object &$entry the entry to convert to po string
  * @return string|bool PO-style formatted string for the entry or
  * 	false if the entry is empty
  */
 function export_entry(&$entry)
 {
     if (is_null($entry->singular)) {
         return false;
     }
     $po = array();
     if (!empty($entry->translator_comments)) {
         $po[] = PO::comment_block($entry->translator_comments);
     }
     if (!empty($entry->extracted_comments)) {
         $po[] = PO::comment_block($entry->extracted_comments, '.');
     }
     if (!empty($entry->references)) {
         $po[] = PO::comment_block(implode(' ', $entry->references), ':');
     }
     if (!empty($entry->flags)) {
         $po[] = PO::comment_block(implode(", ", $entry->flags), ',');
     }
     if (!is_null($entry->context)) {
         $po[] = 'msgctxt ' . PO::poify($entry->context);
     }
     $po[] = 'msgid ' . PO::poify($entry->singular);
     if (!$entry->is_plural) {
         $translation = empty($entry->translations) ? '' : $entry->translations[0];
         $po[] = 'msgstr ' . PO::poify($translation);
     } else {
         $po[] = 'msgid_plural ' . PO::poify($entry->plural);
         $translations = empty($entry->translations) ? array('', '') : $entry->translations;
         foreach ($translations as $i => $translation) {
             $po[] = "msgstr[{$i}] " . PO::poify($translation);
         }
     }
     return implode("\n", $po);
 }
开发者ID:mostafiz93,项目名称:PrintfScanf,代码行数:42,代码来源:po.php

示例4: writePot

 /**
  * Write an empty POT file containing all strings found
  *
  * @param string $file File to write to
  */
 public function writePot($file)
 {
     $output = "# Copyright (C) " . date("Y") . " Next Buzz" . PHP_EOL . "msgid \"\"" . PHP_EOL . "msgstr \"\"" . PHP_EOL . "\"Project-Id-Version: buzz-seo\\n\"" . PHP_EOL . "\"POT-Creation-Date: " . date("Y-m-d H:i:sO") . "\\n\"" . PHP_EOL . "\"MIME-Version: 1.0\\n\"" . PHP_EOL . "\"Content-Type: text/plain; charset=UTF-8\\n\"" . PHP_EOL . "\"Content-Transfer-Encoding: 8bit\\n\"" . PHP_EOL . "\"PO-Revision-Date: 2014-MO-DA HO:MI+ZONE\\n\"" . PHP_EOL . "\"Language-Team: Next Buzz, Bas de Kort <bas@nextbuzz.nl>\\n\"" . PHP_EOL . PHP_EOL;
     require_once ABSPATH . '/wp-includes/pomo/po.php';
     $poifyString = new \PO();
     foreach ($this->findings as $translatable => $locations) {
         $output .= "#:";
         foreach ($locations as $line => $location) {
             $output .= " " . $location . ":" . $line;
         }
         $output .= PHP_EOL . "msgid " . $poifyString->poify(StringParser::factory($translatable)->trimMultiline()) . PHP_EOL . "msgstr \"\"" . PHP_EOL . PHP_EOL;
     }
     file_put_contents($file, $output);
 }
开发者ID:nextbuzz,项目名称:buzz-seo,代码行数:19,代码来源:CreatePot.php


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