translate flash messages

This commit is contained in:
2018-05-04 11:10:56 +02:00
parent a12701b97f
commit cabd863245
2 changed files with 25 additions and 13 deletions

View File

@@ -22,6 +22,7 @@ use Chill\PersonBundle\Entity\PersonRepository;
use Chill\MainBundle\Entity\UserRepository;
use Chill\TaskBundle\Event\TaskEvent;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Translation\TranslatorInterface;
class SingleTaskController extends Controller
{
@@ -34,7 +35,8 @@ class SingleTaskController extends Controller
*/
public function newAction(
Request $request,
EventDispatcherInterface $dispatcher
EventDispatcherInterface $dispatcher,
TranslatorInterface $translator
) {
$task = (new SingleTask())
@@ -76,14 +78,14 @@ class SingleTaskController extends Controller
$em->flush();
$this->addFlash('success', "The task is created");
$this->addFlash('success', $translator->trans("The task is created"));
return $this->redirectToRoute('chill_task_singletask_list', [
'person_id' => $task->getPerson()->getId()
]);
} else {
$this->addFlash('error', "This form contains errors");
$this->addFlash('error', $translator->trans("This form contains errors"));
}
}
@@ -141,8 +143,11 @@ class SingleTaskController extends Controller
* name="chill_task_single_task_edit"
* )
*/
public function editAction(Request $request, $id)
{
public function editAction(
Request $request,
$id,
TranslatorInterface $translator
) {
/* @var $taskRepository SingleTaskRepository */
$taskRepository = $this->get('chill_task.single_task_repository');
@@ -180,14 +185,15 @@ class SingleTaskController extends Controller
$em->flush();
$this->addFlash('success', "The task has been updated");
$this->addFlash('success', $translator
->trans("The task has been updated"));
return $this->redirectToRoute('chill_task_singletask_list', [
'person_id' => $task->getPerson()->getId()
]);
} else {
$this->addFlash('error', "This form contains errors");
$this->addFlash('error', $translator->trans("This form contains errors"));
}
}
@@ -204,8 +210,11 @@ class SingleTaskController extends Controller
* name="chill_task_single_task_delete"
* )
*/
public function deleteAction(Request $request, $id)
{
public function deleteAction(
Request $request,
$id,
TranslatorInterface $translator
) {
/* @var $taskRepository SingleTaskRepository */
$taskRepository = $this->get('chill_task.single_task_repository');
@@ -258,7 +267,7 @@ class SingleTaskController extends Controller
$em->remove($task);
$em->flush();
$this->addFlash('success', $this->get('translator')
$this->addFlash('success', $translator
->trans("The task has been successfully removed."));
return $this->redirect($this->generateUrl(