當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PO::export_entry方法代碼示例

本文整理匯總了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));
    }
開發者ID:boonebgorges,項目名稱:develop.wordpress,代碼行數:50,代碼來源:po.php

示例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;
 }
開發者ID:GautamGupta,項目名稱:glotpress-import-export,代碼行數:15,代碼來源:pot-ext-meta.php

示例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;
 }
開發者ID:rosio,項目名稱:wordpress-i18n-tools,代碼行數:33,代碼來源:NotGettexted.php


注:本文中的PO::export_entry方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。