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
Comments
👍 |
you mean in the exception handler? |
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/ :) |
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. |
@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 |
Should be easy to implement with #1358 |
Closing here as this should now be easy to handle with #1358 being merged. |
"You do not have the necessary permissions" and "You are not authenticated".
The text was updated successfully, but these errors were encountered: