-
-
Notifications
You must be signed in to change notification settings - Fork 59
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
AbstractValidator does not use messageKey when translating messages #1
Comments
@bkilinc can you maybe outline a test case for what you'd like the behavior to be? Originally posted by @Ocramius at zendframework/zend-validator#260 (comment) |
I want to use something like this as a translator object. This is not possible, because AbstractValidator does not pass messageKey to translator object. class myTranslator implements \Zend\Validator\Translator\TranslatorInterface
{
protected $translations = [
'dateInvalid' => "Invalid type given. String, integer, array or DateTime expected",
'dateInvalidDate'=> "The input does not appear to be a valid date",
'dateFalseFormat' => "The input does not fit the date format '%format%'",
];
public function translate($messageKey, $textDomain = 'default', $locale = null)
{
return $this->translations[$messageKey];
}
} Originally posted by @bkilinc at zendframework/zend-validator#260 (comment) |
Originally posted by @froschdesign at zendframework/zend-validator#260 (comment) |
Thanks, I was creating my custom validator. I would like to use messageKey for looking up translations, because default message may also change. when I saw Originally posted by @bkilinc at zendframework/zend-validator#260 (comment) |
I am closing it as it is mostly a question and the solution already provided. |
I would like to translate validation messages using
messageKeys
as message strings may change. ButtranslateMessage
inAbstractValidator
does not use$messageKey
parameter for translating, even if it is defined as method parameter. It uses message string to translate.Originally posted by @bkilinc at zendframework/zend-validator#260
The text was updated successfully, but these errors were encountered: