Changeset 47122 for trunk/src/wp-includes/pomo/po.php
- Timestamp:
- 01/29/2020 12:43:23 AM (7 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/pomo/po.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/pomo/po.php
r47060 r47122 49 49 */ 50 50 function export_entries() { 51 // TODO sorting51 // TODO: Sorting. 52 52 return implode( "\n\n", array_map( array( 'PO', 'export_entry' ), $this->entries ) ); 53 53 } … … 118 118 119 119 $po = $quote . implode( "${slash}n$quote$newline$quote", explode( $newline, $string ) ) . $quote; 120 // add empty string on first line for readbility120 // Add empty string on first line for readbility. 121 121 if ( false !== strpos( $string, $newline ) && 122 122 ( substr_count( $string, $newline ) > 1 || ! ( $newline === substr( $string, -strlen( $newline ) ) ) ) ) { 123 123 $po = "$quote$quote$newline$po"; 124 124 } 125 // remove empty strings125 // Remove empty strings. 126 126 $po = str_replace( "$newline$quote$quote", '', $po ); 127 127 return $po; … … 162 162 } 163 163 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. 165 165 $unpoified = str_replace( array( "\r\n", "\r" ), "\n", $unpoified ); 166 166 … … 179 179 $append = ''; 180 180 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 */ 184 186 array_pop( $lines ); 185 187 $append = "\n"; … … 326 328 function read_entry( $f, $lineno = 0 ) { 327 329 $entry = new Translation_Entry(); 328 // where were we in the last step329 // can be: comment, msgctxt, msgid, msgid_plural, msgstr, msgstr_plural330 // Where were we in the last step. 331 // Can be: comment, msgctxt, msgid, msgid_plural, msgstr, msgstr_plural. 330 332 $context = ''; 331 333 $msgstr_index = 0; … … 337 339 if ( self::is_final( $context ) ) { 338 340 break; 339 } elseif ( ! $context ) { // we haven't read a line and eof came341 } elseif ( ! $context ) { // We haven't read a line and EOF came. 340 342 return null; 341 343 } else { … … 351 353 $line = trim( $line ); 352 354 if ( preg_match( '/^#/', $line, $m ) ) { 353 // the comment is the start of a new entry355 // The comment is the start of a new entry. 354 356 if ( self::is_final( $context ) ) { 355 357 PO::read_line( $f, 'put-back' ); … … 357 359 break; 358 360 } 359 // comments have to be at the beginning361 // Comments have to be at the beginning. 360 362 if ( $context && $context != 'comment' ) { 361 363 return false; 362 364 } 363 // add comment365 // Add comment. 364 366 $this->add_comment_to_entry( $entry, $line ); 365 367 } elseif ( preg_match( '/^msgctxt\s+(".*")/', $line, $m ) ) {
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)