Changeset 54959
- Timestamp:
- 12/12/2022 07:37:43 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/pomo/po.php
r54134 r54959 111 111 * Formats a string in PO-style 112 112 * 113 * @param string $ string the string to format113 * @param string $input_string the string to format 114 114 * @return string the poified string 115 115 */ 116 public static function poify( $ string ) {116 public static function poify( $input_string ) { 117 117 $quote = '"'; 118 118 $slash = '\\'; … … 125 125 ); 126 126 127 $ string = str_replace( array_keys( $replaces ), array_values( $replaces ), $string );128 129 $po = $quote . implode( "{$slash}n{$quote}{$newline}{$quote}", explode( $newline, $ string ) ) . $quote;127 $input_string = str_replace( array_keys( $replaces ), array_values( $replaces ), $input_string ); 128 129 $po = $quote . implode( "{$slash}n{$quote}{$newline}{$quote}", explode( $newline, $input_string ) ) . $quote; 130 130 // Add empty string on first line for readbility. 131 if ( false !== strpos( $ string, $newline ) &&132 ( substr_count( $ string, $newline ) > 1 || substr( $string, -strlen( $newline ) ) !== $newline ) ) {131 if ( false !== strpos( $input_string, $newline ) && 132 ( substr_count( $input_string, $newline ) > 1 || substr( $input_string, -strlen( $newline ) ) !== $newline ) ) { 133 133 $po = "$quote$quote$newline$po"; 134 134 } … … 141 141 * Gives back the original string from a PO-formatted string 142 142 * 143 * @param string $ string PO-formatted string143 * @param string $input_string PO-formatted string 144 144 * @return string enascaped string 145 145 */ 146 public static function unpoify( $ string ) {146 public static function unpoify( $input_string ) { 147 147 $escapes = array( 148 148 't' => "\t", … … 151 151 '\\' => '\\', 152 152 ); 153 $lines = array_map( 'trim', explode( "\n", $ string ) );153 $lines = array_map( 'trim', explode( "\n", $input_string ) ); 154 154 $lines = array_map( array( 'PO', 'trim_quotes' ), $lines ); 155 155 $unpoified = ''; … … 179 179 180 180 /** 181 * Inserts $with in the beginning of every new line of $ string and181 * Inserts $with in the beginning of every new line of $input_string and 182 182 * returns the modified string 183 183 * 184 * @param string $ string prepend lines in this string185 * @param string $with prepend lines with this string186 */ 187 public static function prepend_each_line( $ string, $with ) {188 $lines = explode( "\n", $ string );184 * @param string $input_string prepend lines in this string 185 * @param string $with prepend lines with this string 186 */ 187 public static function prepend_each_line( $input_string, $with ) { 188 $lines = explode( "\n", $input_string ); 189 189 $append = ''; 190 if ( "\n" === substr( $ string, -1 ) && '' === end( $lines ) ) {190 if ( "\n" === substr( $input_string, -1 ) && '' === end( $lines ) ) { 191 191 /* 192 * Last line might be empty because $ string was terminated192 * Last line might be empty because $input_string was terminated 193 193 * with a newline, remove it from the $lines array, 194 194 * we'll restore state by re-terminating the string at the end.
Note: See TracChangeset
for help on using the changeset viewer.