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

Make default notifications translatable #23885

Closed
wants to merge 1 commit into from
Closed

Make default notifications translatable #23885

wants to merge 1 commit into from

Conversation

dakira
Copy link
Contributor

@dakira dakira commented Apr 15, 2018

This uses the JSON translation-strings feature to make it easier
to localize notifications and the password reset mail.

This uses the JSON translation-strings feature to make it easier
to localize notifications and the password reset mail.
@dakira
Copy link
Contributor Author

dakira commented Apr 15, 2018

I also added a note to the docs.
laravel/docs#4239

->line('You are receiving this email because we received a password reset request for your account.')
->action('Reset Password', url(config('app.url').route('password.reset', $this->token, false)))
->line('If you did not request a password reset, no further action is required.');
->line(__('You are receiving this email because we received a password reset request for your account.'))

Choose a reason for hiding this comment

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

I feel that these keys should be more succinct in their key naming and stored in the default lang file in resources/lang/en in the laravel/laravel repository

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@countnoobula Taylor mentioned that he'd accept a pull-request if the json translation features was used instead of translation keys (see laravel/ideas#409).

Copy link
Member

Choose a reason for hiding this comment

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

The auth component can't use helpers defined in the foundation package.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually tested this before submitting the PR and it does work as expected.

Copy link
Member

Choose a reason for hiding this comment

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

I actually tested this before submitting the PR and it does work as expected.

Did you test using the auth component outside of the framework?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This notification won't work without the rest of the framework anyway, will it? It can't be used in isolation.

Copy link
Member

Choose a reason for hiding this comment

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

It should work without the foundation package, such as in Lumen. If there is genuinely code in here that doesn't work, even with every illuminate package installed, then it is in the wrong place, and should be in foundation.

Copy link
Contributor Author

@dakira dakira Apr 16, 2018

Choose a reason for hiding this comment

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

Correct me if I'm wrong: Lumen does not use the ResetPassword notification. And if one wants to use it they need to pull in all sorts of packages anyway (that are not defined in auths composer.json).

The thing is: There should be an easy way to localize password resets. Right now there isn't. If Foundation is the one package that can't be pulled in if people want this feature, then this file really should be moved to foundation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@GrahamCampbell Ahh.. I see. Foundation is not a seperate package that can be pulled in. Shame on me.

That said.. all the other password reset stuff is already in foundation.. so this should probably go there, too, right?

->line('You are receiving this email because we received a password reset request for your account.')
->action('Reset Password', url(config('app.url').route('password.reset', $this->token, false)))
->line('If you did not request a password reset, no further action is required.');
->line(__('You are receiving this email because we received a password reset request for your account.'))
Copy link
Member

Choose a reason for hiding this comment

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

The auth component can't use helpers defined in the foundation package.

@taylorotwell
Copy link
Member

I suggest using toMailUsing() method to register your own way of sending this notification.

@dakira
Copy link
Contributor Author

dakira commented Apr 16, 2018

@taylorotwell It's actually not as easy as that. You need to create your own PasswordBroker, too to override the usage of this notification with your own, just to be able to translate hardcoded English strings. I missed this new function. That of course makes it easier.

Apart from that, are you okay with translating the default notification strings in https://github.com/laravel/framework/blob/5.6/src/Illuminate/Notifications/resources/views/email.blade.php?

(Edited)

@dakira dakira deleted the notificationtranslations branch May 23, 2018 10:16
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.

4 participants