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)
This commit is contained in:
commit
0009deb055
@ -1,2 +1,3 @@
|
||||
This template is used for translation message extraction tests
|
||||
<?php echo $view['translator']->trans('new key') ?>
|
||||
<?php echo $view['translator']->trans('single-quoted key') ?>
|
||||
<?php echo $view['translator']->trans("double-quoted key") ?>
|
||||
|
@ -28,8 +28,9 @@ class PhpExtractorTest extends TestCase
|
||||
$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');
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ class PhpExtractor implements ExtractorInterface
|
||||
}
|
||||
}
|
||||
|
||||
$message = trim($message, '\'');
|
||||
$message = trim($message, '\'"');
|
||||
|
||||
if ($message) {
|
||||
$catalog->set($message, $this->prefix.$message);
|
||||
|
Reference in New Issue
Block a user