-
Notifications
You must be signed in to change notification settings - Fork 63
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
Translation reason #202
Comments
Hello, I Was asking myself the same thing. Is it not possible or just no time to do it? |
It's not possible :'( |
Hey guys! You're correct, it's not translated out of the box (yet) unfortunately - I'll try to think about it. But, you don't need to be able to override that exception class to translate the message - just leverage the Symfony Translator component. Let me give you a workaround. First of all, thanks to Maker bundle that generated the actual code in your code base - you can easily tweak it if you need. Open your public function reset(TranslatorInterface $translator, Request $request, UserPasswordHasherInterface $passwordHasher, string $token = null): Response
{
// ...
try {
// ...
} catch (ResetPasswordExceptionInterface $e) {
$this->addFlash('reset_password_error', $translator->trans(sprintf(
'There was a problem validating your reset request - %s',
$e->getReason()
)));
// ...
}
} That's it! That's literally the only workaround you need. Finally, all you need to do is actually translate those complete messages in your translation files, e.g. in my # ...
"There was a problem validating your reset request - The reset password link is invalid. Please try to reset your password again.": Виникла проблема під час перевірки вашого запиту на скидання – посилання для скидання пароля недійсне. Спробуйте скинути пароль ще раз. And so on for other ResetPasswordExceptionInterface possible exception messages, don't forget to prefix all of them with |
Thanks @bocharsky-bw |
Hi,
I have a question, there are possibility to translate the reason that return for exceptions :
ResetPasswordExceptionInterface
ExpiredResetPasswordTokenException
FakeRepositoryException
InvalidResetPasswordTokenException
TooManyPasswordRequestsException
? :)
The text was updated successfully, but these errors were encountered: