From 4922a80ee5995b5fca8b02cf67edbfb881474406 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 28 Aug 2013 10:25:32 +0200 Subject: [PATCH] [FrameworkBundle] added support for double-quoted strings in the extractor (closes #8797) --- .../Tests/Fixtures/Resources/views/translation.html.php | 3 ++- .../FrameworkBundle/Tests/Translation/PhpExtractorTest.php | 7 ++++--- .../Bundle/FrameworkBundle/Translation/PhpExtractor.php | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/views/translation.html.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/views/translation.html.php index 48ea9fdb08c9..23631b99435e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/views/translation.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/views/translation.html.php @@ -1,2 +1,3 @@ This template is used for translation message extraction tests -trans('new key') ?> +trans('single-quoted key') ?> +trans("double-quoted key") ?> diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/PhpExtractorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/PhpExtractorTest.php index 4305f0e69c7d..d639f01806a2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/PhpExtractorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/PhpExtractorTest.php @@ -28,8 +28,9 @@ public function testExtraction() $extractor->extract(__DIR__.'/../Fixtures/Resources/views/', $catalogue); // Assert - $this->assertCount(1, $catalogue->all('messages'), '->extract() should find 1 translation'); - $this->assertTrue($catalogue->has('new key'), '->extract() should find at leat "new key" message'); - $this->assertEquals('prefixnew key', $catalogue->get('new key'), '->extract() should apply "prefix" as prefix'); + $this->assertCount(2, $catalogue->all('messages'), '->extract() should find 1 translation'); + $this->assertTrue($catalogue->has('single-quoted key'), '->extract() should find the "single-quoted key" message'); + $this->assertTrue($catalogue->has('double-quoted key'), '->extract() should find the "double-quoted key" message'); + $this->assertEquals('prefixsingle-quoted key', $catalogue->get('single-quoted key'), '->extract() should apply "prefix" as prefix'); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Translation/PhpExtractor.php b/src/Symfony/Bundle/FrameworkBundle/Translation/PhpExtractor.php index 1eb36052b3e9..1b8bfe44a7e2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Translation/PhpExtractor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Translation/PhpExtractor.php @@ -111,7 +111,7 @@ protected function parseTokens($tokens, MessageCatalogue $catalog) } } - $message = trim($message, '\''); + $message = trim($message, '\'"'); if ($message) { $catalog->set($message, $this->prefix.$message);