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

RFC: Add translations for exception reasons #206

Merged
merged 5 commits into from
Jan 31, 2022

Conversation

bocharsky-bw
Copy link
Member

@bocharsky-bw bocharsky-bw commented Jan 28, 2022

Closes #202

The next step - I'll create a PR in Maker bundle to wrap reasons with Translator::trans() - then all exception messages in this bundle will be automatically translated. The remaining step - wait for more translation contributions.

Basically, I explained a workaround here which can be avoided with this PR: #202 (comment)

@@ -14,5 +14,8 @@
*/
interface ResetPasswordExceptionInterface extends \Throwable
{
public const MESSAGE_PROBLEM_VALIDATE = 'There was a problem validating your password reset request';
public const MESSAGE_PROBLEM_HANDLE = 'There was a problem handling your password reset request';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those strings are hardcode in Maker - probably we could migrate them in this bundle as well and then just reuse these constants in Maker, see https://github.com/symfony/maker-bundle/blob/085358c107a7047b4889455d7518d0dbf55169f1/src/Resources/skeleton/resetPassword/ResetPasswordController.tpl.php#L160

Copy link
Collaborator

@jrushlow jrushlow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Thanks @bocharsky-bw

@bocharsky-bw
Copy link
Member Author

Related PR to Maker bundle created: symfony/maker-bundle#1059

@jrushlow jrushlow mentioned this pull request Feb 14, 2022
weaverryan added a commit to symfony/maker-bundle that referenced this pull request Feb 16, 2022
…ded by ResetPasswordBundle (bocharsky-bw)

This PR was squashed before being merged into the 1.0-dev branch.

Discussion
----------

[make:reset-password] Translate exception reasons provided by ResetPasswordBundle

If there's `Symfony\Contracts\Translation\TranslatorInterface` service available in the project - Maker will generate a slightly different controller's code to inject translator service and translate exception reasons out of the box.

Available after: SymfonyCasts/reset-password-bundle#206

Commits
-------

b771178 [make:reset-password] Translate exception reasons provided by ResetPasswordBundle
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

Successfully merging this pull request may close these issues.

Translation reason
2 participants