Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0009deb

Browse files
committed
merged branch fabpot/extrator-fix (PR #8869)
This PR was merged into the 2.2 branch. Discussion ---------- [FrameworkBundle] added support for double-quoted strings in the extractor (closes #8797) | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #8797 | License | MIT | Doc PR | n/a Commits ------- 4922a80 [FrameworkBundle] added support for double-quoted strings in the extractor (closes #8797)
2 parents 16b585d + 4922a80 commit 0009deb

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
This template is used for translation message extraction tests
2-
<?php echo $view['translator']->trans('new key') ?>
2+
<?php echo $view['translator']->trans('single-quoted key') ?>
3+
<?php echo $view['translator']->trans("double-quoted key") ?>

src/Symfony/Bundle/FrameworkBundle/Tests/Translation/PhpExtractorTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ public function testExtraction()
2828
$extractor->extract(__DIR__.'/../Fixtures/Resources/views/', $catalogue);
2929

3030
// Assert
31-
$this->assertCount(1, $catalogue->all('messages'), '->extract() should find 1 translation');
32-
$this->assertTrue($catalogue->has('new key'), '->extract() should find at leat "new key" message');
33-
$this->assertEquals('prefixnew key', $catalogue->get('new key'), '->extract() should apply "prefix" as prefix');
31+
$this->assertCount(2, $catalogue->all('messages'), '->extract() should find 1 translation');
32+
$this->assertTrue($catalogue->has('single-quoted key'), '->extract() should find the "single-quoted key" message');
33+
$this->assertTrue($catalogue->has('double-quoted key'), '->extract() should find the "double-quoted key" message');
34+
$this->assertEquals('prefixsingle-quoted key', $catalogue->get('single-quoted key'), '->extract() should apply "prefix" as prefix');
3435
}
3536
}

src/Symfony/Bundle/FrameworkBundle/Translation/PhpExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ protected function parseTokens($tokens, MessageCatalogue $catalog)
111111
}
112112
}
113113

114-
$message = trim($message, '\'');
114+
$message = trim($message, '\'"');
115115

116116
if ($message) {
117117
$catalog->set($message, $this->prefix.$message);

0 commit comments

Comments
 (0)