#132 - clean up notifications (#147)

* #132 - added translations

* wip

* #132 - added translations

* #132 - cs fix

* #132 - cs fix

Co-authored-by: Adrian Hopek <adrian.hopek@blumilk.pl>
This commit is contained in:
Ewelina Lasowy
2022-05-17 15:17:09 +02:00
committed by GitHub
parent 74f33d6c0b
commit 7154caa340
22 changed files with 92 additions and 46 deletions

View File

@@ -24,7 +24,7 @@ class CatchAll extends BaseHandler
$handlers = $this->findAvailableHandlers();
$attachmentFields = $this->mapHandlersToAttachments($handlers);
return $this->respondToSlack(":x: Nie rozpoznaję polecenia. Lista wszystkich poleceń:")
return $this->respondToSlack(__(":x: I don't recognize the command. List of all commands:"))
->withAttachment(
Attachment::create()
->setColor("danger")

View File

@@ -16,7 +16,7 @@ use Toby\Infrastructure\Slack\Elements\RemotesAttachment;
class DailySummary extends SignatureHandler
{
protected $signature = "toby dzisiaj";
protected $description = "Codzienne podsumowanie";
protected $description = "Daily summary";
public function handle(Request $request): Response
{
@@ -30,7 +30,7 @@ class DailySummary extends SignatureHandler
new BirthdaysAttachment($dailySummaryRetriever->getBirthdays($now)),
]);
return $this->respondToSlack("Podsumowanie dla dnia {$now->toDisplayString()}")
return $this->respondToSlack(__("Summary for the day :day", ["day" => $now->toDisplayString()]))
->withAttachments($attachments->all());
}
}

View File

@@ -18,7 +18,7 @@ class GiveKeysTo extends SignatureHandler
use FindsUserBySlackId;
protected $signature = "toby klucze:dla {user}";
protected $description = "Przekaż klucze wskazanemu użytkownikowi";
protected $description = "Give the keys to the specified user";
/**
* @throws UserNotFoundException
@@ -35,12 +35,12 @@ class GiveKeysTo extends SignatureHandler
$key = $authUser->keys()->first();
if (!$key) {
throw ValidationException::withMessages(["key" => "Nie masz żadnego klucza do przekazania"]);
throw ValidationException::withMessages(["key" => __("You don't have any key to give")]);
}
if ($user->is($authUser)) {
throw ValidationException::withMessages([
"key" => "Nie możesz przekazać sobie kluczy :dzban:",
"key" => __("You can't give the keys to yourself :dzban:"),
]);
}
@@ -51,7 +51,7 @@ class GiveKeysTo extends SignatureHandler
$key->notify(new KeyHasBeenGivenNotification($authUser, $user));
return $this->respondToSlack(
":white_check_mark: Klucz nr {$key->id} został przekazany użytkownikowi <@{$user->profile->slack_id}>",
__(":white_check_mark: Key no. :key has been given to <@:user>", ["key" => $key->id, "user" => $user->profile->slack_id]),
);
}
@@ -65,7 +65,7 @@ class GiveKeysTo extends SignatureHandler
protected function getMessages(): array
{
return [
"user.required" => "Musisz podać użytkownika, któremu chcesz przekazać klucze",
"user.required" => "You must specified the user to whom you want to give the keys",
];
}
}

View File

@@ -14,7 +14,7 @@ class Help extends SignatureHandler
use ListsHandlers;
protected $signature = "toby pomoc";
protected $description = "Wyświetl wszystkie dostępne polecenia";
protected $description = "Show all available commands";
public function handle(Request $request): Response
{
@@ -22,7 +22,7 @@ class Help extends SignatureHandler
$attachmentFields = $this->mapHandlersToAttachments($handlers);
return $this->respondToSlack("Dostępne polecenia:")
return $this->respondToSlack(__("Available commands:"))
->withAttachment(
Attachment::create()
->setColor("good")

View File

@@ -18,18 +18,18 @@ class HomeOffice extends SignatureHandler
use FindsUserBySlackId;
protected $signature = "toby zdalnie";
protected $description = "Pracuj dzisiaj zdalnie";
protected $description = "Work remotely today";
public function handle(Request $request): Response
{
$user = $this->findUserBySlackId($request->userId);
$this->createRemoteday($user, Carbon::today());
$this->createRemoteDay($user, Carbon::today());
return $this->respondToSlack(":white_check_mark: Pracujesz dzisiaj zdalnie");
return $this->respondToSlack(__(":white_check_mark: You work remotely today"));
}
protected function createRemoteday(User $user, Carbon $date): void
protected function createRemoteDay(User $user, Carbon $date): void
{
$yearPeriod = YearPeriod::findByYear($date->year);

View File

@@ -12,7 +12,7 @@ use Toby\Infrastructure\Slack\Elements\KeysAttachment;
class KeyList extends SignatureHandler
{
protected $signature = "toby klucze";
protected $description = "Lista wszystkich kluczy";
protected $description = "List of all keys";
public function handle(Request $request): Response
{
@@ -20,7 +20,7 @@ class KeyList extends SignatureHandler
->orderBy("id")
->get();
return $this->respondToSlack("Lista kluczy :key:")
return $this->respondToSlack(__("Keys list :key:"))
->withAttachment(new KeysAttachment($keys));
}
}

View File

@@ -18,7 +18,7 @@ class TakeKeysFrom extends SignatureHandler
use FindsUserBySlackId;
protected $signature = "toby klucze:od {user}";
protected $description = "Zabierz klucze wskazanemu użytkownikowi";
protected $description = "Take keys from specified user";
/**
* @throws UserNotFoundException|ValidationException
@@ -35,13 +35,13 @@ class TakeKeysFrom extends SignatureHandler
if (!$key) {
throw ValidationException::withMessages([
"key" => "Użytkownik <@{$user->profile->slack_id}> nie ma żadnych kluczy",
"key" => __("User <@:user> does not have any keys", ["user" => $user->profile->slack_id]),
]);
}
if ($key->user()->is($authUser)) {
throw ValidationException::withMessages([
"key" => "Nie możesz zabrać sobie kluczy :dzban:",
"key" => __("You can't take the keys from yourself :dzban:"),
]);
}
@@ -51,7 +51,7 @@ class TakeKeysFrom extends SignatureHandler
$key->notify(new KeyHasBeenTakenNotification($authUser, $user));
return $this->respondToSlack(":white_check_mark: Klucz nr {$key->id} został zabrany użytkownikowi <@{$user->profile->slack_id}>");
return $this->respondToSlack(__(":white_check_mark: Key no. :key has been taken from user <@:user>", ["key" => $key->id, "user" => $user->profile->slack_id]));
}
protected function getRules(): array
@@ -64,7 +64,7 @@ class TakeKeysFrom extends SignatureHandler
protected function getMessages(): array
{
return [
"user.required" => "Musisz podać użytkownika, któremu chcesz zabrać klucze",
"user.required" => __("You must specified the user you want to take the keys from"),
];
}
}