本文整理汇总了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}");
}
示例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));
}
示例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);
}
示例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);
}