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

Any way to use translator service for localizing error messages #672

Closed
Svel opened this issue Jan 23, 2014 · 7 comments
Closed

Any way to use translator service for localizing error messages #672

Svel opened this issue Jan 23, 2014 · 7 comments

Comments

@Svel
Copy link

Svel commented Jan 23, 2014

"You do not have the necessary permissions" and "You are not authenticated".

@willdurand
Copy link
Member

👍

@lsmith77
Copy link
Member

you mean in the exception handler?

@Svel
Copy link
Author

Svel commented Jan 23, 2014

Somewhere from Controller\ExceptionController --> fos_rest.view.exception_wrapper_handler --> till ViewHandler::handle() and ViewHandler::initResponse()

can't explain better, sorry :/

PS: TY @willdurand for http://williamdurand.fr/2012/08/02/rest-apis-with-symfony2-the-right-way/ :)

@lsmith77
Copy link
Member

Are we talking about simply adding support for the translator in https://github.com/FriendsOfSymfony/FOSRestBundle/blob/master/Controller/ExceptionController.php#L171 ?

I guess it should not be too hard to make it an option and then inject the translator.

@stof
Copy link
Member

stof commented Jan 23, 2014

@lsmith77 since Symfony 2.2, the security component provide a translation key for its exception, with a message which is safe to be displayed (i.e. not leaking infos about table names because of a bad SQL query). For them, it would make sense to use this message and to translate it: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Security/Core/Exception/AuthenticationException.php#L68-86 (the translations are available in the security domain)

@lsmith77 lsmith77 added this to the 2.0 milestone Jul 10, 2015
@lsmith77 lsmith77 modified the milestone: 2.0 Nov 10, 2015
@GuilhemN
Copy link
Member

GuilhemN commented Mar 6, 2016

Should be easy to implement with #1358

@xabbuh
Copy link
Member

xabbuh commented May 16, 2016

Closing here as this should now be easy to handle with #1358 being merged.

@xabbuh xabbuh closed this as completed May 16, 2016
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

6 participants