diff --git a/composer.json b/composer.json index fdc81d9..4b75664 100644 --- a/composer.json +++ b/composer.json @@ -47,6 +47,7 @@ "require-dev": { "doctrine/doctrine-fixtures-bundle": "^3.6", "friendsofphp/php-cs-fixer": "^3.69", + "nikic/php-parser": "^5.5", "symfony/debug-bundle": "7.3.*", "symfony/maker-bundle": "^1.60", "symfony/stopwatch": "7.3.*", diff --git a/composer.lock b/composer.lock index 758d681..680037a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d035db9a327bfae49b87a5a0e08c5198", + "content-hash": "985698a147f2debf556533cf94d2217d", "packages": [ { "name": "behat/transliterator", @@ -8974,16 +8974,16 @@ }, { "name": "friendsofphp/php-cs-fixer", - "version": "v3.81.0", + "version": "v3.82.2", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", - "reference": "e00a39c729aced6c3771b9530c6e58c2efa87592" + "reference": "684ed3ab41008a2a4848de8bde17eb168c596247" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/e00a39c729aced6c3771b9530c6e58c2efa87592", - "reference": "e00a39c729aced6c3771b9530c6e58c2efa87592", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/684ed3ab41008a2a4848de8bde17eb168c596247", + "reference": "684ed3ab41008a2a4848de8bde17eb168c596247", "shasum": "" }, "require": { @@ -9067,7 +9067,7 @@ ], "support": { "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", - "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.81.0" + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.82.2" }, "funding": [ { @@ -9075,7 +9075,7 @@ "type": "github" } ], - "time": "2025-07-07T15:27:54+00:00" + "time": "2025-07-08T21:13:15+00:00" }, { "name": "nikic/php-parser", @@ -10041,7 +10041,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": true, "prefer-lowest": false, "platform": { @@ -10049,6 +10049,6 @@ "ext-ctype": "*", "ext-iconv": "*" }, - "platform-dev": [], - "plugin-api-version": "2.3.0" + "platform-dev": {}, + "plugin-api-version": "2.6.0" } diff --git a/src/Controller/BadgeController.php b/src/Controller/BadgeController.php index 79c253c..feb65da 100644 --- a/src/Controller/BadgeController.php +++ b/src/Controller/BadgeController.php @@ -16,7 +16,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; #[Route('/badge')] class BadgeController extends AbstractController { - #[Route('/project-status/{projectSlug}/{status}', name: 'app_badge_project_status')] + #[Route('/project-status/{projectSlug}/{status}/{_locale}', name: 'app_badge_project_status', requirements: ['_locale' => '(fr|en)*'])] public function index( EntityManagerInterface $entityManager, TaskLifecycleManager $taskLifecycleManager, @@ -54,9 +54,9 @@ class BadgeController extends AbstractController $xml = new \DOMDocument(); - $left = $translator->trans($stats['title']).' ('.$request->getLocale().')'; + $left = $translator->trans($stats['title'], locale: $request->getLocale()).' '; $leftColor = $colors['secondary']; - $right = sprintf(' % 3.0f%%', $stats['percentage']); + $right = sprintf('% 3.0f%%', $stats['percentage']); $rightColor = $colors[$stats['color']]; $charWidth = 7; @@ -66,7 +66,7 @@ class BadgeController extends AbstractController $verticalMargin = round(($totalHeight - $fontSize) / 2); $horizontalMargin = round($fontSize / 3); $totalWidth = round(strlen($left.$right) * $charWidth + 2 * $horizontalMargin); - $middle = floor(strlen($left) * $charWidth); + $middle = round(strlen($left) * $charWidth); $svg = $xml->createElement('svg'); $svg->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns', 'http://www.w3.org/2000/svg'); diff --git a/src/Controller/ProjectController.php b/src/Controller/ProjectController.php index f30fd42..86c8cf9 100644 --- a/src/Controller/ProjectController.php +++ b/src/Controller/ProjectController.php @@ -15,6 +15,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; +use Symfony\Contracts\Translation\TranslatorInterface; #[Route('/project')] class ProjectController extends AbstractController @@ -33,12 +34,12 @@ class ProjectController extends AbstractController // Formulaire de création d’un projet #[Route('/create', name: 'app_project_create')] #[IsGranted('ROLE_USER')] - public function create(Request $request, EntityManagerInterface $entityManager): Response + public function create(Request $request, EntityManagerInterface $entityManager, TranslatorInterface $translator): Response { $project = new Project(); $createForm = $this->createForm(ProjectType::class, $project); $createForm->add('submit', SubmitType::class, [ - 'label' => 'Créer', + 'label' => 'button.create_project', ]); $createForm->handleRequest($request); @@ -50,11 +51,11 @@ class ProjectController extends AbstractController $entityManager->persist($project); $entityManager->flush(); - $this->addFlash('success', 'Projet créé !'); + $this->addFlash('success', $translator->trans('alert.project_created')); return $this->redirectToRoute('app_project'); } catch (\Exception $exception) { - $this->addFlash('danger', 'Impossible de créer le projet !'); + $this->addFlash('danger', $translator->trans('alert.project_not_created')); } } @@ -65,11 +66,11 @@ class ProjectController extends AbstractController // Page d’un prtojet donné (où l’on voit ses tâches) #[Route('/{slug}', name: 'app_project_show')] - public function show(EntityManagerInterface $entityManager, $slug): Response + public function show(EntityManagerInterface $entityManager, TranslatorInterface $translator, $slug): Response { $project = $entityManager->getRepository(Project::class)->findOneBySlug($slug); if (!$project) { - $this->addFlash('warning', 'Projet non trouvé !'); + $this->addFlash('warning', $translator->trans('alert.project_not_found')); return $this->redirectToRoute('app_project'); } @@ -80,7 +81,9 @@ class ProjectController extends AbstractController $csvForm = $this->createForm(CsvType::class, null, [ 'action' => $this->generateUrl('app_project_import', ['slug' => $slug]), ]); - $csvForm->add('submit', SubmitType::class, ['label' => 'Importer']); + $csvForm->add('submit', SubmitType::class, [ + 'label' => 'button.import', + ]); $comments = $entityManager->getRepository(Comment::class)->findLatestByProject($project); // Commentaires agrégés de toutes les tâches du projet @@ -96,11 +99,11 @@ class ProjectController extends AbstractController // Import de tâches dans un projet #[Route('/{slug}/import', name: 'app_project_import')] #[IsGranted('ROLE_USER')] - public function import(Request $request, EntityManagerInterface $entityManager, $slug): Response + public function import(Request $request, EntityManagerInterface $entityManager, TranslatorInterface $translator, $slug): Response { $project = $entityManager->getRepository(Project::class)->findOneBySlug($slug); if (!$project) { - $this->addFlash('warning', 'Projet non trouvé !'); + $this->addFlash('warning', $translator->trans('alert.project_not_found')); return $this->redirectToRoute('app_project'); } @@ -143,20 +146,20 @@ class ProjectController extends AbstractController // Page de modification du projet #[Route('/{slug}/update', name: 'app_project_update')] #[IsGranted('ROLE_USER')] - public function update(Request $request, EntityManagerInterface $entityManager, $slug): Response + public function update(Request $request, EntityManagerInterface $entityManager, TranslatorInterface $translator, $slug): Response { $repository = $entityManager->getRepository(Project::class); $project = $repository->findOneBySlug($slug); if (!$project) { - $this->addFlash('warning', 'Projet non trouvé !'); + $this->addFlash('warning', $translator->trans('alert.project_not_found')); return $this->redirectToRoute('app_project'); } $updateForm = $this->createForm(ProjectType::class, $project); $updateForm->add('submit', SubmitType::class, [ - 'label' => 'Modifier', + 'label' => 'button.update_project', ]); $updateForm->handleRequest($request); @@ -167,11 +170,11 @@ class ProjectController extends AbstractController $entityManager->persist($project); $entityManager->flush(); - $this->addFlash('success', 'Projet modifié !'); + $this->addFlash('success', $translator->trans('alert.project_updated')); return $this->redirectToRoute('app_project_show', ['slug' => $slug]); } catch (\Exception $exception) { - $this->addFlash('danger', 'Impossible de mopdifier le projet !'); + $this->addFlash('danger', $translator->trans('alert.project_not_updated')); } } @@ -184,13 +187,13 @@ class ProjectController extends AbstractController // La suppression d’un projet passe par là #[Route('/{slug}/remove', name: 'app_project_remove')] #[IsGranted('ROLE_USER')] - public function remove(EntityManagerInterface $entityManager, $slug): Response + public function remove(EntityManagerInterface $entityManager, TranslatorInterface $translator, $slug): Response { $repository = $entityManager->getRepository(Project::class); $project = $repository->findOneBySlug($slug); if (!$project) { - $this->addFlash('warning', 'Projet non trouvé !'); + $this->addFlash('warning', $translator->trans('alert.project_not_found')); return $this->redirectToRoute('app_project'); } @@ -199,9 +202,11 @@ class ProjectController extends AbstractController $entityManager->remove($project); $entityManager->flush(); + $this->addFlash('success', $translator->trans('alert.project_removed')); + return $this->redirectToRoute('app_project'); } catch (\Exception $exception) { - $this->addFlash('danger', 'Impossible de supprimer le projet !'); + $this->addFlash('danger', $translator->trans('alert.project_not_removed')); } return $this->redirectToRoute('app_project'); @@ -210,25 +215,25 @@ class ProjectController extends AbstractController // Effectue la requête Overpass liée au projet #[Route('/{slug}/overpass', name: 'app_project_overpass')] #[IsGranted('ROLE_USER')] - public function overpass(OverpassClient $overpassClient, EntityManagerInterface $entityManager, $slug): Response + public function overpass(OverpassClient $overpassClient, EntityManagerInterface $entityManager, TranslatorInterface $translator, $slug): Response { $repository = $entityManager->getRepository(Project::class); $project = $repository->findOneBySlug($slug); if (!$project) { - $this->addFlash('warning', 'Projet non trouvé !'); + $this->addFlash('warning', $translator->trans('alert.project_not_found')); return $this->redirectToRoute('app_project'); } if (!$project->hasOverpassQuery()) { - $this->addFlash('warning', 'Ce projet n’a pas de requête Overpass !'); + $this->addFlash('warning', $translator->trans('alert.no_overpass_query')); return $this->redirectToRoute('app_project_show', ['slug' => $project->getSlug()]); } if ($project->hasOverpassResult() and !$project->isOverpassResultOutdated()) { - $this->addFlash('warning', 'Merci d’attendre un peu avant de requêter de nouveau Overpass !'); + $this->addFlash('warning', $translator->trans('alert.overpass_please_wait')); return $this->redirectToRoute('app_project_show', ['slug' => $project->getSlug()]); } diff --git a/src/Controller/TaskController.php b/src/Controller/TaskController.php index 8ee41af..cf84da0 100644 --- a/src/Controller/TaskController.php +++ b/src/Controller/TaskController.php @@ -20,6 +20,7 @@ use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Security\Http\Attribute\IsGranted; use Symfony\Component\Workflow\WorkflowInterface; +use Symfony\Contracts\Translation\TranslatorInterface; #[Route('/task')] class TaskController extends AbstractController @@ -27,10 +28,10 @@ class TaskController extends AbstractController // Page de créatiom d’une tâche #[Route('/create', name: 'app_task_create')] #[IsGranted('ROLE_USER')] - public function create(Request $request, EntityManagerInterface $entityManager): Response + public function create(Request $request, EntityManagerInterface $entityManager, TranslatorInterface $translator): Response { if (!$request->query->has('slug')) { - $this->addFlash('warning', 'Projet non spécifié !'); + $this->addFlash('warning', $translator->trans('alert.missing_project')); return $this->redirectToRoute('app_project'); } @@ -41,7 +42,7 @@ class TaskController extends AbstractController $project = $repository->findOneBySlug($slug); if (!$project) { - $this->addFlash('warning', 'Projet non trouvé !'); + $this->addFlash('warning', $translator->trans('alert.project_not_found')); return $this->redirectToRoute('app_project'); } @@ -50,7 +51,7 @@ class TaskController extends AbstractController $task->setProject($project); $createForm = $this->createForm(TaskType::class, $task); $createForm->add('submit', SubmitType::class, [ - 'label' => 'Créer', + 'label' => 'button.create', ]); $createForm->handleRequest($request); @@ -65,11 +66,11 @@ class TaskController extends AbstractController $entityManager->persist($task); $entityManager->flush(); - $this->addFlash('success', 'Tâche créée !'); + $this->addFlash('success', $translator->trans('alert.task_created')); return $this->redirectToRoute('app_project_show', ['slug' => $slug]); } catch (\Exception $exception) { - $this->addFlash('danger', 'Impossible de créer la tâche !'); + $this->addFlash('danger', $translator->trans('alert.task_not_created')); } } @@ -81,16 +82,16 @@ class TaskController extends AbstractController // Page spécifique à une tâche, où l’on trouve tout ce qui la concerne #[Route('/{slug}', name: 'app_task_show')] - public function show(Request $request, EntityManagerInterface $entityManager, GeoJsonManager $geoJsonManager, $slug): Response + public function show(Request $request, EntityManagerInterface $entityManager, GeoJsonManager $geoJsonManager, TranslatorInterface $translator, $slug): Response { $repository = $entityManager->getRepository(Task::class); $task = $repository->findOneBySlug($slug); if (!$task) { - $this->addFlash('warning', 'Tâche non trouvée !'); + $this->addFlash('warning', $translator->trans('alert.task_not_found')); if (!$request->headers->has('Referer')) { - throw $this->createNotFoundException('Task not found'); + throw $this->createNotFoundException($translator->trans('exception.task_not_found')); } return $this->redirect($request->headers->get('Referer')); @@ -104,7 +105,7 @@ class TaskController extends AbstractController 'action' => $this->generateUrl('app_task_comment', ['slug' => $slug]), ]); $commentForm->add('submit', SubmitType::class, [ - 'label' => 'Commenter', + 'label' => 'button.comment', ]); // Programmation de la télécommande JOSM @@ -157,13 +158,13 @@ class TaskController extends AbstractController // Ajoute un commentaire à la tâche #[Route('/{slug}/comment', name: 'app_task_comment')] #[IsGranted('ROLE_USER')] - public function comment(Request $request, EntityManagerInterface $entityManager, $slug): Response + public function comment(Request $request, EntityManagerInterface $entityManager, TranslatorInterface $translator, $slug): Response { $repository = $entityManager->getRepository(Task::class); $task = $repository->findOneBySlug($slug); if (!$task) { - $this->addFlash('warning', 'Tâche non trouvée !'); + $this->addFlash('warning', $translator->trans('alert.task_not_found')); return $this->redirect($request->headers->get('Referer')); } @@ -173,7 +174,7 @@ class TaskController extends AbstractController $comment->setTask($task); $commentForm = $this->createForm(CommentType::class, $comment); $commentForm->add('submit', SubmitType::class, [ - 'label' => 'Commenter', + 'label' => 'button.comment', ]); $commentForm->handleRequest($request); @@ -184,7 +185,7 @@ class TaskController extends AbstractController $entityManager->persist($comment); $entityManager->flush(); } catch (\Exception $exception) { - $this->addFlash('danger', 'Impossible de commenter ! '.$exception->getMessage()); + $this->addFlash('danger', $translator->trans('alert.can_not_comment')); } } @@ -194,20 +195,20 @@ class TaskController extends AbstractController // Modifie les informations d’une tâche #[Route('/{slug}/update', name: 'app_task_update')] #[IsGranted('ROLE_USER')] - public function update(Request $request, EntityManagerInterface $entityManager, $slug): Response + public function update(Request $request, EntityManagerInterface $entityManager, TranslatorInterface $translator, $slug): Response { $repository = $entityManager->getRepository(Task::class); $task = $repository->findOneBySlug($slug); if (!$task) { - $this->addFlash('warning', 'Tâche non trouvée !'); + $this->addFlash('warning', $translator->trans('alert.task_not_found')); return $this->redirect($request->headers->get('Referer')); } $updateForm = $this->createForm(TaskType::class, $task); $updateForm->add('submit', SubmitType::class, [ - 'label' => 'Modifier', + 'label' => 'button.update', ]); $updateForm->handleRequest($request); @@ -220,7 +221,7 @@ class TaskController extends AbstractController return $this->redirectToRoute('app_task_show', ['slug' => $slug]); } catch (\Exception $exception) { - $this->addFlash('danger', 'Impossible de modifier la tâche !'); + $this->addFlash('danger', $translator->trans('alert.task_not_updated')); } } @@ -234,13 +235,13 @@ class TaskController extends AbstractController // Supprimer une tâche #[Route('/{slug}/remove', name: 'app_task_remove')] #[IsGranted('ROLE_USER')] - public function remove(Request $request, EntityManagerInterface $entityManager, $slug): Response + public function remove(Request $request, EntityManagerInterface $entityManager, TranslatorInterface $translator, $slug): Response { $repository = $entityManager->getRepository(Task::class); $task = $repository->findOneBySlug($slug); if (!$task) { - $this->addFlash('warning', 'Tâche non trouvée !'); + $this->addFlash('warning', $translator->trans('alert.task_not_found')); return $this->redirect($request->headers->get('Referer')); } @@ -253,20 +254,20 @@ class TaskController extends AbstractController return $this->redirectToRoute('app_project_show', ['slug' => $project->getSlug()]); } catch (\Exception $exception) { - $this->addFlash('danger', 'Impossible de supprimer la tâche !'); + $this->addFlash('danger', $translator->trans('alert.task_not_removed')); } return $this->redirectToRoute('app_project_show', ['slug' => $slug]); } // Passe une tâche d’un état à un autre - private function transition(WorkflowInterface $taskLifecycleStateMachine, EntityManagerInterface $entityManager, $slug, $transitionName): Response + private function transition(WorkflowInterface $taskLifecycleStateMachine, EntityManagerInterface $entityManager, TranslatorInterface $translator, $slug, $transitionName): Response { $repository = $entityManager->getRepository(Task::class); $task = $repository->findOneBySlug($slug); if (!$task) { - $this->addFlash('warning', 'Tâche non trouvée !'); + $this->addFlash('warning', $translator->trans('alert.task_not_found')); return $this->redirectToRoute('app_project'); } @@ -278,7 +279,7 @@ class TaskController extends AbstractController $entityManager->flush(); } catch (Exception $exception) { - $this->addFlash('warning', 'Impossible de modifier la tâche !'); + $this->addFlash('warning', $translator->trans('exception.task_not_updated')); } return $this->redirectToRoute('app_task_show', ['slug' => $slug]); @@ -287,48 +288,48 @@ class TaskController extends AbstractController // Commence une tâche #[Route('/{slug}/start', name: 'app_task_start')] #[IsGranted('ROLE_USER')] - public function start(WorkflowInterface $taskLifecycleStateMachine, EntityManagerInterface $entityManager, $slug): Response + public function start(WorkflowInterface $taskLifecycleStateMachine, EntityManagerInterface $entityManager, TranslatorInterface $translator, $slug): Response { - return $this->transition($taskLifecycleStateMachine, $entityManager, $slug, Task::TRANSITION_START); + return $this->transition($taskLifecycleStateMachine, $entityManager, $translator, $slug, Task::TRANSITION_START); } // Termine une tâche #[Route('/{slug}/finish', name: 'app_task_finish')] #[IsGranted('ROLE_USER')] - public function finish(WorkflowInterface $taskLifecycleStateMachine, EntityManagerInterface $entityManager, $slug): Response + public function finish(WorkflowInterface $taskLifecycleStateMachine, EntityManagerInterface $entityManager, TranslatorInterface $translator, $slug): Response { - return $this->transition($taskLifecycleStateMachine, $entityManager, $slug, Task::TRANSITION_FINISH); + return $this->transition($taskLifecycleStateMachine, $entityManager, $translator, $slug, Task::TRANSITION_FINISH); } // Abandonne une tâche #[Route('/{slug}/cancel', name: 'app_task_cancel')] #[IsGranted('ROLE_USER')] - public function cancel(WorkflowInterface $taskLifecycleStateMachine, EntityManagerInterface $entityManager, $slug): Response + public function cancel(WorkflowInterface $taskLifecycleStateMachine, EntityManagerInterface $entityManager, TranslatorInterface $translator, $slug): Response { - return $this->transition($taskLifecycleStateMachine, $entityManager, $slug, Task::TRANSITION_CANCEL); + return $this->transition($taskLifecycleStateMachine, $entityManager, $translator, $slug, Task::TRANSITION_CANCEL); } // Recommence une tâche #[Route('/{slug}/reset', name: 'app_task_reset')] #[IsGranted('ROLE_USER')] - public function reset(WorkflowInterface $taskLifecycleStateMachine, EntityManagerInterface $entityManager, $slug): Response + public function reset(WorkflowInterface $taskLifecycleStateMachine, EntityManagerInterface $entityManager, TranslatorInterface $translator, $slug): Response { - return $this->transition($taskLifecycleStateMachine, $entityManager, $slug, Task::TRANSITION_RESET); + return $this->transition($taskLifecycleStateMachine, $entityManager, $translator, $slug, Task::TRANSITION_RESET); } // Renvoie le geojson associé à une tâche #[Route('/download/{slug}.geojson', name: 'app_task_geojson')] #[IsGranted('ROLE_USER')] - public function geojson(Request $request, EntityManagerInterface $entityManager, $slug): Response + public function geojson(Request $request, EntityManagerInterface $entityManager, TranslatorInterface $translator, $slug): Response { $repository = $entityManager->getRepository(Task::class); $task = $repository->findOneBySlug($slug); if (!$task) { - $this->addFlash('warning', 'Tâche non trouvée !'); + $this->addFlash('warning', $translator->trans('alert.task_not_found')); if (!$request->headers->has('Referer')) { - throw $this->createNotFoundException('Task not found'); + throw $this->createNotFoundException($translator->trans('exception.task_not_found')); } return $this->redirect($request->headers->get('Referer')); @@ -351,15 +352,15 @@ class TaskController extends AbstractController // Renvoie le gpx associé ã une tâche (concrètement il s’agit juste du geojson converti automqtiquement) #[Route('/download/{slug}.gpx', name: 'app_task_gpx')] #[IsGranted('ROLE_USER')] - public function gpx(Request $request, EntityManagerInterface $entityManager, $slug): Response + public function gpx(Request $request, EntityManagerInterface $entityManager, TranslatorInterface $translator, $slug): Response { $repository = $entityManager->getRepository(Task::class); $task = $repository->findOneBySlug($slug); if (!$task) { - $this->addFlash('warning', 'Tâche non trouvée !'); + $this->addFlash('warning', $translator->trans('alert.task_not_found')); if (!$request->headers->has('Referer')) { - throw $this->createNotFoundException('Task not found'); + throw $this->createNotFoundException($translator->trans('exception.task_not_found')); } return $this->redirect($request->headers->get('Referer')); @@ -390,7 +391,7 @@ class TaskController extends AbstractController // Renvoie le XML OSM associé à la tâche #[Route('/download/{slug}.osm', name: 'app_task_osm')] #[IsGranted('PUBLIC_ACCESS')] - public function osm(Request $request, EntityManagerInterface $entityManager, $slug): Response + public function osm(Request $request, EntityManagerInterface $entityManager, TranslatorInterface $translator, $slug): Response { $repository = $entityManager->getRepository(Task::class); $task = $repository->findOneBySlug($slug); @@ -398,7 +399,7 @@ class TaskController extends AbstractController if (!$task) { $this->addFlash( 'warning', - 'Tâche non trouvée !' + $translator->trans('alert.task_not_found') ); return $this->redirect($request->headers->get('referer')); @@ -424,13 +425,13 @@ class TaskController extends AbstractController // corresponddre à ce que l’on a pu importer) #[Route('/download/{slug}.csv', name: 'app_task_csv')] #[IsGranted('ROLE_USER')] - public function csv(Request $request, EntityManagerInterface $entityManager, $slug): Response + public function csv(Request $request, EntityManagerInterface $entityManager, TranslatorInterface $translator, $slug): Response { $repository = $entityManager->getRepository(Project::class); $project = $repository->findOneBySlug($slug); if (!$project) { - $this->addFlash('warning', 'Projet non trouvé !'); + $this->addFlash('warning', $translator->trans('alert.project_not_found')); return $this->redirect($request->headers->get('referer')); } diff --git a/src/Controller/ToolsController.php b/src/Controller/ToolsController.php index 5f7ac62..9fe9a6f 100644 --- a/src/Controller/ToolsController.php +++ b/src/Controller/ToolsController.php @@ -31,7 +31,9 @@ class ToolsController extends AbstractController OverpassClient $overpass, ): Response { $form = $this->createForm(CityToolType::class, []); - $form->add('submit', SubmitType::class, ['label' => 'Générer']); + $form->add('submit', SubmitType::class, [ + 'label' => 'button.generate', + ]); $form->handleRequest($request); if ($form->isSubmitted() and $form->isValid()) { @@ -101,7 +103,9 @@ class ToolsController extends AbstractController LoggerInterface $logger, ): Response { $form = $this->createForm(OsmoseToolType::class, array_merge(['limit' => 500], $request->query->all())); - $form->add('submit', SubmitType::class, ['label' => 'Générer']); + $form->add('submit', SubmitType::class, [ + 'label' => 'button.generate', + ]); $form->handleRequest($request); if ($form->isSubmitted() and $form->isValid()) { diff --git a/src/Form/CityToolType.php b/src/Form/CityToolType.php index d0b7548..2343de3 100644 --- a/src/Form/CityToolType.php +++ b/src/Form/CityToolType.php @@ -46,8 +46,9 @@ class CityToolType extends AbstractType $builder ->add('area', ChoiceType::class, [ - 'label' => 'Département', + 'label' => 'field.city_tool.area', 'choices' => $choices, + 'choice_translation_domain' => false, ]) ; } diff --git a/src/Form/CsvType.php b/src/Form/CsvType.php index de25cf5..8c51457 100644 --- a/src/Form/CsvType.php +++ b/src/Form/CsvType.php @@ -14,7 +14,7 @@ class CsvType extends AbstractType $builder ->add('csv', FileType::class, [ 'mapped' => false, - 'label' => 'Fichier CSV', + 'label' => 'field.csv.csv', 'constraints' => [ new File([ 'maxSize' => '40M', @@ -22,10 +22,10 @@ class CsvType extends AbstractType 'text/csv', 'text/plain', ], - 'mimeTypesMessage' => 'Type MIME inattendu', + 'mimeTypesMessage' => 'field.csv.csv_mime_constraint', ]), ], - 'help' => 'Fichier CSV classique (encodé en UTF8, séparé par des virgules, entouré avec des doubles guillemets, échappé avec des barres obliques et avec des retours chariots UNIX) contenant une ligne de noms de colonnes « name,description,osm,geojson,status » et enfin dans la colonne « status » la valeur « todo », « doing » ou « done ».', + 'help' => 'field.csv.csv_help', ]) ; } diff --git a/src/Form/OsmoseToolType.php b/src/Form/OsmoseToolType.php index 4ee93d4..32b6d7c 100644 --- a/src/Form/OsmoseToolType.php +++ b/src/Form/OsmoseToolType.php @@ -13,22 +13,22 @@ class OsmoseToolType extends AbstractType { $builder ->add('item', IntegerType::class, [ - 'label' => 'Item', + 'label' => 'field.osmose_tool.item', 'help_html' => true, - 'help' => 'Voir la liste sur le wiki', + 'help' => 'field.osmose_tool.item_help', ]) ->add('source', IntegerType::class, [ - 'label' => 'Identifiant source', + 'label' => 'field.osmose_tool.source', ]) ->add('class', IntegerType::class, [ - 'label' => 'Identifiant de la classe', + 'label' => 'field.osmose_tool.class', ]) ->add('limit', IntegerType::class, [ - 'label' => 'Limite', - 'help' => 'Nombre mmaximal de signalements à renvoyer', + 'label' => 'field.osmose_tool.limit', + 'help' => 'field.osmose_tool.limit_help', ]) ->add('group_by_city', CheckboxType::class, [ - 'label' => 'Grouper par commune', + 'label' => 'field.osmose_tool.group_by_city', 'required' => false, ]) ; diff --git a/src/Form/ProjectType.php b/src/Form/ProjectType.php index e4423df..2fad624 100644 --- a/src/Form/ProjectType.php +++ b/src/Form/ProjectType.php @@ -14,31 +14,35 @@ class ProjectType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options): void { $builder - ->add('name', null, ['label' => 'Nom']) - ->add('description', null, ['label' => 'Description']) + ->add('name', null, [ + 'label' => 'field.project.name', + ]) + ->add('description', null, [ + 'label' => 'field.project.description', + ]) ->add('hashtags', null, [ - 'label' => 'Hashtags', + 'label' => 'field.project.hashtags', 'help_html' => true, - 'help' => 'Mots séparés par des espaces, sans #', + 'help' => 'field.project.hashtags_help', ]) ->add('source', null, [ - 'label' => 'Source', + 'label' => 'field.project.source', 'help_html' => true, - 'help' => 'On peut en préciser plusieurs, en les séparant par des ;', + 'help' => 'field.project.source_help', ]) ->add('imagery', null, [ - 'label' => 'Imagerie', + 'label' => 'field.project.imagery', 'help_html' => true, - 'help' => 'Cf le wiki', + 'help' => 'field.project.imagery_help', ]) ->add('overpassQuery', null, [ - 'label' => 'Requête Overpass', + 'label' => 'field.project.overpass', 'required' => false, 'help_html' => true, - 'help' => 'Cf le frontal. Se limiter à la requête stricto sensu, sans [out:json][timeout:25]; avant ou out geom; après.', + 'help' => 'field.project.overpass_help', ]) ->add('tags', EntityType::class, [ - 'label' => 'Étiquettes', + 'label' => 'field.project.tags', 'class' => Tag::class, 'choice_label' => 'name', 'multiple' => true, diff --git a/src/Form/TaskType.php b/src/Form/TaskType.php index 4153dda..1c2dc07 100644 --- a/src/Form/TaskType.php +++ b/src/Form/TaskType.php @@ -14,36 +14,36 @@ class TaskType extends AbstractType { $builder ->add('name', null, [ - 'label' => 'Nom', + 'label' => 'field.task.name', ]) ->add('description', null, [ - 'label' => 'Description', + 'label' => 'field.task.description', ]) ->add('geojson', TextareaType::class, [ - 'label' => 'GeoJSON', + 'label' => 'field.task.geojson', 'required' => false, 'help_html' => true, - 'help' => 'Ce qu’il faut dessiner sur la carte au format GeoJSON et mettre à disposition à l’export sous forme de GPX pour l’import dans JOSM. Outil pratique : geojson.io.', + 'help' => 'field.task.geojson_help', ]) ->add('osm', TextareaType::class, [ - 'label' => 'OSM', + 'label' => 'field.task.osm', 'required' => false, 'help_html' => true, - 'help' => 'XML décrivant ce qu’il faut charger dans la feuille de données de JOSM (cf FR:OSM XML - OpenStreetMap Wiki)', + 'help' => 'field.task.osm_help', 'empty_data' => '', ]) ->add('status', TaskLifecycleType::class, [ - 'label' => 'État', + 'label' => 'field.task.status', ]) ->add('urgent', null, [ - 'label' => 'Urgence', + 'label' => 'field.task.urgent', 'required' => false, - 'help' => 'Un entier signé optionnel.', + 'help' => 'field.task.urgent_help', ]) ->add('important', null, [ - 'label' => 'Importance', + 'label' => 'field.task.important', 'required' => false, - 'help' => 'Un entier signé optionnel.', + 'help' => 'field.task.important_help', ]) ; } diff --git a/templates/comment/cancel.md.twig b/templates/comment/cancel.md.twig index 831663f..a11ee80 100644 --- a/templates/comment/cancel.md.twig +++ b/templates/comment/cancel.md.twig @@ -1,2 +1,6 @@ {% import 'macro.html.twig' as macro %} -{{ macro.osmLinkTo(user.username) }} abandonne la tâche [{{ task.name }}]({{ path('app_task_show', {'slug': task.slug}) }}) +{{ 'comment.cancel'|trans({ + '%username%': macro.osmLinkTo(user.username), + '%task_name%': task.name, + '%task_url%': path('app_task_show', {'slug': task.slug}) +}) }} diff --git a/templates/comment/finish.md.twig b/templates/comment/finish.md.twig index cc1e34c..a0beed7 100644 --- a/templates/comment/finish.md.twig +++ b/templates/comment/finish.md.twig @@ -1,2 +1,6 @@ {% import 'macro.html.twig' as macro %} -{{ macro.osmLinkTo(user.username) }} termine la tâche [{{ task.name }}]({{ path('app_task_show', {'slug': task.slug}) }}) +{{ 'comment.finish'|trans({ + '%username%': macro.osmLinkTo(user.username), + '%task_name%': task.name, + '%task_url%': path('app_task_show', {'slug': task.slug}) +}) }} diff --git a/templates/comment/reset.md.twig b/templates/comment/reset.md.twig index 656d852..b06b98a 100644 --- a/templates/comment/reset.md.twig +++ b/templates/comment/reset.md.twig @@ -1,2 +1,6 @@ {% import 'macro.html.twig' as macro %} -{{ macro.osmLinkTo(user.username) }} recommence la tâche [{{ task.name }}]({{ path('app_task_show', {'slug': task.slug}) }}) +{{ 'comment.reset'|trans({ + '%username%': macro.osmLinkTo(user.username), + '%task_name%': task.name, + '%task_url%': path('app_task_show', {'slug': task.slug}) +}) }} diff --git a/templates/comment/start.md.twig b/templates/comment/start.md.twig index 561036a..d64a6e3 100644 --- a/templates/comment/start.md.twig +++ b/templates/comment/start.md.twig @@ -1,6 +1,6 @@ {% import 'macro.html.twig' as macro %} {{ 'comment.start'|trans({ '%username%': macro.osmLinkTo(user.username), - '%task_name%': task.name }}, + '%task_name%': task.name, '%task_url%': path('app_task_show', {'slug': task.slug}) }) }} diff --git a/templates/macro.html.twig b/templates/macro.html.twig index d8fac4d..8fdeb70 100644 --- a/templates/macro.html.twig +++ b/templates/macro.html.twig @@ -53,7 +53,7 @@ Où : {% endfor %}
- {{ 'map.open_with'|trans }} {{ 'map.or'|trans }} + {{ 'map.open_with'|trans }} diff --git a/templates/partials/_task-title.html.twig b/templates/partials/_task-title.html.twig index 0a41e8a..f2239c9 100644 --- a/templates/partials/_task-title.html.twig +++ b/templates/partials/_task-title.html.twig @@ -1,2 +1,2 @@ {{ task.name }} - + diff --git a/templates/project/create.html.twig b/templates/project/create.html.twig index aabc8ce..ac95f76 100644 --- a/templates/project/create.html.twig +++ b/templates/project/create.html.twig @@ -1,11 +1,11 @@ {% extends 'base.html.twig' %} {% block breadcrumb %} -
{% include 'partials/_project-metadata.html.twig' %}
{% if project.description %}{{ project.description|markdown_to_html }}
{% endif %} - Voir le détail + {{ 'button.details'|trans }} @@ -39,7 +39,7 @@ {% else %} {% if not is_granted('IS_AUTHENTICATED_FULLY') %} -Il n’y a pas encore de projet. Connectez-vous pour pouvoir en créer un.
+{{ 'text.login_to_create_project'|trans }}
{% endif %} {% endif %} {% endblock %} diff --git a/templates/project/show.html.twig b/templates/project/show.html.twig index 1eb2e26..cfd3fae 100644 --- a/templates/project/show.html.twig +++ b/templates/project/show.html.twig @@ -2,7 +2,7 @@ {% import 'macro.html.twig' as macro %} {% block breadcrumb %} -