I translate validation errors with a PHP file and that works fine for eg:
"Invalid type given. String expected" => "Verkeer type opgegevens er wordt tekst verwacht",
But when using a wildcard it does not work:
"The input is less than %min% characters long" => "De input is minder dan %min% karakters",
What is wrong?
I use this settup:
Global.php
'service_manager' => array(
'aliases' => array(
'translator' => 'MvcTranslator',
),
),
module.config.php
'translator' => [
'locale' => 'nl_NL',
'translation_file_patterns' => [
[
'type' => 'phparray',
'base_dir' => 'module/Application/lang',
'pattern' => '%s.php',
],
],
]
nl_NL.php
<?php
return [
// Zend\Authentication\Validator\Authentication
"Invalid identity" => "Invalid identity",
"Identity is ambiguous" => "Identity is ambiguous",
"Invalid password" => "Invalid password",
"Authentication failed" => "Authentication failed",
// Zend\Validator\EmailAddress
"Invalid type given. String expected" => "Invalid type given. String expected",
"The input is not a valid email address. Use the basic format local-part@hostname" => "The input is not a valid email address. Use the basic format local-part@hostname",
"'%hostname%' is not a valid hostname for the email address" => "'%hostname%' is not a valid hostname for the email address",
…
];
Vallidator in Form
$inputFilter->add([
'name' => 'naam',
'required' => true,
'filters' => [
['name' => 'StringTrim'],
['name' => 'StripTags'],
['name' => 'StripNewlines'],
],
'validators' => [
[
'name' => 'StringLength',
'options' => [
'min' => 3,
'max' => 128
],
],
],
]
);