I'm early in a project and I've created some basic functionality, including a custom callback validator (validates end date is after start date). I've since started refactoring to enable translation. I've so far had no issues... until I started looking at translating my custom callback validation.
I read a post online that claimed that I could put my translation key value as my error message and Symfony will automatically translate... but this doesn't seem to be the case for me. Can someone tell me how, or provide a link to documentation, to enable translations in my custom validations?
Here's my current validation code with the translation key included:
<?php
namespace CG5\BFG\CoreBundle\Validators;
use Symfony\Component\Validator\ExecutionContext;
class EndDateValidator
{
static public function isEndDateValid($entity, ExecutionContext $context)
{
if ($entity->getEndDate() <= $entity->getStartDate())
$context->addViolationAtSubPath('endDate', 'validation.invalid.enddate', array(), null);
}
}