Ticket #17128: 17128.diff
File 17128.diff, 3.6 KB (added by , 6 years ago) |
---|
-
src/wp-includes/pomo/entry.php
81 81 } 82 82 83 83 // Prepend context and EOT, like in MO files 84 $key = ! $this->context ? $this->singular : $this->context . chr( 4 ). $this->singular;84 $key = ! $this->context ? $this->singular : $this->context . "\4" . $this->singular; 85 85 // Standardize on \n line endings 86 86 $key = str_replace( array( "\r\n", "\r" ), "\n", $key ); 87 87 -
src/wp-includes/pomo/mo.php
124 124 // headers' msgid is an empty string 125 125 fwrite( $fh, pack( 'VV', 0, $current_addr ) ); 126 126 $current_addr++; 127 $originals_table = chr( 0 );127 $originals_table = "\0"; 128 128 129 129 $reader = new POMO_Reader(); 130 130 131 131 foreach ( $entries as $entry ) { 132 $originals_table .= $this->export_original( $entry ) . chr( 0 );132 $originals_table .= $this->export_original( $entry ) . "\0"; 133 133 $length = $reader->strlen( $this->export_original( $entry ) ); 134 134 fwrite( $fh, pack( 'VV', $length, $current_addr ) ); 135 135 $current_addr += $length + 1; // account for the NULL byte after … … 138 138 $exported_headers = $this->export_headers(); 139 139 fwrite( $fh, pack( 'VV', $reader->strlen( $exported_headers ), $current_addr ) ); 140 140 $current_addr += strlen( $exported_headers ) + 1; 141 $translations_table = $exported_headers . chr( 0 );141 $translations_table = $exported_headers . "\0"; 142 142 143 143 foreach ( $entries as $entry ) { 144 $translations_table .= $this->export_translations( $entry ) . chr( 0 );144 $translations_table .= $this->export_translations( $entry ) . "\0"; 145 145 $length = $reader->strlen( $this->export_translations( $entry ) ); 146 146 fwrite( $fh, pack( 'VV', $length, $current_addr ) ); 147 147 $current_addr += $length + 1; … … 160 160 //TODO: warnings for control characters 161 161 $exported = $entry->singular; 162 162 if ( $entry->is_plural ) { 163 $exported .= chr( 0 ). $entry->plural;163 $exported .= "\0" . $entry->plural; 164 164 } 165 165 if ( $entry->context ) { 166 $exported = $entry->context . chr( 4 ). $exported;166 $exported = $entry->context . "\4" . $exported; 167 167 } 168 168 return $exported; 169 169 } … … 174 174 */ 175 175 function export_translations( $entry ) { 176 176 //TODO: warnings for control characters 177 return $entry->is_plural ? implode( chr( 0 ), $entry->translations ) : $entry->translations[0];177 return $entry->is_plural ? implode( "\0", $entry->translations ) : $entry->translations[0]; 178 178 } 179 179 180 180 /** … … 310 310 */ 311 311 function &make_entry( $original, $translation ) { 312 312 $entry = new Translation_Entry(); 313 // look for context314 $parts = explode( chr( 4 ), $original );313 // Look for context, separated by \4. 314 $parts = explode( "\4", $original ); 315 315 if ( isset( $parts[1] ) ) { 316 316 $original = $parts[1]; 317 317 $entry->context = $parts[0]; 318 318 } 319 319 // look for plural original 320 $parts = explode( chr( 0 ), $original );320 $parts = explode( "\0", $original ); 321 321 $entry->singular = $parts[0]; 322 322 if ( isset( $parts[1] ) ) { 323 323 $entry->is_plural = true; … … 324 324 $entry->plural = $parts[1]; 325 325 } 326 326 // plural translations are also separated by \0 327 $entry->translations = explode( chr( 0 ), $translation );327 $entry->translations = explode( "\0", $translation ); 328 328 return $entry; 329 329 } 330 330