Changeset 22349 for trunk/wp-includes/pomo/mo.php
- Timestamp:
- 10/31/2012 10:13:51 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/pomo/mo.php
r21793 r22349 3 3 * Class for working with MO files 4 4 * 5 * @version $Id: mo.php 602 2011-01-30 12:43:29Z nbachiyski $5 * @version $Id: mo.php 718 2012-10-31 00:32:02Z nbachiyski $ 6 6 * @package pomo 7 7 * @subpackage mo … … 35 35 return $res; 36 36 } 37 37 38 38 function export() { 39 39 $tmp_fh = fopen("php://temp", 'r+'); … … 43 43 return stream_get_contents( $tmp_fh ); 44 44 } 45 45 46 function is_entry_good_for_export( $entry ) { 47 if ( empty( $entry->translations ) ) { 48 return false; 49 } 50 51 if ( !array_filter( $entry->translations ) ) { 52 return false; 53 } 54 55 return true; 56 } 57 46 58 function export_to_file_handle($fh) { 47 $entries = array_filter( $this->entries, create_function('$e', 'return !empty($e->translations);'));59 $entries = array_filter( $this->entries, array( $this, 'is_entry_good_for_export' ) ); 48 60 ksort($entries); 49 61 $magic = 0x950412de; … … 58 70 $translations_lenghts_addr, $size_of_hash, $hash_addr)); 59 71 fseek($fh, $originals_lenghts_addr); 60 72 61 73 // headers' msgid is an empty string 62 74 fwrite($fh, pack('VV', 0, $current_addr)); … … 70 82 $current_addr += $length + 1; // account for the NULL byte after 71 83 } 72 84 73 85 $exported_headers = $this->export_headers(); 74 86 fwrite($fh, pack('VV', strlen($exported_headers), $current_addr)); 75 87 $current_addr += strlen($exported_headers) + 1; 76 88 $translations_table = $exported_headers . chr(0); 77 89 78 90 foreach($entries as $entry) { 79 91 $translations_table .= $this->export_translations($entry) . chr(0); … … 82 94 $current_addr += $length + 1; 83 95 } 84 96 85 97 fwrite($fh, $originals_table); 86 98 fwrite($fh, $translations_table); 87 99 return true; 88 100 } 89 101 90 102 function export_original($entry) { 91 103 //TODO: warnings for control characters … … 95 107 return $exported; 96 108 } 97 109 98 110 function export_translations($entry) { 99 111 //TODO: warnings for control characters 100 112 return implode(chr(0), $entry->translations); 101 113 } 102 114 103 115 function export_headers() { 104 116 $exported = ''; … … 196 208 197 209 if ('' === $original) { 198 $headers = $this->make_headers($translation); 199 $this->set_headers($headers); 210 $this->set_headers($this->make_headers($translation)); 200 211 } else { 201 212 $entry = &$this->make_entry($original, $translation); … … 209 220 * Build a Translation_Entry from original string and translation strings, 210 221 * found in a MO file 211 * 222 * 212 223 * @static 213 224 * @param string $original original string to translate from MO file. Might contain
Note: See TracChangeset
for help on using the changeset viewer.