diff --git a/features/makepot.feature b/features/makepot.feature index 1c1913fc..3179eeb7 100644 --- a/features/makepot.feature +++ b/features/makepot.feature @@ -715,6 +715,8 @@ Feature: Generate a POT file of a WordPress project And STDERR should contain: """ Warning: The string "Hello World" has 2 different translator comments. (foo-plugin.php:7) + translators: Translators 1! + Translators: Translators 2! """ Scenario: Does not print a warning when two identical strings have the same translator comment @@ -932,7 +934,7 @@ Feature: Generate a POT file of a WordPress project """ And STDERR should not contain: """ - Warning: The string "Hello World" has 2 different translator comments. (foo-plugin.php:7) + Warning: The string "Hello World" has 2 different translator comments. """ Scenario: Skips excluded folders @@ -3646,7 +3648,7 @@ Feature: Generate a POT file of a WordPress project } } """ - + When I try `wp i18n make-pot foo-theme` Then STDOUT should be: """ diff --git a/src/MakePotCommand.php b/src/MakePotCommand.php index bfe37c61..73e61dc5 100644 --- a/src/MakePotCommand.php +++ b/src/MakePotCommand.php @@ -749,7 +749,7 @@ protected function audit_strings( $translations ) { $references = $translation->getReferences(); // File headers don't have any file references. - $location = $translation->hasReferences() ? '(' . implode( ':', array_shift( $references ) ) . ')' : ''; + $location = $translation->hasReferences() ? '(' . implode( ':', $references[0] ) . ')' : ''; // Check 1: Flag strings with placeholders that should have translator comments. if ( @@ -805,10 +805,11 @@ function ( $comment ) use ( &$unique_comments ) { if ( $comments_count > 1 ) { $message = sprintf( - 'The string "%1$s" has %2$d different translator comments. %3$s', + "The string \"%1\$s\" has %2\$d different translator comments. %3\$s\n%4\$s", $translation->getOriginal(), $comments_count, - $location + $location, + implode( "\n", $unique_comments ) ); WP_CLI::warning( $message ); }