Make WordPress Core


Ignore:
Timestamp:
01/29/2020 12:43:23 AM (6 years ago)
Author:
SergeyBiryukov
Message:

Docs: Improve inline comments per the documentation standards.

Includes minor code layout fixes for better readability.

See #48303.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/pomo/mo.php

    r44336 r47122  
    102102            $magic                     = 0x950412de;
    103103            $revision                  = 0;
    104             $total                     = count( $entries ) + 1; // all the headers are one entry
     104            $total                     = count( $entries ) + 1; // All the headers are one entry.
    105105            $originals_lenghts_addr    = 28;
    106106            $translations_lenghts_addr = $originals_lenghts_addr + 8 * $total;
     
    123123            fseek( $fh, $originals_lenghts_addr );
    124124
    125             // headers' msgid is an empty string
     125            // Headers' msgid is an empty string.
    126126            fwrite( $fh, pack( 'VV', 0, $current_addr ) );
    127127            $current_addr++;
     
    134134                $length           = $reader->strlen( $this->export_original( $entry ) );
    135135                fwrite( $fh, pack( 'VV', $length, $current_addr ) );
    136                 $current_addr += $length + 1; // account for the NULL byte after
     136                $current_addr += $length + 1; // Account for the NULL byte after.
    137137            }
    138138
     
    159159         */
    160160        function export_original( $entry ) {
    161             //TODO: warnings for control characters
     161            // TODO: Warnings for control characters.
    162162            $exported = $entry->singular;
    163163            if ( $entry->is_plural ) {
     
    175175         */
    176176        function export_translations( $entry ) {
    177             //TODO: warnings for control characters
     177            // TODO: Warnings for control characters.
    178178            return $entry->is_plural ? implode( "\0", $entry->translations ) : $entry->translations[0];
    179179        }
     
    195195         */
    196196        function get_byteorder( $magic ) {
    197             // The magic is 0x950412de
     197            // The magic is 0x950412de.
    198198
    199199            // bug in PHP 5.0.2, see https://savannah.nongnu.org/bugs/?func=detailitem&item_id=10565
     
    229229            }
    230230
    231             // parse header
     231            // Parse header.
    232232            $header = unpack( "{$endian}revision/{$endian}total/{$endian}originals_lenghts_addr/{$endian}translations_lenghts_addr/{$endian}hash_length/{$endian}hash_addr", $header );
    233233            if ( ! is_array( $header ) ) {
     
    235235            }
    236236
    237             // support revision 0 of MO format specs, only
     237            // Support revision 0 of MO format specs, only.
    238238            if ( $header['revision'] != 0 ) {
    239239                return false;
    240240            }
    241241
    242             // seek to data blocks
     242            // Seek to data blocks.
    243243            $reader->seekto( $header['originals_lenghts_addr'] );
    244244
    245             // read originals' indices
     245            // Read originals' indices.
    246246            $originals_lengths_length = $header['translations_lenghts_addr'] - $header['originals_lenghts_addr'];
    247247            if ( $originals_lengths_length != $header['total'] * 8 ) {
     
    254254            }
    255255
    256             // read translations' indices
     256            // Read translations' indices.
    257257            $translations_lenghts_length = $header['hash_addr'] - $header['translations_lenghts_addr'];
    258258            if ( $translations_lenghts_length != $header['total'] * 8 ) {
     
    265265            }
    266266
    267             // transform raw data into set of indices
     267            // Transform raw data into set of indices.
    268268            $originals    = $reader->str_split( $originals, 8 );
    269269            $translations = $reader->str_split( $translations, 8 );
    270270
    271             // skip hash table
     271            // Skip hash table.
    272272            $strings_addr = $header['hash_addr'] + $header['hash_length'] * 4;
    273273
     
    284284                }
    285285
    286                 // adjust offset due to reading strings to separate space before
     286                // Adjust offset due to reading strings to separate space before.
    287287                $o['pos'] -= $strings_addr;
    288288                $t['pos'] -= $strings_addr;
     
    320320                $entry->context = $parts[0];
    321321            }
    322             // look for plural original
     322            // Look for plural original.
    323323            $parts           = explode( "\0", $original );
    324324            $entry->singular = $parts[0];
     
    327327                $entry->plural    = $parts[1];
    328328            }
    329             // plural translations are also separated by \0
     329            // Plural translations are also separated by \0.
    330330            $entry->translations = explode( "\0", $translation );
    331331            return $entry;
Note: See TracChangeset for help on using the changeset viewer.