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

How translate error messages? #125

Closed
AxelBriche opened this issue Jul 9, 2020 · 8 comments
Closed

How translate error messages? #125

AxelBriche opened this issue Jul 9, 2020 · 8 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@AxelBriche
Copy link

AxelBriche commented Jul 9, 2020

I have this message:

"You have already requested a reset password email. Please check your email or try again soon"

How can I translate that please?
This error message is not inside a translation file.

Thanks.

@kbond
Copy link
Contributor

kbond commented Jul 9, 2020

You would have to translate that message yourself and add to your translation file(s). Then call $translator->trans($e->getReason()); before showing the message (as a flash or in a template).

@weaverryan
Copy link
Contributor

@kbond is exactly correct! In your controller (I'm assuming you used MakerBundle to generate your setup), in a try/catch you are passed a ResetPasswordExceptionInterface exception. Each of these has a ->getReason() method. Translate this in your controller before displaying it. This text will not change in future versions of this bundle (if it did, it would be a backwards compatibility break).

This is probably something we should add to the docs.

@jrushlow
Copy link
Collaborator

There are PRs open in the Symfony Demo repository that demonstrate how this is done. I'm hoping to get some time to head over there and put the finishing touches on those PR's soon.

@jrushlow jrushlow added documentation Improvements or additions to documentation enhancement New feature or request labels Dec 18, 2020
@codedmonkey
Copy link
Contributor

Hi there, would it be useful to add these strings to the translation files of the bundle?

@kbond
Copy link
Contributor

kbond commented Feb 10, 2022

@codedmonkey, is this what you mean?

@bocharsky-bw
Copy link
Member

Hey guys!

I suggested translating error messages in #206 that was already merged 🎉 - but we still need to merge related PR in Maker, see symfony/maker-bundle#1059 . Please, give it a try and review if you want! Also, feel free to help translating error messages to other languages, currently it's translated into en, ru and uk:

<trans-unit id="6">
<source>There was a problem validating your password reset request</source>
<target>There was a problem validating your password reset request</target>
</trans-unit>
<trans-unit id="7">
<source>There was a problem handling your password reset request</source>
<target>There was a problem handling your password reset request</target>
</trans-unit>
<trans-unit id="8">
<source>The link in your email is expired. Please try to reset your password again.</source>
<target>The link in your email is expired. Please try to reset your password again.</target>
</trans-unit>
<trans-unit id="9">
<source>Please update the request_password_repository configuration in config/packages/reset_password.yaml to point to your "request password repository" service.</source>
<target>Please update the request_password_repository configuration in config/packages/reset_password.yaml to point to your "request password repository" service.</target>
</trans-unit>
<trans-unit id="10">
<source>The reset password link is invalid. Please try to reset your password again.</source>
<target>The reset password link is invalid. Please try to reset your password again.</target>
</trans-unit>
<trans-unit id="11">
<source>You have already requested a reset password email. Please check your email or try again soon.</source>
<target>You have already requested a reset password email. Please check your email or try again soon.</target>
</trans-unit>

Btw, for now you can easily translate those messages yourself if needed, find a workaround here: #202 (comment)

@bocharsky-bw
Copy link
Member

I'm closing this - symfony/maker-bundle#1059 is merged and Maker v1.37.0 is released. Now this bundle only needs missing translations. If you already generated reset password code with Maker before - please, update it according to the new changes in Maker, see symfony/maker-bundle#1059 for the help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants