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

[5.7] Notifications can choose locale #24919

Merged
merged 1 commit into from
Aug 12, 2018

Conversation

derekmd
Copy link
Contributor

@derekmd derekmd commented Jul 21, 2018

Follow-up to #23178 and #24451, this brings Notification localization behavior in line with Mailable. This allows notifications to choose their locale so when they're queued the subject line, greeting, body, etc. are always running as that locale instead of the app's default locale.

Notification::locale('es')->send(
    $users, new OrderConfirmation($order)
);
Auth::user()->notify(
    (new OrderConfirmation($order))->locale('es')
);

Multiple recipients for more than one language

I have a follow-up pull request to add a HasLocalePreference contract to users/notifiables so you can easily store user settings in the database and have Notification::send($users, new OrderConfirmation($order)); magically send the correct translation to each account.

The mailable-only preview is here: https://github.com/derekmd/framework/commits/mailable-localized-recipients

@GrahamCampbell GrahamCampbell changed the base branch from master to 5.7 August 1, 2018 22:11
Queued notifications can run in a
locale other than the application
default.
@derekmd derekmd force-pushed the translate-queued-notifications branch from 40615ab to 6cd8121 Compare August 5, 2018 20:17
@taylorotwell taylorotwell merged commit 6cd8121 into laravel:5.7 Aug 12, 2018
@taylorotwell
Copy link
Member

@derekmd thanks. could you send a PR to docs (5.7 branch) to add this to the release notes with an explanation of how to use it?

@derekmd
Copy link
Contributor Author

derekmd commented Aug 12, 2018

Sure, if not today I'll have something in by mid-week.

@derekmd derekmd deleted the translate-queued-notifications branch August 12, 2018 20:14
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.

2 participants