From 4204a06b7726597dc84fe34b39c53f1534a86140 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Fri, 11 Mar 2016 14:48:46 +0100 Subject: Add flashes messages --- src/Wallabag/ImportBundle/Controller/PocketController.php | 8 ++++++-- src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php | 9 ++++++--- src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php | 9 ++++++--- 3 files changed, 18 insertions(+), 8 deletions(-) (limited to 'src/Wallabag/ImportBundle/Controller') diff --git a/src/Wallabag/ImportBundle/Controller/PocketController.php b/src/Wallabag/ImportBundle/Controller/PocketController.php index 7a35514b..1d804219 100644 --- a/src/Wallabag/ImportBundle/Controller/PocketController.php +++ b/src/Wallabag/ImportBundle/Controller/PocketController.php @@ -52,8 +52,9 @@ class PocketController extends Controller */ public function callbackAction() { - $message = 'Import failed, please try again.'; + $message = 'flashes.import.notice.failed'; $pocket = $this->get('wallabag_import.pocket.import'); + $markAsRead = $this->get('session')->get('mark_as_read'); $this->get('session')->remove('mark_as_read'); @@ -69,7 +70,10 @@ class PocketController extends Controller if (true === $pocket->setMarkAsRead($markAsRead)->import()) { $summary = $pocket->getSummary(); - $message = 'Import summary: '.$summary['imported'].' imported, '.$summary['skipped'].' already saved.'; + $message = $this->get('translator')->trans('flashes.import.notice.summary', array( + '%imported%' => $summary['imported'], + '%skipped%' => $summary['skipped'], + )); } $this->get('session')->getFlashBag()->add( diff --git a/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php b/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php index 154a0769..1bc9696d 100644 --- a/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php +++ b/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php @@ -31,11 +31,14 @@ class WallabagV1Controller extends Controller ->setMarkAsRead($markAsRead) ->import(); - $message = 'Import failed, please try again.'; + $message = 'flashes.import.notice.failed'; if (true === $res) { $summary = $wallabag->getSummary(); - $message = 'Import summary: '.$summary['imported'].' imported, '.$summary['skipped'].' already saved.'; + $message = $this->get('translator')->trans('flashes.import.notice.summary', array( + '%imported%' => $summary['imported'], + '%skipped%' => $summary['skipped'], + )); unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name); } @@ -49,7 +52,7 @@ class WallabagV1Controller extends Controller } else { $this->get('session')->getFlashBag()->add( 'notice', - 'Error while processing import. Please verify your import file.' + 'flashes.import.notice.failed_on_file' ); } } diff --git a/src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php b/src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php index 6dcd204a..3e6428a0 100644 --- a/src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php +++ b/src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php @@ -31,11 +31,14 @@ class WallabagV2Controller extends Controller ->setMarkAsRead($markAsRead) ->import(); - $message = 'Import failed, please try again.'; + $message = 'flashes.import.notice.failed'; if (true === $res) { $summary = $wallabag->getSummary(); - $message = 'Import summary: '.$summary['imported'].' imported, '.$summary['skipped'].' already saved.'; + $message = $this->get('translator')->trans('flashes.import.notice.summary', array( + '%imported%' => $summary['imported'], + '%skipped%' => $summary['skipped'], + )); unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name); } @@ -49,7 +52,7 @@ class WallabagV2Controller extends Controller } else { $this->get('session')->getFlashBag()->add( 'notice', - 'Error while processing import. Please verify your import file.' + 'flashes.import.notice.failed_on_file' ); } } -- cgit v1.2.3