本文整理汇总了PHP中PO::export_entry方法的典型用法代码示例。如果您正苦于以下问题:PHP PO::export_entry方法的具体用法?PHP PO::export_entry怎么用?PHP PO::export_entry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PO
的用法示例。
在下文中一共展示了PO::export_entry方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PO
function test_export_entry()
{
$po = new PO();
$entry = new Translation_Entry(array('singular' => 'baba'));
$this->assertEquals("msgid \"baba\"\nmsgstr \"\"", $po->export_entry($entry));
// plural
$entry = new Translation_Entry(array('singular' => 'baba', 'plural' => 'babas'));
$this->assertEquals('msgid "baba"
msgid_plural "babas"
msgstr[0] ""
msgstr[1] ""', $po->export_entry($entry));
$entry = new Translation_Entry(array('singular' => 'baba', 'translator_comments' => "baba\ndyado"));
$this->assertEquals('# baba
# dyado
msgid "baba"
msgstr ""', $po->export_entry($entry));
$entry = new Translation_Entry(array('singular' => 'baba', 'extracted_comments' => "baba"));
$this->assertEquals('#. baba
msgid "baba"
msgstr ""', $po->export_entry($entry));
$entry = new Translation_Entry(array('singular' => 'baba', 'extracted_comments' => "baba", 'references' => range(1, 29)));
$this->assertEquals('#. baba
#: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
#: 29
msgid "baba"
msgstr ""', $po->export_entry($entry));
$entry = new Translation_Entry(array('singular' => 'baba', 'translations' => array()));
$this->assertEquals("msgid \"baba\"\nmsgstr \"\"", $po->export_entry($entry));
$entry = new Translation_Entry(array('singular' => 'baba', 'translations' => array('куку', 'буку')));
$this->assertEquals("msgid \"baba\"\nmsgstr \"куку\"", $po->export_entry($entry));
$entry = new Translation_Entry(array('singular' => 'baba', 'plural' => 'babas', 'translations' => array('кукубуку')));
$this->assertEquals('msgid "baba"
msgid_plural "babas"
msgstr[0] "кукубуку"', $po->export_entry($entry));
$entry = new Translation_Entry(array('singular' => 'baba', 'plural' => 'babas', 'translations' => array('кукубуку', 'кукуруку', 'бабаяга')));
$this->assertEquals('msgid "baba"
msgid_plural "babas"
msgstr[0] "кукубуку"
msgstr[1] "кукуруку"
msgstr[2] "бабаяга"', $po->export_entry($entry));
// context
$entry = new Translation_Entry(array('context' => 'ctxt', 'singular' => 'baba', 'plural' => 'babas', 'translations' => array('кукубуку', 'кукуруку', 'бабаяга'), 'flags' => array('fuzzy', 'php-format')));
$this->assertEquals('#, fuzzy, php-format
msgctxt "ctxt"
msgid "baba"
msgid_plural "babas"
msgstr[0] "кукубуку"
msgstr[1] "кукуруку"
msgstr[2] "бабаяга"', $po->export_entry($entry));
}
示例2: load_from_file
function load_from_file($ext_filename)
{
$source = MakePOT::get_first_lines($ext_filename);
$pot = '';
foreach ($this->headers as $header) {
$string = MakePOT::get_addon_header($header, $source);
if (!$string) {
continue;
}
$args = array('singular' => $string, 'extracted_comments' => $header . ' of the plugin/theme');
$entry = new Translation_Entry($args);
$pot .= "\n" . PO::export_entry($entry) . "\n";
}
return $pot;
}
示例3: command_extract
function command_extract()
{
$args = func_get_args();
$pot_filename = $args[0];
if (isset($args[1]) && is_array($args[1])) {
$filenames = $args[1];
} else {
$filenames = array_slice($args, 1);
}
$global_name = '__entries_' . mt_rand(1, 1000);
$GLOBALS[$global_name] = array();
foreach ($filenames as $filename) {
$tokens = token_get_all(file_get_contents($filename));
$aggregator = $this->make_string_aggregator($global_name, $filename);
$this->walk_tokens($tokens, array($this, 'ignore_token'), array($this, 'ignore_token'), $aggregator);
}
$potf = '-' == $pot_filename ? STDOUT : @fopen($pot_filename, 'a');
if (false === $potf) {
$this->cli_die("Couldn't open pot file: {$pot_filename}");
}
foreach ($GLOBALS[$global_name] as $item) {
@(list($string, $comment_id, $filename, $line_number) = $item);
$filename = isset($filename) ? preg_replace('|^\\./|', '', $filename) : '';
$ref_line_number = isset($line_number) ? ":{$line_number}" : '';
$args = array('singular' => $string, 'extracted_comments' => "Not gettexted string {$comment_id}", 'references' => array("{$filename}{$ref_line_number}"));
$entry = new Translation_Entry($args);
fwrite($potf, "\n" . PO::export_entry($entry) . "\n");
}
if ('-' != $pot_filename) {
fclose($potf);
}
return true;
}