WordPress.org

Make WordPress Core


Ignore:
Timestamp:
01/29/2020 12:43:23 AM (13 months 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/po.php

    r47060 r47122  
    4949         */
    5050        function export_entries() {
    51             //TODO sorting
     51            // TODO: Sorting.
    5252            return implode( "\n\n", array_map( array( 'PO', 'export_entry' ), $this->entries ) );
    5353        }
     
    118118
    119119            $po = $quote . implode( "${slash}n$quote$newline$quote", explode( $newline, $string ) ) . $quote;
    120             // add empty string on first line for readbility
     120            // Add empty string on first line for readbility.
    121121            if ( false !== strpos( $string, $newline ) &&
    122122                ( substr_count( $string, $newline ) > 1 || ! ( $newline === substr( $string, -strlen( $newline ) ) ) ) ) {
    123123                $po = "$quote$quote$newline$po";
    124124            }
    125             // remove empty strings
     125            // Remove empty strings.
    126126            $po = str_replace( "$newline$quote$quote", '', $po );
    127127            return $po;
     
    162162            }
    163163
    164             // Standardise the line endings on imported content, technically PO files shouldn't contain \r
     164            // Standardise the line endings on imported content, technically PO files shouldn't contain \r.
    165165            $unpoified = str_replace( array( "\r\n", "\r" ), "\n", $unpoified );
    166166
     
    179179            $append = '';
    180180            if ( "\n" === substr( $string, -1 ) && '' === end( $lines ) ) {
    181                 // Last line might be empty because $string was terminated
    182                 // with a newline, remove it from the $lines array,
    183                 // we'll restore state by re-terminating the string at the end
     181                /*
     182                 * Last line might be empty because $string was terminated
     183                 * with a newline, remove it from the $lines array,
     184                 * we'll restore state by re-terminating the string at the end.
     185                 */
    184186                array_pop( $lines );
    185187                $append = "\n";
     
    326328        function read_entry( $f, $lineno = 0 ) {
    327329            $entry = new Translation_Entry();
    328             // where were we in the last step
    329             // can be: comment, msgctxt, msgid, msgid_plural, msgstr, msgstr_plural
     330            // Where were we in the last step.
     331            // Can be: comment, msgctxt, msgid, msgid_plural, msgstr, msgstr_plural.
    330332            $context      = '';
    331333            $msgstr_index = 0;
     
    337339                        if ( self::is_final( $context ) ) {
    338340                            break;
    339                         } elseif ( ! $context ) { // we haven't read a line and eof came
     341                        } elseif ( ! $context ) { // We haven't read a line and EOF came.
    340342                            return null;
    341343                        } else {
     
    351353                $line = trim( $line );
    352354                if ( preg_match( '/^#/', $line, $m ) ) {
    353                     // the comment is the start of a new entry
     355                    // The comment is the start of a new entry.
    354356                    if ( self::is_final( $context ) ) {
    355357                        PO::read_line( $f, 'put-back' );
     
    357359                        break;
    358360                    }
    359                     // comments have to be at the beginning
     361                    // Comments have to be at the beginning.
    360362                    if ( $context && $context != 'comment' ) {
    361363                        return false;
    362364                    }
    363                     // add comment
     365                    // Add comment.
    364366                    $this->add_comment_to_entry( $entry, $line );
    365367                } elseif ( preg_match( '/^msgctxt\s+(".*")/', $line, $m ) ) {
Note: See TracChangeset for help on using the changeset viewer.