The Twig extraction should use the Symfony extractor
The extractor you wrote misses lots of features of the Symfony Twig bridge:
- it does not support the
trans_choicetag - it does not support the
trans_default_domaintag
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.
I did not know Symfony had an extractor. Hm, wonder why I missed that.
We should definitely work together then. Thank you!
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?
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.