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

Change Language for errors message #623

Closed
FuriosoJack opened this issue Mar 21, 2020 · 3 comments
Closed

Change Language for errors message #623

FuriosoJack opened this issue Mar 21, 2020 · 3 comments

Comments

@FuriosoJack
Copy link

FuriosoJack commented Mar 21, 2020

It would be awesome to be able to set a message translation file or the ConstraintError class can be overwritten to change the messages

@erayd
Copy link
Contributor

erayd commented Mar 22, 2020

@FuriosoJack You are welcome to open a PR that implements this. Note it's a low priority though.

@shmax
Copy link
Collaborator

shmax commented Apr 21, 2020

I don't think there's anything stopping you from doing this already. Each error payload has a meaningful identifier that you can use to map to your own localized strings. Something like this:

foreach(  $validator->getErrors() as $error ) {
    $msgId = "msg_json_schema_error_{$error['constraint']";
    // insert your favorite localization technology here
    echo $i18n->loc($msgId, $error['params'];
}

@DannyvdSluijs
Copy link
Collaborator

@FuriosoJack in an attempt to cleanup this repo we are trying to filter the issues and see which ones might be closed. Is it safe to assume this is a rather old issue, which sadly was left unanswered, and can be closed? Feel free to close it yourself with some comments if helpful.

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

No branches or pull requests

4 participants