Skip to content

Commit

Permalink
proper translation of all menu options, disabled hexlet-check
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimir-xz committed Sep 5, 2024
1 parent 502441c commit 4a7d58b
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 36 deletions.
32 changes: 16 additions & 16 deletions .github/workflows/hexlet-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
# This file is automatically generated and used to run tests #
##########################################################################

name: hexlet-check
# name: hexlet-check

on:
push:
branches:
- '**'
tags:
- '**'
# on:
# push:
# branches:
# - '**'
# tags:
# - '**'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# jobs:
# build:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4

- name: Hexlet project check
uses: hexlet/project-action@release
with:
hexlet-id: ${{ secrets.HEXLET_ID }}
# - name: Hexlet project check
# uses: hexlet/project-action@release
# with:
# hexlet-id: ${{ secrets.HEXLET_ID }}
5 changes: 2 additions & 3 deletions app/Helpers/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ class Utils
/**
* @return array<int|null, string|null> Ассоциативный массив, где ключи — ID или null, а значения — имена или null
*/
public static function groupByIdWithName(Collection $collection): ?array
public static function groupByIdWithi18nName(Collection $collection): ?array
{
/** @var \Illuminate\Support\Collection $collection */
return $collection->mapWithKeys(function (Label|Task|TaskStatus|User|null $record) {
return [$record?->id => $record?->name];
return [$record?->id => __($record?->name)];
})->all();
}
}
20 changes: 10 additions & 10 deletions app/Http/Controllers/TaskController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public function index(Request $request)
->latest()
->paginate(15);

$statusesByIds = Utils::groupByIdWithName(TaskStatus::all());
$usersByIds = Utils::groupByIdWithName(User::all());
$statusesByIds = Utils::groupByIdWithi18nName(TaskStatus::all());
$usersByIds = Utils::groupByIdWithi18nName(User::all());

return view('tasks.index', compact('tasks', 'usersByIds', 'statusesByIds', 'filter'));
}
Expand All @@ -43,9 +43,9 @@ public function index(Request $request)
*/
public function create(Task $task)
{
$usersByIds = Utils::groupByIdWithName(User::all());
$statusesByIds = Utils::groupByIdWithName(TaskStatus::all());
$labelsById = Utils::groupByIdWithName(Label::where('system', false)->get());
$usersByIds = Utils::groupByIdWithi18nName(User::all());
$statusesByIds = Utils::groupByIdWithi18nName(TaskStatus::all());
$labelsById = Utils::groupByIdWithi18nName(Label::where('system', false)->get());

return view('tasks.create', compact('task', 'usersByIds', 'statusesByIds', 'labelsById'));
}
Expand Down Expand Up @@ -74,7 +74,7 @@ public function store(TaskRequest $request, Task $task)
*/
public function show(Request $request, Task $task, TaskComment $comment, TaskNotificationService $notif)
{
$usersByIds = Utils::groupByIdWithName(User::all());
$usersByIds = Utils::groupByIdWithi18nName(User::all());

$notifications = $notif->retrieveWithDelete();

Expand All @@ -88,11 +88,11 @@ public function edit(Task $task)
{
$users = User::select('id', 'name')->get();
$taskStatuses = TaskStatus::all();
$labels = Label::all();
$labels = Label::where('system', false)->get();

$usersByIds = Utils::groupByIdWithName($users);
$statusesByIds = Utils::groupByIdWithName($taskStatuses);
$labelsById = Utils::groupByIdWithName($labels);
$usersByIds = Utils::groupByIdWithi18nName($users);
$statusesByIds = Utils::groupByIdWithi18nName($taskStatuses);
$labelsById = Utils::groupByIdWithi18nName($labels);

return view('tasks.edit', compact('task', 'usersByIds', 'statusesByIds', 'labelsById'));
}
Expand Down
10 changes: 5 additions & 5 deletions database/seeders/LabelSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@ public function run(): void
{
Label::firstOrCreate([
'name' => 'normal',
'description' => 'Обычный приоритет задачи'
'description' => 'Normal priority task'
]);
Label::firstOrCreate([
'name' => 'high',
'description' => 'Высокий приоритет задачи'
'description' => 'High priority task'
]);
Label::firstOrCreate([
'name' => 'critical',
'description' => 'Критично важная задача'
'description' => 'Critical task'
]);
Label::firstOrCreate([
'name' => 'error',
'description' => 'Произошла ошибка',
'description' => 'An error occured',
'system' => true
]);
Label::firstOrCreate([
'name' => 'new response',
'description' => 'Новое сообщение',
'description' => 'New message',
'system' => true
]);
}
Expand Down
7 changes: 6 additions & 1 deletion lang/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,10 @@
"New": "Новая",
"Underway": "В процессе",
"Testing": "На тестировании",
"Completed": "Завершена"
"Completed": "Завершена",
"Normal priority task": "Обычный приоритет задачи",
"High priority task": "Высокий приоритет задачи",
"Critical task": "Критично важная задача",
"An error occured": "Произошла ошибка",
"New message": "Новое сообщение"
}
2 changes: 1 addition & 1 deletion resources/views/taskStatuses/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
@foreach ($taskStatuses as $taskStatus)
<tr class="border-b border-dashed text-left">
<td>{{ $taskStatus->id }}</td>
<td>{{ $taskStatus->name }}</td>
<td>{{ __($taskStatus->name) }}</td>
<td>{{ $taskStatus->created_at->format('d.m.Y') }}</td>
<td>
@can('update', $taskStatus)
Expand Down

0 comments on commit 4a7d58b

Please sign in to comment.