Skip to content

Commit

Permalink
🐛 fix locale in account deletion mail (#2600)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKrisKrisu authored May 25, 2024
1 parent 76ec77f commit 9bd816d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/Mail/AccountDeletionNotificationTwoWeeksBefore.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\App;

class AccountDeletionNotificationTwoWeeksBefore extends Mailable
{
Expand All @@ -18,16 +17,19 @@ class AccountDeletionNotificationTwoWeeksBefore extends Mailable

public function __construct(User $user) {
$this->user = $user;
$this->locale(str_starts_with($user->language, 'de') ? 'de' : 'en'); //other languages currently don't have a translation here and (bug?) fall back to the default locale doesn't work?
}

public function envelope(): Envelope {
return new Envelope(
subject: __(key: 'mail.account_deletion_notification_two_weeks_before.subject', locale: $this->user?->language),
subject: __(
key: 'mail.account_deletion_notification_two_weeks_before.subject',
locale: str_starts_with($this->user->language, 'de') ? 'de' : 'en'
),
);
}

public function content(): Content {
App::setLocale($this->user?->language ?? config('app.locale', 'en'));
return new Content(
view: 'mail.account_deletion_notification_two_weeks_before',
with: [
Expand Down

0 comments on commit 9bd816d

Please sign in to comment.