<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[18528] trunk/wp-includes/pomo: Sync pomo library with the current GlotPress version</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/18528">18528</a></dd>
<dt>Author</dt> <dd>nbachiyski</dd>
<dt>Date</dt> <dd>2011-08-11 04:29:35 +0000 (Thu, 11 Aug 2011)</dd>
</dl>
<h3>Log Message</h3>
<pre>Sync pomo library with the current GlotPress version</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludespomoentryphp">trunk/wp-includes/pomo/entry.php</a></li>
<li><a href="#trunkwpincludespomomophp">trunk/wp-includes/pomo/mo.php</a></li>
<li><a href="#trunkwpincludespomopophp">trunk/wp-includes/pomo/po.php</a></li>
<li><a href="#trunkwpincludespomostreamsphp">trunk/wp-includes/pomo/streams.php</a></li>
<li><a href="#trunkwpincludespomotranslationsphp">trunk/wp-includes/pomo/translations.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludespomoentryphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/pomo/entry.php (18527 => 18528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/pomo/entry.php        2011-08-11 03:02:01 UTC (rev 18527)
+++ trunk/wp-includes/pomo/entry.php        2011-08-11 04:29:35 UTC (rev 18528)
</span><span class="lines">@@ -2,7 +2,7 @@
</span><span class="cx"> /**
</span><span class="cx"> * Contains Translation_Entry class
</span><span class="cx"> *
</span><del>- * @version $Id: entry.php 406 2010-02-07 11:10:24Z nbachiyski $
</del><ins>+ * @version $Id: entry.php 621 2011-06-13 12:21:50Z nbachiyski $
</ins><span class="cx"> * @package pomo
</span><span class="cx"> * @subpackage entry
</span><span class="cx"> */
</span><span class="lines">@@ -65,5 +65,14 @@
</span><span class="cx">                 // prepend context and EOT, like in MO files
</span><span class="cx">                 return is_null($this->context)? $this->singular : $this->context.chr(4).$this->singular;
</span><span class="cx">         }
</span><ins>+        
+        function merge_with(&$other) {
+                $this->flags = array_unique( array_merge( $this->flags, $other->flags ) );
+                $this->references = array_unique( array_merge( $this->references, $other->references ) );
+                if ( $this->extracted_comments != $other->extracted_comments ) {
+                        $this->extracted_comments .= $other->extracted_comments;
+                }
+                
+        }
</ins><span class="cx"> }
</span><span class="cx"> endif;
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpincludespomomophp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/pomo/mo.php (18527 => 18528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/pomo/mo.php        2011-08-11 03:02:01 UTC (rev 18527)
+++ trunk/wp-includes/pomo/mo.php        2011-08-11 04:29:35 UTC (rev 18528)
</span><span class="lines">@@ -2,7 +2,7 @@
</span><span class="cx"> /**
</span><span class="cx"> * Class for working with MO files
</span><span class="cx"> *
</span><del>- * @version $Id: mo.php 406 2010-02-07 11:10:24Z nbachiyski $
</del><ins>+ * @version $Id: mo.php 602 2011-01-30 12:43:29Z nbachiyski $
</ins><span class="cx"> * @package pomo
</span><span class="cx"> * @subpackage mo
</span><span class="cx"> */
</span><span class="lines">@@ -30,6 +30,20 @@
</span><span class="cx">         function export_to_file($filename) {
</span><span class="cx">                 $fh = fopen($filename, 'wb');
</span><span class="cx">                 if ( !$fh ) return false;
</span><ins>+                $res = $this->export_to_file_handle( $fh );
+                fclose($fh);
+                return $res;
+        }
+        
+        function export() {
+                $tmp_fh = fopen("php://temp", 'r+');
+                if ( !$tmp_fh ) return false;
+                $this->export_to_file_handle( $tmp_fh );
+                rewind( $tmp_fh );
+                return stream_get_contents( $tmp_fh );
+        }
+        
+        function export_to_file_handle($fh) {
</ins><span class="cx">                 $entries = array_filter($this->entries, create_function('$e', 'return !empty($e->translations);'));
</span><span class="cx">                 ksort($entries);
</span><span class="cx">                 $magic = 0x950412de;
</span><span class="lines">@@ -43,7 +57,7 @@
</span><span class="cx">                 fwrite($fh, pack('V*', $magic, $revision, $total, $originals_lenghts_addr,
</span><span class="cx">                         $translations_lenghts_addr, $size_of_hash, $hash_addr));
</span><span class="cx">                 fseek($fh, $originals_lenghts_addr);
</span><del>-
</del><ins>+                
</ins><span class="cx">                 // headers' msgid is an empty string
</span><span class="cx">                 fwrite($fh, pack('VV', 0, $current_addr));
</span><span class="cx">                 $current_addr++;
</span><span class="lines">@@ -55,24 +69,24 @@
</span><span class="cx">                         fwrite($fh, pack('VV', $length, $current_addr));
</span><span class="cx">                         $current_addr += $length + 1; // account for the NULL byte after
</span><span class="cx">                 }
</span><del>-
</del><ins>+                
</ins><span class="cx">                 $exported_headers = $this->export_headers();
</span><span class="cx">                 fwrite($fh, pack('VV', strlen($exported_headers), $current_addr));
</span><span class="cx">                 $current_addr += strlen($exported_headers) + 1;
</span><span class="cx">                 $translations_table = $exported_headers . chr(0);
</span><del>-
</del><ins>+                
</ins><span class="cx">                 foreach($entries as $entry) {
</span><span class="cx">                         $translations_table .= $this->export_translations($entry) . chr(0);
</span><span class="cx">                         $length = strlen($this->export_translations($entry));
</span><span class="cx">                         fwrite($fh, pack('VV', $length, $current_addr));
</span><span class="cx">                         $current_addr += $length + 1;
</span><span class="cx">                 }
</span><del>-
</del><ins>+                
</ins><span class="cx">                 fwrite($fh, $originals_table);
</span><span class="cx">                 fwrite($fh, $translations_table);
</span><del>-                fclose($fh);
</del><ins>+                return true;
</ins><span class="cx">         }
</span><del>-
</del><ins>+        
</ins><span class="cx">         function export_original($entry) {
</span><span class="cx">                 //TODO: warnings for control characters
</span><span class="cx">                 $exported = $entry->singular;
</span><span class="lines">@@ -80,12 +94,12 @@
</span><span class="cx">                 if (!is_null($entry->context)) $exported = $entry->context . chr(4) . $exported;
</span><span class="cx">                 return $exported;
</span><span class="cx">         }
</span><del>-
</del><ins>+        
</ins><span class="cx">         function export_translations($entry) {
</span><span class="cx">                 //TODO: warnings for control characters
</span><span class="cx">                 return implode(chr(0), $entry->translations);
</span><span class="cx">         }
</span><del>-
</del><ins>+        
</ins><span class="cx">         function export_headers() {
</span><span class="cx">                 $exported = '';
</span><span class="cx">                 foreach($this->headers as $header => $value) {
</span><span class="lines">@@ -193,7 +207,7 @@
</span><span class="cx">         /**
</span><span class="cx">          * Build a Translation_Entry from original string and translation strings,
</span><span class="cx">          * found in a MO file
</span><del>-         *
</del><ins>+         *
</ins><span class="cx">          * @static
</span><span class="cx">          * @param string $original original string to translate from MO file. Might contain
</span><span class="cx">          *         0x04 as context separator or 0x00 as singular/plural separator
</span></span></pre></div>
<a id="trunkwpincludespomopophp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/pomo/po.php (18527 => 18528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/pomo/po.php        2011-08-11 03:02:01 UTC (rev 18527)
+++ trunk/wp-includes/pomo/po.php        2011-08-11 04:29:35 UTC (rev 18528)
</span><span class="lines">@@ -2,7 +2,7 @@
</span><span class="cx"> /**
</span><span class="cx"> * Class for working with PO files
</span><span class="cx"> *
</span><del>- * @version $Id: po.php 406 2010-02-07 11:10:24Z nbachiyski $
</del><ins>+ * @version $Id: po.php 589 2010-12-18 01:40:57Z nbachiyski $
</ins><span class="cx"> * @package pomo
</span><span class="cx"> * @subpackage po
</span><span class="cx"> */
</span><span class="lines">@@ -18,8 +18,9 @@
</span><span class="cx"> */
</span><span class="cx"> if ( !class_exists( 'PO' ) ):
</span><span class="cx"> class PO extends Gettext_Translations {
</span><ins>+        
+        var $comments_before_headers = '';
</ins><span class="cx">
</span><del>-
</del><span class="cx">         /**
</span><span class="cx">          * Exports headers to a PO entry
</span><span class="cx">          *
</span><span class="lines">@@ -31,7 +32,11 @@
</span><span class="cx">                         $header_string.= "$header: $value\n";
</span><span class="cx">                 }
</span><span class="cx">                 $poified = PO::poify($header_string);
</span><del>-                return rtrim("msgid \"\"\nmsgstr $poified");
</del><ins>+                if ($this->comments_before_headers)
+                        $before_headers = $this->prepend_each_line(rtrim($this->comments_before_headers)."\n", '# ');
+                else
+                        $before_headers = '';
+                return rtrim("{$before_headers}msgid \"\"\nmsgstr $poified");
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /**
</span><span class="lines">@@ -75,6 +80,15 @@
</span><span class="cx">                 if (false === $res) return false;
</span><span class="cx">                 return fclose($fh);
</span><span class="cx">         }
</span><ins>+        
+        /**
+         * Text to include as a comment before the start of the PO contents
+         *
+         * Doesn't need to include # in the beginning of lines, these are added automatically
+         */
+        function set_comment_before_headers( $text ) {
+                $this->comments_before_headers = $text;
+        }
</ins><span class="cx">
</span><span class="cx">         /**
</span><span class="cx">          * Formats a string in PO-style
</span><span class="lines">@@ -106,10 +120,10 @@
</span><span class="cx">                 $po = str_replace("$newline$quote$quote", '', $po);
</span><span class="cx">                 return $po;
</span><span class="cx">         }
</span><del>-
</del><ins>+        
</ins><span class="cx">         /**
</span><span class="cx">          * Gives back the original string from a PO-formatted string
</span><del>-         *
</del><ins>+         *
</ins><span class="cx">          * @static
</span><span class="cx">          * @param string $string PO-formatted string
</span><span class="cx">          * @return string enascaped string
</span><span class="lines">@@ -139,7 +153,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /**
</span><del>-         * Inserts $with in the beginning of every new line of $string and
</del><ins>+         * Inserts $with in the beginning of every new line of $string and
</ins><span class="cx">          * returns the modified string
</span><span class="cx">          *
</span><span class="cx">          * @static
</span><span class="lines">@@ -217,7 +231,7 @@
</span><span class="cx">                 PO::read_line($f, 'clear');
</span><span class="cx">                 return $res !== false;
</span><span class="cx">         }
</span><del>-
</del><ins>+        
</ins><span class="cx">         function read_entry($f, $lineno = 0) {
</span><span class="cx">                 $entry = new Translation_Entry();
</span><span class="cx">                 // where were we in the last step
</span><span class="lines">@@ -254,7 +268,7 @@
</span><span class="cx">                                         return false;
</span><span class="cx">                                 }
</span><span class="cx">                                 // add comment
</span><del>-                                $this->add_comment_to_entry($entry, $line);
</del><ins>+                                $this->add_comment_to_entry($entry, $line);;
</ins><span class="cx">                         } elseif (preg_match('/^msgctxt\s+(".*")/', $line, $m)) {
</span><span class="cx">                                 if ($is_final($context)) {
</span><span class="cx">                                         PO::read_line($f, 'put-back');
</span><span class="lines">@@ -322,7 +336,7 @@
</span><span class="cx">                 }
</span><span class="cx">                 return array('entry' => $entry, 'lineno' => $lineno);
</span><span class="cx">         }
</span><del>-
</del><ins>+        
</ins><span class="cx">         function read_line($f, $action = 'read') {
</span><span class="cx">                 static $last_line = '';
</span><span class="cx">                 static $use_last_line = false;
</span><span class="lines">@@ -339,7 +353,7 @@
</span><span class="cx">                 $use_last_line = false;
</span><span class="cx">                 return $line;
</span><span class="cx">         }
</span><del>-
</del><ins>+        
</ins><span class="cx">         function add_comment_to_entry(&$entry, $po_comment_line) {
</span><span class="cx">                 $first_two = substr($po_comment_line, 0, 2);
</span><span class="cx">                 $comment = trim(substr($po_comment_line, 2));
</span><span class="lines">@@ -353,11 +367,11 @@
</span><span class="cx">                         $entry->translator_comments = trim($entry->translator_comments . "\n" . $comment);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-
</del><ins>+        
</ins><span class="cx">         function trim_quotes($s) {
</span><span class="cx">                 if ( substr($s, 0, 1) == '"') $s = substr($s, 1);
</span><span class="cx">                 if ( substr($s, -1, 1) == '"') $s = substr($s, 0, -1);
</span><span class="cx">                 return $s;
</span><span class="cx">         }
</span><span class="cx"> }
</span><del>-endif;
</del><ins>+endif;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpincludespomostreamsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/pomo/streams.php (18527 => 18528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/pomo/streams.php        2011-08-11 03:02:01 UTC (rev 18527)
+++ trunk/wp-includes/pomo/streams.php        2011-08-11 04:29:35 UTC (rev 18528)
</span><span class="lines">@@ -3,26 +3,26 @@
</span><span class="cx"> * Classes, which help reading streams of data from files.
</span><span class="cx"> * Based on the classes from Danilo Segan <danilo@kvota.net>
</span><span class="cx"> *
</span><del>- * @version $Id: streams.php 406 2010-02-07 11:10:24Z nbachiyski $
</del><ins>+ * @version $Id: streams.php 597 2011-01-16 20:14:36Z nbachiyski $
</ins><span class="cx"> * @package pomo
</span><span class="cx"> * @subpackage streams
</span><span class="cx"> */
</span><span class="cx">
</span><span class="cx"> if ( !class_exists( 'POMO_Reader' ) ):
</span><span class="cx"> class POMO_Reader {
</span><del>-
</del><ins>+        
</ins><span class="cx">         var $endian = 'little';
</span><span class="cx">         var $_post = '';
</span><del>-
</del><ins>+        
</ins><span class="cx">         function POMO_Reader() {
</span><span class="cx">                 $this->is_overloaded = ((ini_get("mbstring.func_overload") & 2) != 0) && function_exists('mb_substr');
</span><span class="cx">                 $this->_pos = 0;
</span><span class="cx">         }
</span><del>-
</del><ins>+        
</ins><span class="cx">         /**
</span><span class="cx">          * Sets the endianness of the file.
</span><span class="cx">          *
</span><del>-         * @param string $endian 'big' or 'little'
</del><ins>+         * @param $endian string 'big' or 'little'
</ins><span class="cx">          */
</span><span class="cx">         function setEndian($endian) {
</span><span class="cx">                 $this->endian = $endian;
</span><span class="lines">@@ -57,8 +57,8 @@
</span><span class="cx">                 $endian_letter = ('big' == $this->endian)? 'N' : 'V';
</span><span class="cx">                 return unpack($endian_letter.$count, $bytes);
</span><span class="cx">         }
</span><del>-
-
</del><ins>+        
+        
</ins><span class="cx">         function substr($string, $start, $length) {
</span><span class="cx">                 if ($this->is_overloaded) {
</span><span class="cx">                         return mb_substr($string, $start, $length, 'ascii');
</span><span class="lines">@@ -66,7 +66,7 @@
</span><span class="cx">                         return substr($string, $start, $length);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-
</del><ins>+        
</ins><span class="cx">         function strlen($string) {
</span><span class="cx">                 if ($this->is_overloaded) {
</span><span class="cx">                         return mb_strlen($string, 'ascii');
</span><span class="lines">@@ -74,7 +74,7 @@
</span><span class="cx">                         return strlen($string);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-
</del><ins>+        
</ins><span class="cx">         function str_split($string, $chunk_size) {
</span><span class="cx">                 if (!function_exists('str_split')) {
</span><span class="cx">                         $length = $this->strlen($string);
</span><span class="lines">@@ -86,8 +86,8 @@
</span><span class="cx">                         return str_split( $string, $chunk_size );
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-
-
</del><ins>+        
+                
</ins><span class="cx">         function pos() {
</span><span class="cx">                 return $this->_pos;
</span><span class="cx">         }
</span><span class="lines">@@ -95,7 +95,7 @@
</span><span class="cx">         function is_resource() {
</span><span class="cx">                 return true;
</span><span class="cx">         }
</span><del>-
</del><ins>+        
</ins><span class="cx">         function close() {
</span><span class="cx">                 return true;
</span><span class="cx">         }
</span><span class="lines">@@ -106,13 +106,13 @@
</span><span class="cx"> class POMO_FileReader extends POMO_Reader {
</span><span class="cx">         function POMO_FileReader($filename) {
</span><span class="cx">                 parent::POMO_Reader();
</span><del>-                $this->_f = fopen($filename, 'r');
</del><ins>+                $this->_f = fopen($filename, 'rb');
</ins><span class="cx">         }
</span><del>-
</del><ins>+        
</ins><span class="cx">         function read($bytes) {
</span><span class="cx">                 return fread($this->_f, $bytes);
</span><span class="cx">         }
</span><del>-
</del><ins>+        
</ins><span class="cx">         function seekto($pos) {
</span><span class="cx">                 if ( -1 == fseek($this->_f, $pos, SEEK_SET)) {
</span><span class="cx">                         return false;
</span><span class="lines">@@ -120,19 +120,19 @@
</span><span class="cx">                 $this->_pos = $pos;
</span><span class="cx">                 return true;
</span><span class="cx">         }
</span><del>-
</del><ins>+        
</ins><span class="cx">         function is_resource() {
</span><span class="cx">                 return is_resource($this->_f);
</span><span class="cx">         }
</span><del>-
</del><ins>+        
</ins><span class="cx">         function feof() {
</span><span class="cx">                 return feof($this->_f);
</span><span class="cx">         }
</span><del>-
</del><ins>+        
</ins><span class="cx">         function close() {
</span><span class="cx">                 return fclose($this->_f);
</span><span class="cx">         }
</span><del>-
</del><ins>+        
</ins><span class="cx">         function read_all() {
</span><span class="cx">                 $all = '';
</span><span class="cx">                 while ( !$this->feof() )
</span><span class="lines">@@ -148,9 +148,9 @@
</span><span class="cx"> * of a physical file.
</span><span class="cx"> */
</span><span class="cx"> class POMO_StringReader extends POMO_Reader {
</span><del>-
</del><ins>+        
</ins><span class="cx">         var $_str = '';
</span><del>-
</del><ins>+        
</ins><span class="cx">         function POMO_StringReader($str = '') {
</span><span class="cx">                 parent::POMO_Reader();
</span><span class="cx">                 $this->_str = $str;
</span><span class="lines">@@ -178,7 +178,7 @@
</span><span class="cx">         function read_all() {
</span><span class="cx">                 return $this->substr($this->_str, $this->_pos, $this->strlen($this->_str));
</span><span class="cx">         }
</span><del>-
</del><ins>+        
</ins><span class="cx"> }
</span><span class="cx"> endif;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpincludespomotranslationsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/pomo/translations.php (18527 => 18528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/pomo/translations.php        2011-08-11 03:02:01 UTC (rev 18527)
+++ trunk/wp-includes/pomo/translations.php        2011-08-11 04:29:35 UTC (rev 18528)
</span><span class="lines">@@ -2,7 +2,7 @@
</span><span class="cx"> /**
</span><span class="cx"> * Class for a set of entries for translation and their associated headers
</span><span class="cx"> *
</span><del>- * @version $Id: translations.php 406 2010-02-07 11:10:24Z nbachiyski $
</del><ins>+ * @version $Id: translations.php 590 2010-12-20 19:58:37Z nbachiyski $
</ins><span class="cx"> * @package pomo
</span><span class="cx"> * @subpackage translations
</span><span class="cx"> */
</span><span class="lines">@@ -29,6 +29,19 @@
</span><span class="cx">                 $this->entries[$key] = &$entry;
</span><span class="cx">                 return true;
</span><span class="cx">         }
</span><ins>+        
+        function add_entry_or_merge($entry) {
+                if (is_array($entry)) {
+                        $entry = new Translation_Entry($entry);
+                }
+                $key = $entry->key();
+                if (false === $key) return false;
+                if (isset($this->entries[$key]))
+                        $this->entries[$key]->merge_with($entry);
+                else
+                        $this->entries[$key] = &$entry;
+                return true;
+        }
</ins><span class="cx">
</span><span class="cx">         /**
</span><span class="cx">          * Sets $header PO header to $value
</span><span class="lines">@@ -108,6 +121,15 @@
</span><span class="cx">                         $this->entries[$entry->key()] = $entry;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><ins>+        
+        function merge_originals_with(&$other) {
+                foreach( $other->entries as $entry ) {
+                        if ( !isset( $this->entries[$entry->key()] ) )
+                                $this->entries[$entry->key()] = $entry;
+                        else
+                                $this->entries[$entry->key()]->merge_with($entry);
+                }
+        }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> class Gettext_Translations extends Translations {
</span><span class="lines">@@ -126,7 +148,7 @@
</span><span class="cx">                 }
</span><span class="cx">                 return call_user_func($this->_gettext_select_plural_form, $count);
</span><span class="cx">         }
</span><del>-
</del><ins>+        
</ins><span class="cx">         function nplurals_and_expression_from_header($header) {
</span><span class="cx">                 if (preg_match('/^\s*nplurals\s*=\s*(\d+)\s*;\s+plural\s*=\s*(.+)$/', $header, $matches)) {
</span><span class="cx">                         $nplurals = (int)$matches[1];
</span><span class="lines">@@ -152,7 +174,7 @@
</span><span class="cx">         /**
</span><span class="cx">          * Adds parantheses to the inner parts of ternary operators in
</span><span class="cx">          * plural expressions, because PHP evaluates ternary oerators from left to right
</span><del>-         *
</del><ins>+         *
</ins><span class="cx">          * @param string $expression the expression without parentheses
</span><span class="cx">          * @return string the expression with parentheses added
</span><span class="cx">          */
</span><span class="lines">@@ -180,7 +202,7 @@
</span><span class="cx">                 }
</span><span class="cx">                 return rtrim($res, ';');
</span><span class="cx">         }
</span><del>-
</del><ins>+        
</ins><span class="cx">         function make_headers($translation) {
</span><span class="cx">                 $headers = array();
</span><span class="cx">                 // sometimes \ns are used instead of real new lines
</span><span class="lines">@@ -193,7 +215,7 @@
</span><span class="cx">                 }
</span><span class="cx">                 return $headers;
</span><span class="cx">         }
</span><del>-
</del><ins>+        
</ins><span class="cx">         function set_header($header, $value) {
</span><span class="cx">                 parent::set_header($header, $value);
</span><span class="cx">                 if ('Plural-Forms' == $header) {
</span><span class="lines">@@ -212,7 +234,7 @@
</span><span class="cx"> class NOOP_Translations {
</span><span class="cx">         var $entries = array();
</span><span class="cx">         var $headers = array();
</span><del>-
</del><ins>+        
</ins><span class="cx">         function add_entry($entry) {
</span><span class="cx">                 return true;
</span><span class="cx">         }
</span></span></pre>
</div>
</div>
</body>
</html>