From 684b992597b4e854e85359cd919c3f9902f58e63 Mon Sep 17 00:00:00 2001 From: "Dominik Schilling (ocean90)" Date: Sun, 22 Feb 2015 12:46:12 +0000 Subject: [PATCH] i18n tools: Improve support for multi-line comments in StringExtractor. props SergeyBiryukov. fixes #30972. git-svn-id: https://develop.svn.wordpress.org/trunk@31498 602fd350-edb4-49c9-b593-d223f7449a82 --- tools/i18n/extract.php | 2 ++ tools/i18n/t/ExtractTest.php | 43 ++++++++++++++++++++++++++++++++---- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/tools/i18n/extract.php b/tools/i18n/extract.php index 59f873a3fd..db0c8b4916 100644 --- a/tools/i18n/extract.php +++ b/tools/i18n/extract.php @@ -170,6 +170,8 @@ class StringExtractor { continue; } if ( T_COMMENT == $id ) { + $text = preg_replace( '%^\s+\*\s%m', '', $text ); + $text = str_replace( array( "\r\n", "\n" ), ' ', $text );; $text = trim( preg_replace( '%^/\*|//%', '', preg_replace( '%\*/$%', '', $text ) ) ); if ( 0 === stripos( $text, $this->comment_prefix ) ) { $latest_comment = $text; diff --git a/tools/i18n/t/ExtractTest.php b/tools/i18n/t/ExtractTest.php index 32f62797e0..25ae44098c 100644 --- a/tools/i18n/t/ExtractTest.php +++ b/tools/i18n/t/ExtractTest.php @@ -134,27 +134,62 @@ class ExtractTest extends PHPUnit_Framework_TestCase { $this->assertEquals( array( array( 'name' => 'f', 'args' => array( null, "baba" ), 'line' => 1 ) ), $this->extractor->find_function_calls( array('f'), 'assertEquals( array( array( 'name' => 'f', 'args' => array( 'baba' ), 'line' => 1, 'comment' => 'translators: let your ears fly!' ) ), - $this->extractor->find_function_calls( array('f'), 'extractor->find_function_calls( array('f'), 'assertEquals( array( array( 'name' => 'f', 'args' => array( 'baba' ), 'line' => 1, 'comment' => 'translators: let your ears fly!' ) ), - $this->extractor->find_function_calls( array('f'), 'extractor->find_function_calls( array('f'), 'assertEquals( array( array( 'name' => 'f', 'args' => array( 'baba' ), 'line' => 1, 'comment' => 'translators: let your ears fly!' ) ), - $this->extractor->find_function_calls( array('f'), 'extractor->find_function_calls( array('f'), 'assertEquals( array( array( + 'name' => '__', 'args' => array( 'on' ), 'line' => 6, + '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." + ) ), + $this->extractor->find_function_calls( array( '__' ), + "assertEquals( array( array( 'name' => 'f', 'args' => array( 'baba' ), 'line' => 1, 'comment' => 'Translators: let your ears fly!' ) ), - $this->extractor->find_function_calls( array('f'), 'extractor->find_function_calls( array('f'), '