Description
Description
In the current symfony documentation ( https://symfony.com/doc/current/validation/translations.html ), it says that we can translate validation constraints by simply adding a translation key in "message" property, then adding this key in a "validators" catalog file.
Nice. But it would be soooo much better, easier and safer it we could generate this file by using the translation:extract
command like for any other translation.
However, according to the translator documentation: https://symfony.com/doc/current/translation.html#extracting-translation-contents-and-updating-catalogs-automatically
The translation:extract command looks for missing translations in:
Templates stored in the templates/ directory (or any other directory defined in the twig.default_path and twig.paths config options);
Any PHP file/class that injects or autowires the translator service and makes calls to the trans() method.
Any PHP file/class stored in the src/ directory that creates Translations using the constructor or the t() method or calls the trans() method.
Therefore, since validator in entities
- are not in
/templates/
- do not inject translator service
- do not call trans() or t()
then these keys are never extracted by the translation:extract
command. And indeed, after trying it in my project, I can confirm they are not.
Could we get a fix for that?
Example
No response