PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Using pre-translated validation messages

Zend Framework is shipped with more than 45 different validators with more than 200 failure messages. It can be a tedious task to translate all of these messages. But for your convenience Zend Framework comes with already pre-translated validation messages. You can find them within the path /resources/languages in your Zend Framework installation.

Used path

The resource files are outside of the library path because all of your translations should also be outside of this path.

So to translate all validation messages to German for example, all you have to do is to attach a translator to Zend_Validate using these resource files.

<?php
$translator 
= new Zend_Translate(
    array(
        
'adapter' => 'array',
        
'content' => '/resources/languages',
        
'locale'  => $language,
        
'scan' => Zend_Translate::LOCALE_DIRECTORY
    
)
);
Zend_Validate_Abstract::setDefaultTranslator($translator);

Used translation adapter

As translation adapter Zend Framework chose the array adapter. It is simple to edit and created very fast.

Supported languages

This feature is very young, so the amount of supported languages may not be complete. New languages will be added with each release. Additionally feel free to use the existing resource files to make your own translations.

You could also use these resource files to rewrite existing translations. So you are not in need to create these files manually yourself.

Zend Framework