Changeset 18528 for trunk/wp-includes/pomo/mo.php
- Timestamp:
- 08/11/2011 04:29:35 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/pomo/mo.php
r13830 r18528 3 3 * Class for working with MO files 4 4 * 5 * @version $Id: mo.php 406 2010-02-07 11:10:24Z nbachiyski $5 * @version $Id: mo.php 602 2011-01-30 12:43:29Z nbachiyski $ 6 6 * @package pomo 7 7 * @subpackage mo … … 31 31 $fh = fopen($filename, 'wb'); 32 32 if ( !$fh ) return false; 33 $res = $this->export_to_file_handle( $fh ); 34 fclose($fh); 35 return $res; 36 } 37 38 function export() { 39 $tmp_fh = fopen("php://temp", 'r+'); 40 if ( !$tmp_fh ) return false; 41 $this->export_to_file_handle( $tmp_fh ); 42 rewind( $tmp_fh ); 43 return stream_get_contents( $tmp_fh ); 44 } 45 46 function export_to_file_handle($fh) { 33 47 $entries = array_filter($this->entries, create_function('$e', 'return !empty($e->translations);')); 34 48 ksort($entries); … … 44 58 $translations_lenghts_addr, $size_of_hash, $hash_addr)); 45 59 fseek($fh, $originals_lenghts_addr); 46 60 47 61 // headers' msgid is an empty string 48 62 fwrite($fh, pack('VV', 0, $current_addr)); … … 56 70 $current_addr += $length + 1; // account for the NULL byte after 57 71 } 58 72 59 73 $exported_headers = $this->export_headers(); 60 74 fwrite($fh, pack('VV', strlen($exported_headers), $current_addr)); 61 75 $current_addr += strlen($exported_headers) + 1; 62 76 $translations_table = $exported_headers . chr(0); 63 77 64 78 foreach($entries as $entry) { 65 79 $translations_table .= $this->export_translations($entry) . chr(0); … … 68 82 $current_addr += $length + 1; 69 83 } 70 84 71 85 fwrite($fh, $originals_table); 72 86 fwrite($fh, $translations_table); 73 fclose($fh);74 } 75 87 return true; 88 } 89 76 90 function export_original($entry) { 77 91 //TODO: warnings for control characters … … 81 95 return $exported; 82 96 } 83 97 84 98 function export_translations($entry) { 85 99 //TODO: warnings for control characters 86 100 return implode(chr(0), $entry->translations); 87 101 } 88 102 89 103 function export_headers() { 90 104 $exported = ''; … … 194 208 * Build a Translation_Entry from original string and translation strings, 195 209 * found in a MO file 196 * 210 * 197 211 * @static 198 212 * @param string $original original string to translate from MO file. Might contain
Note: See TracChangeset
for help on using the changeset viewer.