#132 - added translations

This commit is contained in:
EwelinaLasowy 2022-05-06 08:01:09 +02:00
parent 3404bf1da8
commit 35b5b344b6
19 changed files with 69 additions and 38 deletions

View File

@ -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,
]);
}

View File

@ -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,
]);
}

View File

@ -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.");
}
}

View File

@ -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:"));
}
}

View File

@ -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:"));
}
}

View File

@ -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"));
}
}

View File

@ -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:"));
}
}

View File

@ -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]);
});
}
}

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")
];
}
}

View File

@ -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");
}
}

View File

@ -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;

View File

@ -37,7 +37,7 @@ trait ListsHandlers
)
->map(
fn(SignatureHandler $handler): AttachmentField => AttachmentField::create(
$handler->getDescription(),
__($handler->getDescription()) ,
"`/{$handler->getSignature()}`",
),
)

View File

@ -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"
}