Changeset 31498
- Timestamp:
- 02/22/2015 12:46:12 PM (10 years ago)
- Location:
- trunk/tools/i18n
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/i18n/extract.php
r29563 r31498 171 171 } 172 172 if ( T_COMMENT == $id ) { 173 $text = preg_replace( '%^\s+\*\s%m', '', $text ); 174 $text = str_replace( array( "\r\n", "\n" ), ' ', $text );; 173 175 $text = trim( preg_replace( '%^/\*|//%', '', preg_replace( '%\*/$%', '', $text ) ) ); 174 176 if ( 0 === stripos( $text, $this->comment_prefix ) ) { -
trunk/tools/i18n/t/ExtractTest.php
r25920 r31498 135 135 } 136 136 137 /** 138 * @group comment 139 */ 137 140 function test_find_function_calls_with_comment() { 138 141 $this->assertEquals( 139 142 array( array( 'name' => 'f', 'args' => array( 'baba' ), 'line' => 1, 'comment' => 'translators: let your ears fly!' ) ), 140 $this->extractor->find_function_calls( array('f'), '<?php /* translators: let your ears fly! */ f( "baba" ); ' ) ); 143 $this->extractor->find_function_calls( array('f'), '<?php /* translators: let your ears fly! */ f( "baba" ); ' ) 144 ); 141 145 } 142 146 147 /** 148 * @group comment 149 */ 143 150 function test_find_function_calls_with_not_immediate_comment() { 144 151 $this->assertEquals( 145 152 array( array( 'name' => 'f', 'args' => array( 'baba' ), 'line' => 1, 'comment' => 'translators: let your ears fly!' ) ), 146 $this->extractor->find_function_calls( array('f'), '<?php /* translators: let your ears fly! */ $foo = g ( f( "baba" ) ); ' ) ); 153 $this->extractor->find_function_calls( array('f'), '<?php /* translators: let your ears fly! */ $foo = g ( f( "baba" ) ); ' ) 154 ); 147 155 } 148 156 157 /** 158 * @group comment 159 */ 149 160 function test_find_function_calls_with_not_immediate_comment_include_only_latest() { 150 161 $this->assertEquals( 151 162 array( array( 'name' => 'f', 'args' => array( 'baba' ), 'line' => 1, 'comment' => 'translators: let your ears fly!' ) ), 152 $this->extractor->find_function_calls( array('f'), '<?php /* translators: boo */ /* translators: let your ears fly! */ /* baba */ $foo = g ( f( "baba" ) ); ' ) ); 163 $this->extractor->find_function_calls( array('f'), '<?php /* translators: boo */ /* translators: let your ears fly! */ /* baba */ $foo = g ( f( "baba" ) ); ' ) 164 ); 153 165 } 154 166 167 /** 168 * @group comment 169 */ 170 function test_find_function_calls_with_multi_line_comment() { 171 $this->assertEquals( array( array( 172 'name' => '__', 'args' => array( 'on' ), 'line' => 6, 173 'comment' => "Translators: If there are characters in your language that are not supported by Lato, translate this to 'off'. Do not translate into your own language." 174 ) ), 175 $this->extractor->find_function_calls( array( '__' ), 176 "<?php 177 /* 178 * Translators: If there are characters in your language that are not supported 179 * by Lato, translate this to 'off'. Do not translate into your own language. 180 */ 181 __( 'on' );" 182 ) 183 ); 184 } 185 186 /** 187 * @group comment 188 */ 155 189 function test_comment_prefix_should_be_case_insensitive() { 156 190 $this->assertEquals( 157 191 array( array( 'name' => 'f', 'args' => array( 'baba' ), 'line' => 1, 'comment' => 'Translators: let your ears fly!' ) ), 158 $this->extractor->find_function_calls( array('f'), '<?php /* Translators: let your ears fly! */ f( "baba" ); ' ) ); 192 $this->extractor->find_function_calls( array('f'), '<?php /* Translators: let your ears fly! */ f( "baba" ); ' ) 193 ); 159 194 } 160 195 }
Note: See TracChangeset
for help on using the changeset viewer.