-
Notifications
You must be signed in to change notification settings - Fork 33
Closed
Description
Might be somewhat related to #125.
The ContainerAwareTrans visitor unconditionally creates a source location, even if the result of getStringArgument is null.
extractor/src/Visitor/Php/Symfony/ContainerAwareTrans.php
Lines 38 to 44 in 82fc51a
| //If $this->get('translator')->trans('foobar') | |
| if ('trans' === $name) { | |
| $label = $this->getStringArgument($node, 0); | |
| $domain = $this->getStringArgument($node, 2); | |
| $this->addLocation($label, $node->getAttribute('startLine'), $node, ['domain' => $domain]); | |
| } |
In my particular case this happens because I concatenate a string with a variable:
$this->translator->trans('message.audit_log.' . $eventType);Which results in the following translation unit being added to my messages.en.xlf:
<unit id="47DEQpj" name="">
<segment>
<source></source>
<target></target>
</segment>
</unit>I believe the $this->addLocation call should be wrapped in an if (null !== $label = $this->getStringArgument($node, 1)), similar to what happens in the FlashMessage visitor:
extractor/src/Visitor/Php/Symfony/FlashMessage.php
Lines 55 to 57 in 82fc51a
| if (null !== $label = $this->getStringArgument($node, 1)) { | |
| $this->addLocation($label, $node->getAttribute('startLine'), $node); | |
| } |
Metadata
Metadata
Assignees
Labels
No labels