Changeset 47122 for trunk/src/wp-includes/pomo/mo.php
- Timestamp:
- 01/29/2020 12:43:23 AM (6 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/pomo/mo.php (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/pomo/mo.php
r44336 r47122 102 102 $magic = 0x950412de; 103 103 $revision = 0; 104 $total = count( $entries ) + 1; // all the headers are one entry104 $total = count( $entries ) + 1; // All the headers are one entry. 105 105 $originals_lenghts_addr = 28; 106 106 $translations_lenghts_addr = $originals_lenghts_addr + 8 * $total; … … 123 123 fseek( $fh, $originals_lenghts_addr ); 124 124 125 // headers' msgid is an empty string125 // Headers' msgid is an empty string. 126 126 fwrite( $fh, pack( 'VV', 0, $current_addr ) ); 127 127 $current_addr++; … … 134 134 $length = $reader->strlen( $this->export_original( $entry ) ); 135 135 fwrite( $fh, pack( 'VV', $length, $current_addr ) ); 136 $current_addr += $length + 1; // account for the NULL byte after136 $current_addr += $length + 1; // Account for the NULL byte after. 137 137 } 138 138 … … 159 159 */ 160 160 function export_original( $entry ) { 161 // TODO: warnings for control characters161 // TODO: Warnings for control characters. 162 162 $exported = $entry->singular; 163 163 if ( $entry->is_plural ) { … … 175 175 */ 176 176 function export_translations( $entry ) { 177 // TODO: warnings for control characters177 // TODO: Warnings for control characters. 178 178 return $entry->is_plural ? implode( "\0", $entry->translations ) : $entry->translations[0]; 179 179 } … … 195 195 */ 196 196 function get_byteorder( $magic ) { 197 // The magic is 0x950412de 197 // The magic is 0x950412de. 198 198 199 199 // bug in PHP 5.0.2, see https://savannah.nongnu.org/bugs/?func=detailitem&item_id=10565 … … 229 229 } 230 230 231 // parse header231 // Parse header. 232 232 $header = unpack( "{$endian}revision/{$endian}total/{$endian}originals_lenghts_addr/{$endian}translations_lenghts_addr/{$endian}hash_length/{$endian}hash_addr", $header ); 233 233 if ( ! is_array( $header ) ) { … … 235 235 } 236 236 237 // support revision 0 of MO format specs, only237 // Support revision 0 of MO format specs, only. 238 238 if ( $header['revision'] != 0 ) { 239 239 return false; 240 240 } 241 241 242 // seek to data blocks242 // Seek to data blocks. 243 243 $reader->seekto( $header['originals_lenghts_addr'] ); 244 244 245 // read originals' indices245 // Read originals' indices. 246 246 $originals_lengths_length = $header['translations_lenghts_addr'] - $header['originals_lenghts_addr']; 247 247 if ( $originals_lengths_length != $header['total'] * 8 ) { … … 254 254 } 255 255 256 // read translations' indices256 // Read translations' indices. 257 257 $translations_lenghts_length = $header['hash_addr'] - $header['translations_lenghts_addr']; 258 258 if ( $translations_lenghts_length != $header['total'] * 8 ) { … … 265 265 } 266 266 267 // transform raw data into set of indices267 // Transform raw data into set of indices. 268 268 $originals = $reader->str_split( $originals, 8 ); 269 269 $translations = $reader->str_split( $translations, 8 ); 270 270 271 // skip hash table271 // Skip hash table. 272 272 $strings_addr = $header['hash_addr'] + $header['hash_length'] * 4; 273 273 … … 284 284 } 285 285 286 // adjust offset due to reading strings to separate space before286 // Adjust offset due to reading strings to separate space before. 287 287 $o['pos'] -= $strings_addr; 288 288 $t['pos'] -= $strings_addr; … … 320 320 $entry->context = $parts[0]; 321 321 } 322 // look for plural original322 // Look for plural original. 323 323 $parts = explode( "\0", $original ); 324 324 $entry->singular = $parts[0]; … … 327 327 $entry->plural = $parts[1]; 328 328 } 329 // plural translations are also separated by \0329 // Plural translations are also separated by \0. 330 330 $entry->translations = explode( "\0", $translation ); 331 331 return $entry;
Note: See TracChangeset
for help on using the changeset viewer.