diff --git a/app/Notifications/AccountCreated.php b/app/Notifications/AccountCreated.php index 2365113a3..0692b104c 100644 --- a/app/Notifications/AccountCreated.php +++ b/app/Notifications/AccountCreated.php @@ -23,14 +23,16 @@ class AccountCreated extends Notification implements ShouldQueue public function toMail(User $notifiable): MailMessage { + $locale = $notifiable->language ?? 'en'; + $message = (new MailMessage()) - ->greeting('Hello ' . $notifiable->username . '!') - ->line('You are receiving this email because an account has been created for you on ' . config('app.name') . '.') - ->line('Username: ' . $notifiable->username) - ->line('Email: ' . $notifiable->email); + ->greeting(trans('mail.greeting', ['name' => $notifiable->username], $locale)) + ->line(trans('mail.account_created.body', ['app' => config('app.name')], $locale)) + ->line(trans('mail.account_created.username', ['username' => $notifiable->username], $locale)) + ->line(trans('mail.account_created.email', ['email' => $notifiable->email], $locale)); if (!is_null($this->token)) { - return $message->action('Setup Your Account', Filament::getPanel('app')->getResetPasswordUrl($this->token, $notifiable)); + return $message->action(trans('mail.account_created.action', locale: $locale), Filament::getPanel('app')->getResetPasswordUrl($this->token, $notifiable)); } return $message; diff --git a/app/Notifications/AddedToServer.php b/app/Notifications/AddedToServer.php index 45ca507e8..a328737bf 100644 --- a/app/Notifications/AddedToServer.php +++ b/app/Notifications/AddedToServer.php @@ -24,10 +24,12 @@ class AddedToServer extends Notification implements ShouldQueue public function toMail(User $notifiable): MailMessage { + $locale = $notifiable->language ?? 'en'; + return (new MailMessage()) - ->greeting('Hello ' . $notifiable->username . '!') - ->line('You have been added as a subuser for the following server, allowing you certain control over the server.') - ->line('Server Name: ' . $this->server->name) - ->action('Visit Server', Console::getUrl(panel: 'server', tenant: $this->server)); + ->greeting(trans('mail.greeting', ['name' => $notifiable->username], $locale)) + ->line(trans('mail.added_to_server.body', locale: $locale)) + ->line(trans('mail.added_to_server.server_name', ['name' => $this->server->name], $locale)) + ->action(trans('mail.added_to_server.action', locale: $locale), Console::getUrl(panel: 'server', tenant: $this->server)); } } diff --git a/app/Notifications/MailTested.php b/app/Notifications/MailTested.php index b2ccba861..f44566b4a 100644 --- a/app/Notifications/MailTested.php +++ b/app/Notifications/MailTested.php @@ -20,9 +20,11 @@ class MailTested extends Notification public function toMail(): MailMessage { + $locale = $this->user->language ?? 'en'; + return (new MailMessage()) - ->subject('Panel Test Message') - ->greeting('Hello ' . $this->user->username . '!') - ->line('This is a test of the Panel mail system. You\'re good to go!'); + ->subject(trans('mail.mail_tested.subject', locale: $locale)) + ->greeting(trans('mail.greeting', ['name' => $this->user->username], $locale)) + ->line(trans('mail.mail_tested.body', locale: $locale)); } } diff --git a/app/Notifications/RemovedFromServer.php b/app/Notifications/RemovedFromServer.php index 04f9484fa..1ff2e2f51 100644 --- a/app/Notifications/RemovedFromServer.php +++ b/app/Notifications/RemovedFromServer.php @@ -23,11 +23,13 @@ class RemovedFromServer extends Notification implements ShouldQueue public function toMail(User $notifiable): MailMessage { + $locale = $notifiable->language ?? 'en'; + return (new MailMessage()) ->error() - ->greeting('Hello ' . $notifiable->username . '.') - ->line('You have been removed as a subuser for the following server.') - ->line('Server Name: ' . $this->server->name) - ->action('Visit Panel', url('')); + ->greeting(trans('mail.greeting', ['name' => $notifiable->username], $locale)) + ->line(trans('mail.removed_from_server.body', locale: $locale)) + ->line(trans('mail.removed_from_server.server_name', ['name' => $this->server->name], $locale)) + ->action(trans('mail.removed_from_server.action', locale: $locale), url('')); } } diff --git a/app/Notifications/ServerInstalled.php b/app/Notifications/ServerInstalled.php index 2e6dc4ee5..40f894b0b 100644 --- a/app/Notifications/ServerInstalled.php +++ b/app/Notifications/ServerInstalled.php @@ -24,10 +24,12 @@ class ServerInstalled extends Notification implements ShouldQueue public function toMail(User $notifiable): MailMessage { + $locale = $notifiable->language ?? 'en'; + return (new MailMessage()) - ->greeting('Hello ' . $notifiable->username . '.') - ->line('Your server has finished installing and is now ready for you to use.') - ->line('Server Name: ' . $this->server->name) - ->action('Login and Begin Using', Console::getUrl(panel: 'server', tenant: $this->server)); + ->greeting(trans('mail.greeting', ['name' => $notifiable->username], $locale)) + ->line(trans('mail.server_installed.body', locale: $locale)) + ->line(trans('mail.server_installed.server_name', ['name' => $this->server->name], $locale)) + ->action(trans('mail.server_installed.action', locale: $locale), Console::getUrl(panel: 'server', tenant: $this->server)); } } diff --git a/lang/en/mail.php b/lang/en/mail.php new file mode 100644 index 000000000..9097eb665 --- /dev/null +++ b/lang/en/mail.php @@ -0,0 +1,35 @@ + 'Hello :name!', + + 'account_created' => [ + 'body' => 'You are receiving this email because an account has been created for you on :app.', + 'username' => 'Username: :username', + 'email' => 'Email: :email', + 'action' => 'Setup Your Account', + ], + + 'added_to_server' => [ + 'body' => 'You have been added as a subuser for the following server, allowing you certain control over the server.', + 'server_name' => 'Server Name: :name', + 'action' => 'Visit Server', + ], + + 'removed_from_server' => [ + 'body' => 'You have been removed as a subuser for the following server.', + 'server_name' => 'Server Name: :name', + 'action' => 'Visit Panel', + ], + + 'server_installed' => [ + 'body' => 'Your server has finished installing and is now ready for you to use.', + 'server_name' => 'Server Name: :name', + 'action' => 'Login and Begin Using', + ], + + 'mail_tested' => [ + 'subject' => 'Panel Test Message', + 'body' => 'This is a test of the Panel mail system. You\'re good to go!', + ], +];