Skip to content

Commit

Permalink
feat: change lang of submition article in fr
Browse files Browse the repository at this point in the history
  • Loading branch information
StevyMarlino committed Oct 12, 2024
1 parent 7d707d6 commit 4cd61e8
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion app/Console/Commands/NotifyPendingArticles.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ public function handle(AnonymousNotifiable $notifiable): void
$notifiable->notify(new PendingArticlesNotification($pendingArticles));
}
}
}
}
2 changes: 1 addition & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ protected function commands(): void
{
$this->load(__DIR__.'/Commands');
}
}
}
19 changes: 9 additions & 10 deletions app/Notifications/PendingArticlesNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Notifications\Messages\MailMessage;
use NotificationChannels\Telegram\TelegramChannel;
use NotificationChannels\Telegram\TelegramMessage;

final class PendingArticlesNotification extends Notification
{
use Queueable;

public function __construct(public Collection $pendingArticles) {}
public function __construct(public Collection $pendingArticles)
{
}

public function via(mixed $notifiable): array
{
Expand All @@ -28,25 +28,24 @@ public function toTelegram(): TelegramMessage
$message = $this->content();

return TelegramMessage::create()
->to(config('services.telegram-bot-api.channel'))
->content($message);
->to(config('services.telegram-bot-api.channel'))->content($message);
}

private function content(): string
{
$message = __("Pending approval articles:\n\n");
$message = __("Articles soumis en attente d'approbation:\n\n");
foreach ($this->pendingArticles as $article) {
$message .= __(
"[@:username](:profile_url) submitted the article [:title](:url) on: :date\n\n", [
"[@:username](:profile_url) a soumit l'article [:title](:url) le: :date\n\n",
[
'username' => $article->user?->username,
'profile_url' => route('profile', $article->user?->username),
'title' => $article->title,
'url' => route('articles.show', $article->slug),
'date' => $article->submitted_at->translatedFormat('d/m/Y')
'date' => $article->submitted_at->translatedFormat('d M Y')
]
);
}

return $message;
}
}
}
7 changes: 4 additions & 3 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"Verify Email Address": "Verify Email Address",
"Please click the button below to verify your email address.": "Please click the button below to verify your email address.",
"If you did not create an account, no further action is required.": "If you did not create an account, no further action is required.",
"Pending approval articles:" : "Pending approval articles:",
"[@:username](:profile_url) submitted the article [:title](:url) on: :date" : "[@:username](:profile_url) submitted the article [:title](:url) on: :date"
}
"Articles soumis en attente d'approbation:" : "Pending approval articles:",
"[@:username](:profile_url) a soumit l'article :title le: :date" : "[@:username](:profile_url) submitted the article :title on: :date",
"Voir l'article" : "Voir l'article"
}
7 changes: 4 additions & 3 deletions lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"Verify Email Address": "Vérifier l'adresse e-mail",
"Please click the button below to verify your email address.": "Veuillez cliquer sur le bouton ci-dessous pour vérifier votre adresse email.",
"If you did not create an account, no further action is required.": "Si vous n'avez pas créé de compte, aucune autre action n'est requise.",
"Pending approval articles:" : "Articles soumis en attente d'approbation:",
"[@:username](:profile_url) submitted the article [:title](:url) on: :date" : "[@:username](:profile_url) a soumit l'article [:title](:url) le: :date"
}
"Articles soumis en attente d'approbation:" : "Articles soumis en attente d'approbation:",
"[@:username](:profile_url) a soumit l'article [:title](:url) le: :date" : "[@:username](:profile_url) a soumit l'article [:title](:url) le: :date",
"Voir l'article": "Voir l'article"
}
4 changes: 2 additions & 2 deletions tests/Feature/NotifyPendingArticlesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use App\Models\Article;
use Illuminate\Support\Facades\Notification;

beforeEach(fn() => Notification::fake());
beforeEach(fn () => Notification::fake());

it('will send a notification when there are pending articles', function (): void {
Article::factory()->createMany([
Expand Down Expand Up @@ -46,4 +46,4 @@

Notification::assertNothingSent();
Notification::assertCount(0);
});
});
2 changes: 1 addition & 1 deletion tests/Integration/DiscussionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@

// When providing a slug with invalid url characters, a random 5 character string is returned.
expect($discussion->slug())->toMatch('/\w{5}/');
});
});
2 changes: 1 addition & 1 deletion tests/Integration/ThreadTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,4 @@ function createActiveThread(): Thread
$reply->save();

return $thread;
}
}

0 comments on commit 4cd61e8

Please sign in to comment.