Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error on documentation example code #25

Open
weierophinney opened this issue Dec 31, 2019 · 3 comments
Open

error on documentation example code #25

weierophinney opened this issue Dec 31, 2019 · 3 comments
Assignees
Labels
Bug Something isn't working Documentation

Comments

@weierophinney
Copy link
Member

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"


Originally posted by @igormx at zendframework/zend-validator#106

@weierophinney weierophinney added Bug Something isn't working Documentation labels Dec 31, 2019
@weierophinney
Copy link
Member Author

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.


Originally posted by @Chealer at zendframework/zend-validator#106 (comment)

@weierophinney
Copy link
Member Author

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


Originally posted by @igormx at zendframework/zend-validator#106 (comment)

@weierophinney
Copy link
Member Author

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


Originally posted by @samsonasik at zendframework/zend-validator#106 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Documentation
Projects
None yet
Development

No branches or pull requests

2 participants