web/wp-includes/pomo/mo.php
changeset 194 32102edaa81b
parent 136 bde1974c263b
child 204 09a1c134465b
--- a/web/wp-includes/pomo/mo.php	Thu Sep 16 15:45:36 2010 +0000
+++ b/web/wp-includes/pomo/mo.php	Mon Nov 19 18:26:13 2012 +0100
@@ -2,7 +2,7 @@
 /**
  * Class for working with MO files
  *
- * @version $Id: mo.php 293 2009-11-12 15:43:50Z nbachiyski $
+ * @version $Id: mo.php 602 2011-01-30 12:43:29Z nbachiyski $
  * @package pomo
  * @subpackage mo
  */
@@ -26,10 +26,24 @@
 			return false;
 		return $this->import_from_reader($reader);
 	}
-	
+
 	function export_to_file($filename) {
 		$fh = fopen($filename, 'wb');
 		if ( !$fh ) return false;
+		$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) {
 		$entries = array_filter($this->entries, create_function('$e', 'return !empty($e->translations);'));
 		ksort($entries);
 		$magic = 0x950412de;
@@ -70,7 +84,7 @@
 		
 		fwrite($fh, $originals_table);
 		fwrite($fh, $translations_table);
-		fclose($fh);
+		return true;
 	}
 	
 	function export_original($entry) {
@@ -181,7 +195,8 @@
 			$translation = $reader->substr( $strings, $t['pos'], $t['length'] );
 
 			if ('' === $original) {
-				$this->set_headers($this->make_headers($translation));
+				$headers = $this->make_headers($translation);
+				$this->set_headers($headers);
 			} else {
 				$entry = &$this->make_entry($original, $translation);
 				$this->entries[$entry->key()] = &$entry;
@@ -201,7 +216,7 @@
 	 * 	0x00 as a plural translations separator
 	 */
 	function &make_entry($original, $translation) {
-		$entry = & new Translation_Entry();
+		$entry = new Translation_Entry();
 		// look for context
 		$parts = explode(chr(4), $original);
 		if (isset($parts[1])) {