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

NotEmpty::IS_EMPTY not translated #71

Closed
bacinsky opened this issue Oct 3, 2015 · 8 comments
Closed

NotEmpty::IS_EMPTY not translated #71

bacinsky opened this issue Oct 3, 2015 · 8 comments

Comments

@bacinsky
Copy link
Contributor

bacinsky commented Oct 3, 2015

How is it possible to translate NotEmpty::IS_EMPTY message?

https://github.com/zendframework/zend-inputfilter/blob/master/src/Input.php#L497

@bogutskyy
Copy link

The same problem. Any ideas?

@bogutskyy
Copy link

And how to set a custom message for required field? Message generate without any validators https://github.com/zendframework/zend-inputfilter/blob/master/src/Input.php#L407.

@bacinsky
Copy link
Contributor Author

bacinsky commented Oct 8, 2015

As a temporary solution I rewrote the class method like this:

protected function prepareRequiredValidationFailureMessage()
    {
        $notEmpty = new NotEmpty();
        $templates = $notEmpty->getOption('messageTemplates');

        $message = $notEmpty->hasTranslator()
                 ? $notEmpty->getTranslator()->translate($templates[NotEmpty::IS_EMPTY])
                 : $templates[NotEmpty::IS_EMPTY];

        return [
            // TODO remove this file
            // @issue message translation fix https://github.com/zendframework/zend-inputfilter/issues/71
            NotEmpty::IS_EMPTY => $message,
        ];
    }

But I think it's even a more mess now.

@svycka
Copy link
Contributor

svycka commented Oct 9, 2015

does this help? #73

@bogutskyy
Copy link

In #73 message still get from templates, without translation.
larsnystrom@4fc84cd#diff-5e41c64803af5c0ad8ad84c3e25c834cR510.

         return [
             NotEmpty::IS_EMPTY => $templates[NotEmpty::IS_EMPTY],

@svycka
Copy link
Contributor

svycka commented Oct 9, 2015

you could set translated message with validator options, but yes this is not perfect.
just as test I created PR larsnystrom#1 could you test with this?

@larsnystrom
Copy link
Contributor

PR #67 addresses this. PR #73 concerns being able to specify any message when the required validation fails.

@FabianKoestring
Copy link

I think this is solved in zendframework/zend-inputfilter (2.7.0).

@Maks3w Maks3w closed this as completed Apr 8, 2016
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

6 participants