extractor icon indicating copy to clipboard operation
extractor copied to clipboard

Validation translation domain should respect the Translator translationDomain

Open axi opened this issue 6 years ago • 0 comments

string "validators" translation domain should respect the Translator translationDomain witch can be modified through configuration (validator.translation_domain: my_custom_validation_translation_domain).

See in Translation\Extractor\Visitor\Php\Symfony\ValidationAnnotation

    /**
     * @param array $constraints
     */
    private function extractFromConstraints(array $constraints)
    {
        foreach ($constraints as $constraint) {
            $ref = new \ReflectionClass($constraint);
            $defaultValues = $ref->getDefaultProperties();

            $properties = $ref->getProperties();

            foreach ($properties as $property) {
                $propName = $property->getName();

                // If the property ends with 'Message'
                if ('message' === strtolower(substr($propName, -1 * strlen('Message')))) {
                    // If it is different from the default value
                    if ($defaultValues[$propName] !== $constraint->{$propName}) {
                        $this->addLocation($constraint->{$propName}, 0, null, ['domain' => 'validators']);
                    }
                }
            }
        }
    }

Not sure of the best way to do this, any idea ?

axi avatar Nov 22 '19 09:11 axi