extractor icon indicating copy to clipboard operation
extractor copied to clipboard

The Twig extraction should use the Symfony extractor

Open stof opened this issue 8 years ago • 3 comments

The extractor you wrote misses lots of features of the Symfony Twig bridge:

  • it does not support the trans_choice tag
  • it does not support the trans_default_domain tag

Symfony already maintains a Twig extractor since years, which covers all features listed above, and is kept uptodate for changes in the features. You should use it inside your extractor instead of duplicating the work.

stof avatar Feb 20 '17 10:02 stof

I did not know Symfony had an extractor. Hm, wonder why I missed that.

We should definitely work together then. Thank you!

Nyholm avatar Feb 27 '17 14:02 Nyholm

I've looked into this. Symfonys extractors are located in Symfony\Bundle\FrameworkBundle\Translation and Symfony\Bridge\Twig\Translation.

I would love to use them but I will not pull down the FrameworkBundle and TwigBridge just to use two classes. Is there a way we can work around this?

Nyholm avatar Mar 10 '17 19:03 Nyholm

FrameworkBundle is not necessary for the Twig extractors AFAIK.

The TwigBridge is necessary because it is the one implementing the translation tags. So if the bridge is not installed, there is nothing to extract anyway (and if there is something, you cannot parse the template). So there is no new dependency when using it. You could make it an optional requirement in your composer.json, and register the extractor only when it is available. If the bridge is not there, you know there is nothing to extract anyway.

stof avatar Mar 20 '17 10:03 stof