diff --git a/app/Domain/Notifications/VacationRequestCreatedNotification.php b/app/Domain/Notifications/VacationRequestCreatedNotification.php index 187ee45..378c98c 100644 --- a/app/Domain/Notifications/VacationRequestCreatedNotification.php +++ b/app/Domain/Notifications/VacationRequestCreatedNotification.php @@ -97,8 +97,8 @@ class VacationRequestCreatedNotification extends Notification $name = $this->vacationRequest->name; if ($this->vacationRequest->creator()->is($this->vacationRequest->user)) { - return __("The vacation request :title from user :user has been created successfully.", [ - "user" => $this->vacationRequest->user->profile->full_name, + return __("The vacation request :title has been created successfully.", [ + "requester" => $this->vacationRequest->user->profile->full_name, "title" => $name, ]); } diff --git a/app/Infrastructure/Console/Commands/SendDailySummaryToSlack.php b/app/Infrastructure/Console/Commands/SendDailySummaryToSlack.php index 1c2a5b6..b07c5ff 100644 --- a/app/Infrastructure/Console/Commands/SendDailySummaryToSlack.php +++ b/app/Infrastructure/Console/Commands/SendDailySummaryToSlack.php @@ -18,7 +18,7 @@ use Toby\Infrastructure\Slack\Elements\RemotesAttachment; class SendDailySummaryToSlack extends Command { protected $signature = "toby:slack:daily-summary {--f|force}"; - protected $description = "Sent daily summary to slack"; + protected $description = "Sent daily summary to Slack"; public function handle(DailySummaryRetriever $dailySummaryRetriever): void { @@ -37,7 +37,7 @@ class SendDailySummaryToSlack extends Command Http::withToken($this->getSlackClientToken()) ->post($this->getUrl(), [ "channel" => $this->getSlackChannel(), - "text" => "Podsumowanie dla dnia {$now->toDisplayString()}", + "text" => __("Daily summary for day :day",["day"=>$now->toDisplayString()]), "attachments" => $attachments, ]); } diff --git a/app/Infrastructure/Http/Rules/YearPeriodExists.php b/app/Infrastructure/Http/Rules/YearPeriodExists.php index d6f9677..c6cad9a 100644 --- a/app/Infrastructure/Http/Rules/YearPeriodExists.php +++ b/app/Infrastructure/Http/Rules/YearPeriodExists.php @@ -19,6 +19,6 @@ class YearPeriodExists implements Rule public function message(): string { - return "The year period for given year doesn't exist."; + return __("The year period for given year does not exist."); } } diff --git a/app/Infrastructure/Slack/Elements/AbsencesAttachment.php b/app/Infrastructure/Slack/Elements/AbsencesAttachment.php index 3f34fac..a4d17b2 100644 --- a/app/Infrastructure/Slack/Elements/AbsencesAttachment.php +++ b/app/Infrastructure/Slack/Elements/AbsencesAttachment.php @@ -14,9 +14,9 @@ class AbsencesAttachment extends ListAttachment parent::__construct(); $this - ->setTitle("Nieobecności :palm_tree:") + ->setTitle(__("Absences :palm_tree:")) ->setColor("#eab308") ->setItems($absences->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name)) - ->setEmptyText("Wszyscy dzisiaj pracują :muscle:"); + ->setEmptyText(__("Everybody works today :muscle:")); } } diff --git a/app/Infrastructure/Slack/Elements/BirthdaysAttachment.php b/app/Infrastructure/Slack/Elements/BirthdaysAttachment.php index 860885d..79af2ce 100644 --- a/app/Infrastructure/Slack/Elements/BirthdaysAttachment.php +++ b/app/Infrastructure/Slack/Elements/BirthdaysAttachment.php @@ -14,9 +14,9 @@ class BirthdaysAttachment extends ListAttachment parent::__construct(); $this - ->setTitle("Urodziny :birthday:") + ->setTitle(__("Birthdays :birthday:")) ->setColor("#3c5f97") ->setItems($birthdays->map(fn(User $user): string => $user->profile->full_name)) - ->setEmptyText("Dzisiaj nikt nie ma urodzin :cry:"); + ->setEmptyText(__("Nobody has a birthday today :cry:")); } } diff --git a/app/Infrastructure/Slack/Elements/KeysAttachment.php b/app/Infrastructure/Slack/Elements/KeysAttachment.php index 80819d3..67b2449 100644 --- a/app/Infrastructure/Slack/Elements/KeysAttachment.php +++ b/app/Infrastructure/Slack/Elements/KeysAttachment.php @@ -16,6 +16,6 @@ class KeysAttachment extends ListAttachment $this ->setColor("#3c5f97") ->setItems($keys->map(fn(Key $key): string => "Klucz nr {$key->id} - <@{$key->user->profile->slack_id}>")) - ->setEmptyText("Nie ma żadnych kluczy w tobym"); + ->setEmptyText(__("There are no keys in toby")); } } diff --git a/app/Infrastructure/Slack/Elements/RemotesAttachment.php b/app/Infrastructure/Slack/Elements/RemotesAttachment.php index 2f39ad4..4334883 100644 --- a/app/Infrastructure/Slack/Elements/RemotesAttachment.php +++ b/app/Infrastructure/Slack/Elements/RemotesAttachment.php @@ -14,9 +14,9 @@ class RemotesAttachment extends ListAttachment parent::__construct(); $this - ->setTitle("Praca zdalna :house_with_garden:") + ->setTitle(__("Remote work :house_with_garden:")) ->setColor("#527aba") ->setItems($remoteDays->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name)) - ->setEmptyText("Wszyscy dzisiaj są w biurze :boom:"); + ->setEmptyText(__("Everybody is in the office :boom:")); } } diff --git a/app/Infrastructure/Slack/Elements/VacationRequestsAttachment.php b/app/Infrastructure/Slack/Elements/VacationRequestsAttachment.php index 933b8fb..3cd81b4 100644 --- a/app/Infrastructure/Slack/Elements/VacationRequestsAttachment.php +++ b/app/Infrastructure/Slack/Elements/VacationRequestsAttachment.php @@ -27,7 +27,7 @@ class VacationRequestsAttachment extends ListAttachment ? "{$request->from->toDisplayString()}" : "{$request->from->toDisplayString()} - {$request->to->toDisplayString()}"; - return "<{$url}|Wniosek nr {$request->name}> użytkownika {$request->user->profile->full_name} ({$date})"; + return __("<:url|Request no. :request> for user :user (:date)",["url"=> $url, "request"=>$request->name,"user"=>$request->profile->full_name,"date"=>$date]); }); } } diff --git a/app/Infrastructure/Slack/Handlers/CatchAll.php b/app/Infrastructure/Slack/Handlers/CatchAll.php index ce94256..6a23e1c 100644 --- a/app/Infrastructure/Slack/Handlers/CatchAll.php +++ b/app/Infrastructure/Slack/Handlers/CatchAll.php @@ -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") diff --git a/app/Infrastructure/Slack/Handlers/DailySummary.php b/app/Infrastructure/Slack/Handlers/DailySummary.php index 5a941ee..533d899 100644 --- a/app/Infrastructure/Slack/Handlers/DailySummary.php +++ b/app/Infrastructure/Slack/Handlers/DailySummary.php @@ -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()); } } diff --git a/app/Infrastructure/Slack/Handlers/GiveKeysTo.php b/app/Infrastructure/Slack/Handlers/GiveKeysTo.php index 7925844..6339cfe 100644 --- a/app/Infrastructure/Slack/Handlers/GiveKeysTo.php +++ b/app/Infrastructure/Slack/Handlers/GiveKeysTo.php @@ -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", ]; } } diff --git a/app/Infrastructure/Slack/Handlers/Help.php b/app/Infrastructure/Slack/Handlers/Help.php index e5e7ca2..8ef5675 100644 --- a/app/Infrastructure/Slack/Handlers/Help.php +++ b/app/Infrastructure/Slack/Handlers/Help.php @@ -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") diff --git a/app/Infrastructure/Slack/Handlers/HomeOffice.php b/app/Infrastructure/Slack/Handlers/HomeOffice.php index 7674539..03a8f4b 100644 --- a/app/Infrastructure/Slack/Handlers/HomeOffice.php +++ b/app/Infrastructure/Slack/Handlers/HomeOffice.php @@ -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); diff --git a/app/Infrastructure/Slack/Handlers/KeyList.php b/app/Infrastructure/Slack/Handlers/KeyList.php index 87ef123..1b8bcbb 100644 --- a/app/Infrastructure/Slack/Handlers/KeyList.php +++ b/app/Infrastructure/Slack/Handlers/KeyList.php @@ -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)); } } diff --git a/app/Infrastructure/Slack/Handlers/TakeKeysFrom.php b/app/Infrastructure/Slack/Handlers/TakeKeysFrom.php index 5d89eed..12d9333 100644 --- a/app/Infrastructure/Slack/Handlers/TakeKeysFrom.php +++ b/app/Infrastructure/Slack/Handlers/TakeKeysFrom.php @@ -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") ]; } } diff --git a/app/Infrastructure/Slack/Rules/SlackUserExistsRule.php b/app/Infrastructure/Slack/Rules/SlackUserExistsRule.php index 500c295..3620f36 100644 --- a/app/Infrastructure/Slack/Rules/SlackUserExistsRule.php +++ b/app/Infrastructure/Slack/Rules/SlackUserExistsRule.php @@ -19,6 +19,6 @@ class SlackUserExistsRule implements Rule public function message(): string { - return "Użytkownik :input nie istnieje w tobym"; + return __("User :input does not exist in toby"); } } diff --git a/app/Infrastructure/Slack/Traits/FindsUserBySlackId.php b/app/Infrastructure/Slack/Traits/FindsUserBySlackId.php index b3f1bae..880e1b1 100644 --- a/app/Infrastructure/Slack/Traits/FindsUserBySlackId.php +++ b/app/Infrastructure/Slack/Traits/FindsUserBySlackId.php @@ -30,7 +30,7 @@ trait FindsUserBySlackId $user = $this->findUserBySlackId($slackId); if (!$user) { - throw new UserNotFoundException("Użytkownik {$slackId} nie istnieje w tobym"); + throw new UserNotFoundException(__("User :input does not exist in toby", ["input"=> $slackId])); } return $user; diff --git a/app/Infrastructure/Slack/Traits/ListsHandlers.php b/app/Infrastructure/Slack/Traits/ListsHandlers.php index 0ec2d1f..4b637b6 100644 --- a/app/Infrastructure/Slack/Traits/ListsHandlers.php +++ b/app/Infrastructure/Slack/Traits/ListsHandlers.php @@ -37,7 +37,7 @@ trait ListsHandlers ) ->map( fn(SignatureHandler $handler): AttachmentField => AttachmentField::create( - $handler->getDescription(), + __($handler->getDescription()) , "`/{$handler->getSignature()}`", ), ) diff --git a/resources/lang/pl.json b/resources/lang/pl.json index 8485773..e196bff 100644 --- a/resources/lang/pl.json +++ b/resources/lang/pl.json @@ -73,5 +73,36 @@ "Key no :number has been taken from :user.": "Klucz nr :number został zabrany użytkownikowi :user.", "Key no :number has been given to :user.": "Klucz nr :number został przekazany użytkownikowi :user.", ":sender gives key no :key to :recipient": ":sender przekazuje klucz nr :key :recipient", - ":recipient takes key no :key from :sender": ":recipient zabiera klucz nr :key :sender" + ":recipient takes key no :key from :sender": ":recipient zabiera klucz nr :key :sender", + "The vacation request :title has been created successfully.": "Wniosek urlopowy :title został utworzony pomyślnie.", + ":x: I don't recognize the command. List of all commands:": ":x: Nie rozpoznaję polecenia. Lista wszystkich poleceń:", + "Summary for the day :day": "Podsumowanie dla dnia :day", + "Daily summary": "Podsumowanie dnia", + "Give the keys to the specified user": "Przekaż klucze wskazanemu użytkownikowi", + "You don't have any key to give": "Nie masz żadnego klucza do przekazania", + "You can't give the keys to yourself :dzban:": "Nie możesz przekazać sobie kluczy :dzban:", + ":white_check_mark: Key no. :key has been given to <@:user>": ":white_check_mark: Klucz nr :key został przekazany użytkownikowi <@:user>", + "You must specified the user to whom you want to give the keys": "Musisz podać użytkownika, któremu chcesz przekazać klucze", + "Show all available commands": "Wyświetl wszystkie dostępne polecenia", + "Available commands:": "Dostępne polecenia:", + "Work remotely today": "Pracuj dzisiaj zdalnie", + ":white_check_mark: You work remotely today": ":white_check_mark: Pracujesz dzisiaj zdalnie", + "List of all keys": "Lista wszystkich kluczy", + "Keys list :key:": "Lista kluczy :key:", + "Take keys from specified user": "Zabierz klucze wskazanemu użytkownikowi", + "User <@:user> does not have any keys": "Użytkownik <@:user> nie ma żadnych kluczy", + "You can't take the keys from yourself :dzban:": "Nie możesz zabrać sobie kluczy :dzban:", + "You must specified the user you want to take the keys from": "Musisz podać użytkownika, któremu chcesz zabrać klucze", + "User :input does not exist in toby": "Użytkownik :input nie istnieje w tobym", + ":white_check_mark: Key no. :key has been taken from user <@:user>": ":white_check_mark: Klucz nr :key został zabrany użytkownikowi <@:user>", + "Absences :palm_tree:": "Nieobecności :palm_tree:", + "Everybody works today :muscle:": "Wszyscy dzisiaj pracują :muscle:", + "Birthdays :birthday:": "Urodziny :birthday:", + "Nobody has a birthday today :cry:": "Dzisiaj nikt nie ma urodzin :cry:", + "Remote work :house_with_garden:": "Praca zdalna :house_with_garden:", + "Everybody is in the office :boom:": "Wszyscy dzisiaj są w biurze :boom:", + "There are no keys in toby": "Nie ma żadnych kluczy w tobym", + "<:url|Request no. :request> for user :user (:date)": "<:url Wniosek urlopowy nr :request użytkownika :user (:date)", + "The year period for given year does not exist.": "Okres roczny dla danego roku nie istnieje", + "Daily summary for day :day": "Podsumowanie dla dnia :day" }