Closed nfragnet closed 3 years ago
Constraint messages extraction should only occur on translatable options.
Since this commit https://github.com/schmittjoh/JMSTranslationBundle/commit/60d2d1384bfe2af590ed809f118777bba9007f97 where messages from constraints have been added, every options containing a string or even a integer value is extracted.
Add this line in the tests and make the tests fail and execute phpunit.
phpunit
diff --git a/Tests/Translation/Extractor/File/Fixture/MyFormType.php b/Tests/Translation/Extractor/File/Fixture/MyFormType.php index cda5157..68139f0 100644 --- a/Tests/Translation/Extractor/File/Fixture/MyFormType.php +++ b/Tests/Translation/Extractor/File/Fixture/MyFormType.php @@ -46,6 +46,7 @@ class MyFormType extends AbstractType 'translation_domain' => 'address', 'constraints' => [ new NotBlank(['message' => /** @Desc("You should fill in the street") */ 'form.street.empty_value']), + new Length(['max' => 100]), ], ])
This should not result with an additional translation key "100" but it actually does.
"100"
'messages' => Array ( 'form.street.empty_value' => JMS\TranslationBundle\Model\Message Object (...) 'form.error.password_mismatch' => JMS\TranslationBundle\Model\Message Object (...) + 100 => JMS\TranslationBundle\Model\Message Object (...) ) )
I create a PR to fix it soon.
Expected behavior
Constraint messages extraction should only occur on translatable options.
Actual behavior
Since this commit https://github.com/schmittjoh/JMSTranslationBundle/commit/60d2d1384bfe2af590ed809f118777bba9007f97 where messages from constraints have been added, every options containing a string or even a integer value is extracted.
Steps to reproduce
Add this line in the tests and make the tests fail and execute
phpunit
.This should not result with an additional translation key
"100"
but it actually does.I create a PR to fix it soon.