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

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

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

Comments

Projects
None yet
2 participants
@RalfEggert
Contributor

RalfEggert commented Dec 19, 2015

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

This comment has been minimized.

Member

Maks3w commented Dec 19, 2015

Segregation of Interfaces and remove the i18n dependency

@RalfEggert

This comment has been minimized.

Contributor

RalfEggert commented Dec 19, 2015

Please clarify! I don't get it.

@Maks3w

This comment has been minimized.

Member

Maks3w commented Dec 19, 2015

@Maks3w Maks3w closed this Dec 19, 2015

@RalfEggert

This comment has been minimized.

Contributor

RalfEggert commented Dec 19, 2015

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

@Maks3w

This comment has been minimized.

Member

Maks3w commented Dec 19, 2015

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

@RalfEggert

This comment has been minimized.

Contributor

RalfEggert commented Dec 19, 2015

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

This comment has been minimized.

Member

Maks3w commented Dec 19, 2015

This may suffer changes in future releases #24

@RalfEggert

This comment has been minimized.

Contributor

RalfEggert commented Dec 19, 2015

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment