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


PHP PO::unpoify方法代碼示例

本文整理匯總了PHP中PO::unpoify方法的典型用法代碼示例。如果您正苦於以下問題:PHP PO::unpoify方法的具體用法?PHP PO::unpoify怎麽用?PHP PO::unpoify使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PO的用法示例。


在下文中一共展示了PO::unpoify方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: test_unpoify

	function test_unpoify() {
		$this->assertEquals('baba', @PO::unpoify('"baba"'));
		$this->assertEquals("baba\ngugu", @PO::unpoify('"baba\n"'."\t\t\t\n".'"gugu"'));
		$this->assertEquals($this->a90, @PO::unpoify($this->po_a90));
		$this->assertEquals('\\t\\n', @PO::unpoify('"\\\\t\\\\n"'));
		// wordwrapped
		$this->assertEquals('babadyado', @PO::unpoify("\"\"\n\"baba\"\n\"dyado\""));
		$this->assertEquals($this->mail, @PO::unpoify($this->po_mail));
	}
開發者ID:staylor,項目名稱:develop.svn.wordpress.org,代碼行數:9,代碼來源:po.php

示例2: read_entry

 function read_entry($f, $lineno = 0)
 {
     $entry = new Translation_Entry();
     // where were we in the last step
     // can be: comment, msgctxt, msgid, msgid_plural, msgstr, msgstr_plural
     $context = '';
     $msgstr_index = 0;
     $is_final = create_function('$context', 'return $context == "msgstr" || $context == "msgstr_plural";');
     while (true) {
         $lineno++;
         $line = PO::read_line($f);
         if (!$line) {
             if (feof($f)) {
                 if ($is_final($context)) {
                     break;
                 } elseif (!$context) {
                     // we haven't read a line and eof came
                     return null;
                 } else {
                     return false;
                 }
             } else {
                 return false;
             }
         }
         if ($line == "\n") {
             continue;
         }
         $line = trim($line);
         if (preg_match('/^#/', $line, $m)) {
             // the comment is the start of a new entry
             if ($is_final($context)) {
                 PO::read_line($f, 'put-back');
                 $lineno--;
                 break;
             }
             // comments have to be at the beginning
             if ($context && $context != 'comment') {
                 return false;
             }
             // add comment
             $this->add_comment_to_entry($entry, $line);
         } elseif (preg_match('/^msgctxt\\s+(".*")/', $line, $m)) {
             if ($is_final($context)) {
                 PO::read_line($f, 'put-back');
                 $lineno--;
                 break;
             }
             if ($context && $context != 'comment') {
                 return false;
             }
             $context = 'msgctxt';
             $entry->context .= PO::unpoify($m[1]);
         } elseif (preg_match('/^msgid\\s+(".*")/', $line, $m)) {
             if ($is_final($context)) {
                 PO::read_line($f, 'put-back');
                 $lineno--;
                 break;
             }
             if ($context && $context != 'msgctxt' && $context != 'comment') {
                 return false;
             }
             $context = 'msgid';
             $entry->singular .= PO::unpoify($m[1]);
         } elseif (preg_match('/^msgid_plural\\s+(".*")/', $line, $m)) {
             if ($context != 'msgid') {
                 return false;
             }
             $context = 'msgid_plural';
             $entry->is_plural = true;
             $entry->plural .= PO::unpoify($m[1]);
         } elseif (preg_match('/^msgstr\\s+(".*")/', $line, $m)) {
             if ($context != 'msgid') {
                 return false;
             }
             $context = 'msgstr';
             $entry->translations = array(PO::unpoify($m[1]));
         } elseif (preg_match('/^msgstr\\[(\\d+)\\]\\s+(".*")/', $line, $m)) {
             if ($context != 'msgid_plural' && $context != 'msgstr_plural') {
                 return false;
             }
             $context = 'msgstr_plural';
             $msgstr_index = $m[1];
             $entry->translations[$m[1]] = PO::unpoify($m[2]);
         } elseif (preg_match('/^".*"$/', $line)) {
             $unpoified = PO::unpoify($line);
             switch ($context) {
                 case 'msgid':
                     $entry->singular .= $unpoified;
                     break;
                 case 'msgctxt':
                     $entry->context .= $unpoified;
                     break;
                 case 'msgid_plural':
                     $entry->plural .= $unpoified;
                     break;
                 case 'msgstr':
                     $entry->translations[0] .= $unpoified;
                     break;
                 case 'msgstr_plural':
//.........這裏部分代碼省略.........
開發者ID:mostafiz93,項目名稱:PrintfScanf,代碼行數:101,代碼來源:po.php

示例3: read_entry

	function read_entry($f, $lineno = 0) {
		$entry = new Translation_Entry();
						$context = '';
		$msgstr_index = 0;
		$is_final = create_function('$context', 'return $context == "msgstr" || $context == "msgstr_plural";');
		while (true) {
			$lineno++;
			$line = PO::read_line($f);
			if (!$line)  {
				if (feof($f)) {
					if ($is_final($context))
						break;
					elseif (!$context) 						return null;
					else
						return false;
				} else {
					return false;
				}
			}
			if ($line == "\n") continue;
			$line = trim($line);
			if (preg_match('/^#/', $line, $m)) {
								if ($is_final($context)) {
					PO::read_line($f, 'put-back');
					$lineno--;
					break;
				}
								if ($context && $context != 'comment') {
					return false;
				}
								$this->add_comment_to_entry($entry, $line);
			} elseif (preg_match('/^msgctxt\s+(".*")/', $line, $m)) {
				if ($is_final($context)) {
					PO::read_line($f, 'put-back');
					$lineno--;
					break;
				}
				if ($context && $context != 'comment') {
					return false;
				}
				$context = 'msgctxt';
				$entry->context .= PO::unpoify($m[1]);
			} elseif (preg_match('/^msgid\s+(".*")/', $line, $m)) {
				if ($is_final($context)) {
					PO::read_line($f, 'put-back');
					$lineno--;
					break;
				}
				if ($context && $context != 'msgctxt' && $context != 'comment') {
					return false;
				}
				$context = 'msgid';
				$entry->singular .= PO::unpoify($m[1]);
			} elseif (preg_match('/^msgid_plural\s+(".*")/', $line, $m)) {
				if ($context != 'msgid') {
					return false;
				}
				$context = 'msgid_plural';
				$entry->is_plural = true;
				$entry->plural .= PO::unpoify($m[1]);
			} elseif (preg_match('/^msgstr\s+(".*")/', $line, $m)) {
				if ($context != 'msgid') {
					return false;
				}
				$context = 'msgstr';
				$entry->translations = array(PO::unpoify($m[1]));
			} elseif (preg_match('/^msgstr\[(\d+)\]\s+(".*")/', $line, $m)) {
				if ($context != 'msgid_plural' && $context != 'msgstr_plural') {
					return false;
				}
				$context = 'msgstr_plural';
				$msgstr_index = $m[1];
				$entry->translations[$m[1]] = PO::unpoify($m[2]);
			} elseif (preg_match('/^".*"$/', $line)) {
				$unpoified = PO::unpoify($line);
				switch ($context) {
					case 'msgid':
						$entry->singular .= $unpoified; break;
					case 'msgctxt':
						$entry->context .= $unpoified; break;
					case 'msgid_plural':
						$entry->plural .= $unpoified; break;
					case 'msgstr':
						$entry->translations[0] .= $unpoified; break;
					case 'msgstr_plural':
						$entry->translations[$msgstr_index] .= $unpoified; break;
					default:
						return false;
				}
			} else {
				return false;
			}
		}
		if (array() == array_filter($entry->translations, create_function('$t', 'return $t || "0" === $t;'))) {
			$entry->translations = array();
		}
		return array('entry' => $entry, 'lineno' => $lineno);
	}
開發者ID:pf5512,項目名稱:phpstudy,代碼行數:98,代碼來源:po.php


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