|
12 | 12 | use Illuminate\Support\Traits\Localizable;
|
13 | 13 | use Illuminate\Contracts\Support\Renderable;
|
14 | 14 | use Illuminate\Contracts\Queue\Factory as Queue;
|
| 15 | +use Illuminate\Contracts\Translation\Translator; |
15 | 16 | use Illuminate\Contracts\Mail\Mailer as MailerContract;
|
16 | 17 | use Illuminate\Contracts\Mail\Mailable as MailableContract;
|
17 | 18 |
|
18 | 19 | class Mailable implements MailableContract, Renderable
|
19 | 20 | {
|
20 | 21 | use Localizable;
|
21 | 22 |
|
| 23 | + /** |
| 24 | + * The locale of the message. |
| 25 | + * |
| 26 | + * @var string |
| 27 | + */ |
| 28 | + public $locale; |
| 29 | + |
22 | 30 | /**
|
23 | 31 | * The person the message is from.
|
24 | 32 | *
|
@@ -54,13 +62,6 @@ class Mailable implements MailableContract, Renderable
|
54 | 62 | */
|
55 | 63 | public $replyTo = [];
|
56 | 64 |
|
57 |
| - /** |
58 |
| - * The locale of the message. |
59 |
| - * |
60 |
| - * @var string |
61 |
| - */ |
62 |
| - public $locale; |
63 |
| - |
64 | 65 | /**
|
65 | 66 | * The subject of the message.
|
66 | 67 | *
|
@@ -132,7 +133,9 @@ class Mailable implements MailableContract, Renderable
|
132 | 133 | */
|
133 | 134 | public function send(MailerContract $mailer)
|
134 | 135 | {
|
135 |
| - $this->withLocale($this->locale, $mailer->translator, function () use ($mailer) { |
| 136 | + $translator = Container::getInstance()->make(Translator::class); |
| 137 | + |
| 138 | + $this->withLocale($this->locale, $translator, function () use ($mailer) { |
136 | 139 | Container::getInstance()->call([$this, 'build']);
|
137 | 140 |
|
138 | 141 | $mailer->send($this->buildView(), $this->buildViewData(), function ($message) {
|
@@ -362,6 +365,19 @@ protected function runCallbacks($message)
|
362 | 365 | return $this;
|
363 | 366 | }
|
364 | 367 |
|
| 368 | + /** |
| 369 | + * Set the locale of the message. |
| 370 | + * |
| 371 | + * @param string $locale |
| 372 | + * @return $this |
| 373 | + */ |
| 374 | + public function locale($locale) |
| 375 | + { |
| 376 | + $this->locale = $locale; |
| 377 | + |
| 378 | + return $this; |
| 379 | + } |
| 380 | + |
365 | 381 | /**
|
366 | 382 | * Set the priority of this message.
|
367 | 383 | *
|
@@ -584,19 +600,6 @@ protected function hasRecipient($address, $name = null, $property = 'to')
|
584 | 600 | });
|
585 | 601 | }
|
586 | 602 |
|
587 |
| - /** |
588 |
| - * Set the locale of the message. |
589 |
| - * |
590 |
| - * @param string $locale |
591 |
| - * @return $this |
592 |
| - */ |
593 |
| - public function locale($locale) |
594 |
| - { |
595 |
| - $this->locale = $locale; |
596 |
| - |
597 |
| - return $this; |
598 |
| - } |
599 |
| - |
600 | 603 | /**
|
601 | 604 | * Set the subject of the message.
|
602 | 605 | *
|
|
0 commit comments