Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

error on documentation example code #106

Open
igormx opened this issue Jul 20, 2016 · 4 comments
Open

error on documentation example code #106

igormx opened this issue Jul 20, 2016 · 4 comments

Comments

@igormx
Copy link

igormx commented Jul 20, 2016

The section "Using pre-translated validation messages" on the Zend Validator documentaion has the following example:

use Zend\I18n\Translator\Resources;
use Zend\Mvc\I18n\Translator;
use Zend\Validator\AbstractValidator;

$translator = new Zend\Mvc\I18n\Translator();
$translator->addTranslationFilePattern(
    'phpArray',
    Resources::getBasePath(),
    Resources::getPatternForValidator()
);
AbstractValidator::setDefaultTranslator($translator);

Fist Zend\Mvc\I18n\Translator(); needs an I18nTranslatorInterface and that's not documented on this example.

The another problem with this example is that it throws this Exception:

A plugin by the name "phpArray" was not found in the plugin manager Zend\I18n\Translator\LoaderPluginManager

Because the alias for Zend\I18n\Translator\Loader\PhpArray now is "phparray" not "phpArray"

@Chealer
Copy link

Chealer commented Aug 16, 2016

I was going to report the same.
I can get past line 5 replacing it with:
$translator = new Zend\Mvc\I18n\Translator(new Zend\I18n\Translator\Translator());

While this allows the example to run, it does not change the language. And indeed, the example never specifies German.

Yet another problem: the __call() function of Translator (surely used for addTranslationFilePattern()) is marked as deprecated.

@igormx
Copy link
Author

igormx commented Aug 26, 2016

I resolve my issue exactly in the same way than you.

@samsonasik
Copy link
Contributor

phpArray is re-added to zend-i18n src/Translator/LoaderPluginManager.php zendframework/zend-i18n#56

@weierophinney
Copy link
Member

This repository has been closed and moved to laminas/laminas-validator; a new issue has been opened at laminas/laminas-validator#25.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Development

No branches or pull requests

5 participants