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

Skip to content

Commit 83382bc

Browse files
committed
[TwigBridge] fixed the translator extractor that were not trimming the text in trans tags (closes #7056)
Trimming was not done by the extractor but it was the default behavior of the TransNode class. Now, things are consistent between the two.
1 parent d10ad0f commit 83382bc

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public function getExtractData()
6363
array('{{ "new key" | transchoice(1) | upper }}', array('new key' => 'messages')),
6464
array('{{ "new key" | transchoice(1, {}, "domain") }}', array('new key' => 'domain')),
6565
array('{% trans %}new key{% endtrans %}', array('new key' => 'messages')),
66+
array('{% trans %} new key {% endtrans %}', array('new key' => 'messages')),
6667
array('{% trans from "domain" %}new key{% endtrans %}', array('new key' => 'domain')),
6768
array('{% set foo = "new key" | trans %}', array('new key' => 'messages')),
6869
array('{{ 1 ? "new key" | trans : "another key" | trans }}', array('new key' => 'messages', 'another key' => 'messages')),

src/Symfony/Bridge/Twig/Translation/TwigExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ protected function extractTemplate($template, MessageCatalogue $catalogue)
7777
$this->twig->parse($this->twig->tokenize($template));
7878

7979
foreach ($visitor->getMessages() as $message) {
80-
$catalogue->set($message[0], $this->prefix.$message[0], $message[1] ? $message[1] : $this->defaultDomain);
80+
$catalogue->set(trim($message[0]), $this->prefix.trim($message[0]), $message[1] ? $message[1] : $this->defaultDomain);
8181
}
8282

8383
$visitor->disable();

0 commit comments

Comments
 (0)