Hi,
you can set the translator for the translation of validator messages in your
Module.php onBootstrap method. Pre translated validator files can be found
for numerous languages in app\vendor\zendframework\zendframework\resources.
Just be careful because not all of them (eg. for es) have been updated to
the current Zend Framework Version. de just works fine. If you copy them
over to your module using /language/de_De_Zend_Validate.php you can use the
following code within you onBootstrap method. The logic will automatically
use the locale which is set for the translator in your module.config. This
translator must be present to work:
Module.php in your module
public function onBootstrap(MvcEvent $e)
{
$app = $e->getApplication();
$sm = $app->getServiceManager();
$resDir = __DIR__ .
'/language/'.$sm->get('translator')->getLocale().'_Zend_Validate.php';
$translator = new
\Zend\I18n\Translator\Translator(array('locale'=>$sm->get('translator')->getLocale()));
$translator->addTranslationFile('phpArray',$resDir,'default',$sm->get('translator')->getLocale());
\Zend\Validator\AbstractValidator::setDefaultTranslator($translator);
}
module.config in the Application module:
'translator' => array(
'locale' => 'de_DE',
'translation_file_patterns' => array(
array(
'type' => 'PhpArray',
'base_dir' => __DIR__ . '/../language',
'pattern' => '%s.php',
),
),
),
--
View this message in context:
http://zend-framework-community.634137.n4.nabble.com/problem-in-translation-in-zend2-beta5-tp4655843p4657808.html
Sent from the Zend Framework mailing list archive at Nabble.com.
--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]