Last active
March 9, 2018 23:03
-
-
Save stefanotorresi/13da4d2c8e486927a2f8 to your computer and use it in GitHub Desktop.
adding Zend\Translator resources via zf2 global config, also see http://framework.zend.com/manual/2.3/en/modules/zend.validator.messages.html#using-pre-translated-validation-messages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
return [ | |
// the following assumes that you are using composer | |
// and that your main application entrance point (i.e. public/index.php) changes the working directory | |
// to the one containing the 'vendor' dir, like in ZendSkeletonApplication. | |
'translator' => [ | |
'locale' => 'it', | |
'translation_file_patterns' => [ | |
[ | |
'type' => 'phpArray', | |
'base_dir' => 'vendor/zendframework/zendframework/resources/languages', | |
'pattern' => '%s/Zend_Captcha.php', | |
'text_domain' => 'zend_validate', | |
], | |
[ | |
'type' => 'phpArray', | |
'base_dir' => 'vendor/zendframework/zendframework/resources/languages', | |
'pattern' => '%s/Zend_Validate.php', | |
'text_domain' => 'zend_validate', | |
] | |
], | |
], | |
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Application; | |
use Zend\Mvc\MvcEvent; | |
use Zend\Validator\AbstractValidator; | |
class Module | |
{ | |
public function onBootstrap(MvcEvent $event) | |
{ | |
$application = $event->getApplication(); | |
$serviceManager = $application->getServiceManager(); | |
$translator = $serviceManager->get('translator'); | |
AbstractValidator::setDefaultTranslator($translator, 'zend_validate'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment