Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Translation] Entity constraints are not taken into account in the translation:extract #45039

Open
geoffroyp opened this issue Jan 17, 2022 · 1 comment

Comments

@geoffroyp
Copy link

@geoffroyp geoffroyp commented Jan 17, 2022

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

@ro0NL
Copy link
Contributor

@ro0NL ro0NL commented Jan 17, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants