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

What is the point of Zend\Validator\Translator\TranslatorInterface? #48

Closed
RalfEggert opened this issue Dec 19, 2015 · 8 comments
Closed

Comments

@RalfEggert
Copy link
Contributor

I am just trying to internationalize my Zend\Expressive application and stumbled upon the Zend\Validator\Translator\TranslatorInterface interface, which is checked when I use Zend\Validator\AbstractValidator::setDefaultTranslator() method. I learned now that I cannot use a normal Zend\I18n\Translator\Translator instance. In a Zend\Mvc scenario this issue is solved by the Zend\Mvc\I18n\Translator which uses an Zend\I18n\Translator\Translator instance and implements the Zend\Validator\Translator\TranslatorInterface interface.

It doesn't feel right to use the Zend\Mvc\I18n\Translator within my Zend\Expressive application.

It doesn't feel right to implement a Zend\Expressive\I18n\Translator similar to the Zend\Mvc\I18n\Translator.

What a mess.

So, what is the point of the Zend\Validator\Translator\TranslatorInterface in the first place? The Zend\I18n\Translator\TranslatorInterface has the same method signature for the translate() method except it adds another translatePlural() method to the interface. Why not split Zend\I18n\Translator\TranslatorInterface into two interfaces and kick Zend\Validator\Translator\TranslatorInterface?

Are there any plans to tidy this up? Anyway what about the plans to make the validators stateless and extract the translation part from it? I think both is really needed for a ZF3 release to make translation and validation usable within a Zend\Expressive application.

@Maks3w
Copy link
Member

Maks3w commented Dec 19, 2015

Segregation of Interfaces and remove the i18n dependency

@RalfEggert
Copy link
Contributor Author

Please clarify! I don't get it.

@Maks3w
Copy link
Member

Maks3w commented Dec 19, 2015

@Maks3w Maks3w closed this as completed Dec 19, 2015
@RalfEggert
Copy link
Contributor Author

So the dependency to Zend\I18n was removed to the costs of a Zend\Mvc dependency?

@Maks3w
Copy link
Member

Maks3w commented Dec 19, 2015

Mvc offers a bridge for both interfaces but i18n neither validator depends of Mvc.

@RalfEggert
Copy link
Contributor Author

So in consequence I need to build my own bridge if I want to use the same Translator instance for I18n view helpers and validators if I am in an Zend\Expressive environment and I don't want to use the MVC bridge?

If yes, it still feels kind of awkward...

@Maks3w
Copy link
Member

Maks3w commented Dec 19, 2015

This may suffer changes in future releases #24

@RalfEggert
Copy link
Contributor Author

I love the idea of stateless validators and keeping the whole translation stuff outside of the validator.

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

No branches or pull requests

2 participants