-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Decouple Validator from Translation component #15714
Comments
Well, violation constraints are returned translated already (since 2.2). This is why there is a dependency. Previously, there was 2 different ways to access the violation message depending on whether you wanted to use the translation system or no (and 2 different way to build violations depending on whether you wanted to make them compatible with the usage of translations or no) |
Maybe the validator component could have it's own interfaces for it and have a recommended implementation by using the Symfony translations via adapters? Especially when used as component I think this dependency should not be a require, but suggest. |
Note: Drupal is using now a pretty interesting trick. We provide the TranslationInterface in its own folder as part of the Drupal project (together with the LICENSE file) and use a "replace" entry in composer.json to trick composer. Actually something like that could be done as hack for the validator as well, but I agree separating the interface in its own package would be better |
And we realized that this was a horrible idea, because noone else is actually able to depend on a package which actually depend on the translation component and we reverted that. |
@dawehner Very nice idea. Also thought about it a lot. |
…uple symfony/validator from symfony/translation (nicolas-grekas) This PR was merged into the 4.2-dev branch. Discussion ---------- [Contracts] Add Translation\TranslatorInterface + decouple symfony/validator from symfony/translation | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | #15714, #18930 | License | MIT | Doc PR | - Let's decouple Validator from Translation component \o/! TODO: - [x] add `TranslatorInterface`, deprecate it from Translation - [x] add `TranslatorTrait`, deprecating `MessageSelector`, `Internal` and `PluralizationRules` - [x] deprecate `ValidatorBuilderInterface(LegacyTranslatorInterface)` - [x] inject a new `identity_translator` into `translator.formatter.default`, deprecate `translator.selector` - [x] copy tests in the Contracts namespace to ensure the `TranslatorTrait` behaves properly - [x] figure out a way to keep throwing `InvalidArgumentException` from the component - [x] update UPGRADING and CHANGELOG files - [x] polish the deprecation layer (ensure all needed runtime deprecations are here) Reviews welcome already. Commits ------- 064e369 [Contracts] Add Translation\TranslatorInterface + decouple symfony/validator from symfony/translation
Hi.
Some people are wondering why the validator component needs to depend on the translation component and instead could be decoupled?
The text was updated successfully, but these errors were encountered: