@@ -134,34 +134,14 @@ if (! $validator->isValid('word')) {
134134
135135## Translating messages
136136
137- > ### Translation compatibility
138- >
139- > In versions 2.0 - 2.1, ` Zend\Validator\AbstractValidator ` implemented
140- > ` Zend\I18n\Translator\TranslatorAwareInterface ` and accepted instances of
141- > ` Zend\I18n\Translator\Translator ` . Starting in version 2.2.0, zend-validator
142- > now defines a translator interface, > ` Zend\Validator\Translator\TranslatorInterface ` ,
143- > as well as it's own -aware variant, > ` Zend\Validator\Translator\TranslatorAwareInterface ` .
144- > This was done to reduce dependencies for the component, and follows the
145- > principal of Separated Interfaces.
146- >
147- > The upshot is that if you are migrating from a pre-2.2 version, and receiving
148- > errors indicating that the translator provided does not implement
149- > ` Zend\Validator\Translator\TranslatorInterface ` , you will need to make a
150- > change to your code.
137+ > ### Installation requirements
151138>
152- > An implementation of ` Zend\Validator\Translator\TranslatorInterface ` is
153- > provided in ` Zend\Mvc\I18n\Translator ` , which also extends
154- > ` Zend\I18n\Translator\Translator ` . This version can be instantiated and used
155- > just as the original ` Zend\I18n ` version.
156- >
157- > A new service has also been registered with the MVC, ` MvcTranslator ` , which
158- > will return this specialized, bridge instance.
139+ > The translation of validator messages depends on the zend-i18n component, so
140+ > be sure to have it installed before getting started:
159141>
160- > Most users should see no issues, as ` Zend\Validator\ValidatorPluginManager `
161- > has been modified to use the ` MvcTranslator ` service internally, which is how
162- > most developers were getting the translator instance into validators in the
163- > first place. You will only need to change code if you were manually injecting
164- > the instance previously.
142+ > ``` bash
143+ > $ composer require zendframework/zend-i18n
144+ > ` ` `
165145
166146Validator classes provide a ` setTranslator()` method with which you can specify
167147an instance of ` Zend\V alidator\T ranslator\T ranslatorInterface` which will
@@ -211,3 +191,32 @@ if (! $validator->isTranslatorDisabled()) {
211191It is also possible to use a translator instead of setting own messages with
212192` setMessage()` . But doing so, you should keep in mind, that the translator works
213193also on messages you set your own.
194+
195+ > # ## Translation compatibility
196+ >
197+ > In versions 2.0 - 2.1, ` Zend\V alidator\A bstractValidator` implemented
198+ > ` Zend\I 18n\T ranslator\T ranslatorAwareInterface` and accepted instances of
199+ > ` Zend\I 18n\T ranslator\T ranslator` . Starting in version 2.2.0, zend-validator
200+ > now defines a translator interface, > ` Zend\V alidator\T ranslator\T ranslatorInterface` ,
201+ > as well as it' s own -aware variant, > `Zend\Validator\Translator\TranslatorAwareInterface`.
202+ > This was done to reduce dependencies for the component, and follows the
203+ > principal of Separated Interfaces.
204+ >
205+ > The upshot is that if you are migrating from a pre-2.2 version, and receiving
206+ > errors indicating that the translator provided does not implement
207+ > `Zend\Validator\Translator\TranslatorInterface`, you will need to make a
208+ > change to your code.
209+ >
210+ > An implementation of `Zend\Validator\Translator\TranslatorInterface` is
211+ > provided in `Zend\Mvc\I18n\Translator`, which also extends
212+ > `Zend\I18n\Translator\Translator`. This version can be instantiated and used
213+ > just as the original `Zend\I18n` version.
214+ >
215+ > A new service has also been registered with the MVC, `MvcTranslator`, which
216+ > will return this specialized, bridge instance.
217+ >
218+ > Most users should see no issues, as `Zend\Validator\ValidatorPluginManager`
219+ > has been modified to use the `MvcTranslator` service internally, which is how
220+ > most developers were getting the translator instance into validators in the
221+ > first place. You will only need to change code if you were manually injecting
222+ > the instance previously.
0 commit comments