[FrameworkBundle] added support for double-quoted strings in the extractor (closes #8797)

This commit is contained in:
Fabien Potencier 2013-08-28 10:25:32 +02:00
parent 16b585dc6a
commit 4922a80ee5
3 changed files with 7 additions and 5 deletions

View File

@ -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") ?>

View File

@ -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');
}
}

View File

@ -111,7 +111,7 @@ class PhpExtractor implements ExtractorInterface
}
}
$message = trim($message, '\'');
$message = trim($message, '\'"');
if ($message) {
$catalog->set($message, $this->prefix.$message);