Make WordPress Core

Changeset 36781


Ignore:
Timestamp:
02/29/2016 08:44:31 PM (9 years ago)
Author:
ocean90
Message:

i18n tools: In StringExtractor don't strip slashes from URLs.

Props SergeyBiryukov, ocean90.
Fixes #36015.

Location:
trunk/tools/i18n
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/i18n/extract.php

    r31498 r36781  
    173173                $text = preg_replace( '%^\s+\*\s%m', '', $text );
    174174                $text = str_replace( array( "\r\n", "\n" ), ' ', $text );;
    175                 $text = trim( preg_replace( '%^/\*|//%', '', preg_replace( '%\*/$%', '', $text ) ) );
     175                $text = trim( preg_replace( '%^(/\*|//)%', '', preg_replace( '%\*/$%', '', $text ) ) );
    176176                if ( 0 === stripos( $text, $this->comment_prefix ) ) {
    177177                    $latest_comment = $text;
  • trunk/tools/i18n/t/ExtractTest.php

    r31498 r36781  
    187187     * @group comment
    188188     */
     189    function test_find_function_calls_with_c_style_comment() {
     190        $this->assertEquals( array( array(
     191                'name' => '__', 'args' => array( 'on' ), 'line' => 3,
     192                'comment' => 'translators: let your ears fly!'
     193            ) ),
     194            $this->extractor->find_function_calls( array( '__' ),
     195                "<?php
     196                // translators: let your ears fly!
     197                __( 'on' );"
     198            )
     199        );
     200    }
     201
     202    /**
     203     * @group comment
     204     */
     205    function test_find_function_calls_with_url_in_comment() {
     206        $this->assertEquals( array( array(
     207                'name' => '__', 'args' => array( 'F j, Y g:i a' ), 'line' => 3,
     208                'comment' => 'translators: localized date and time format, see http://php.net/date'
     209            ) ),
     210            $this->extractor->find_function_calls( array( '__' ),
     211                "<?php
     212                /* translators: localized date and time format, see http://php.net/date */
     213                __( 'F j, Y g:i a' );"
     214            )
     215        );
     216    }
     217
     218    /**
     219     * @group comment
     220     */
    189221    function test_comment_prefix_should_be_case_insensitive() {
    190222        $this->assertEquals(
Note: See TracChangeset for help on using the changeset viewer.