I'm writing a complete German application and therefore need to set basically everything to German.
My question: What is the best and easiest way to set for example the form validation to German?
I found this page but couldn't figure out how to get this code working:
Zend_Validate_Abstract::setDefaultTranslator($translate);
Could anyone give me some advice how to use this?
Edit:
Thanks to @Gordon I put the following into my Application/Module.php:
use Zend\I18n\Translator\Translator;
use Zend\Validator\AbstractValidator;
class Module
{
public function onBootstrap(MvcEvent $e)
{
...
$translator = new Translator();
$translator->addTranslationFile(
'phpArray',
'resources/languages/de.php',
'default',
'de_DE'
);
AbstractValidator::setDefaultTranslator($translator);
...
}
Edit 2:
Alright, this is odd. When I set de_DE
I get the message that the de.php file couldn't be opened - which is true because "de" is a folder containing two other PHP files.
Could not open file resources/languages/de.php for reading
Altering the path to the folder or to any existing file within it doesnt help...
When I change the "de_DE" to "de" or "de_de" then nothing happens. No error and English validation errors. Any clues?
The later versions of Zend FW must have translators with specific interfaces.
would become:
Note the
new \Zend\Mvc\I18n\Translator($translator)
Finally I found with help of @Gordon the answer!
I put the following into my Application/Module.php:
Then you need to enable php5-intl. Go to php.ini and enable
extension=php_intl.dll
.Finally I needed to add the full path (starting with vendor) in the funciton provided by Gordon and the docs.
For newest zf2 Version (2.5.0) you have to change the path to Zend_Validate.php to
./vendor/zendframework/zend-i18n-resources/languages/de/Zend_Validate.php
.If you don't want to pile code into onBootstrap and you only need just one language, you can use the configuration file:
Put it into you
module.config.php
for me it works with
'./vendor/zendframework/zendframework/resources/languages/langfolderyouwant/Zend_Validate.php'