Skip to content

Commit

Permalink
merged branch fabpot/extrator-fix (PR symfony#8869)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.2 branch.

Discussion
----------

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

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | symfony#8797
| License       | MIT
| Doc PR        | n/a

Commits
-------

4922a80 [FrameworkBundle] added support for double-quoted strings in the extractor (closes symfony#8797)
  • Loading branch information
fabpot committed Aug 28, 2013
2 parents 16b585d + 4922a80 commit 0009deb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -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") ?>
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ protected function parseTokens($tokens, MessageCatalogue $catalog)
}
}

$message = trim($message, '\'');
$message = trim($message, '\'"');

if ($message) {
$catalog->set($message, $this->prefix.$message);
Expand Down

0 comments on commit 0009deb

Please sign in to comment.