diff --git a/lib/Alchemy/Phrasea/Application.php b/lib/Alchemy/Phrasea/Application.php index 33273d415f..5a305d5680 100644 --- a/lib/Alchemy/Phrasea/Application.php +++ b/lib/Alchemy/Phrasea/Application.php @@ -125,6 +125,7 @@ use Neutron\ReCaptcha\ReCaptchaServiceProvider; use PHPExiftool\PHPExiftoolServiceProvider; use Silex\Application as SilexApplication; use Silex\Application\UrlGeneratorTrait; +use Silex\Application\TranslationTrait; use Silex\Provider\FormServiceProvider; use Silex\Provider\MonologServiceProvider; use Silex\Provider\SessionServiceProvider; @@ -157,6 +158,7 @@ use Symfony\Component\Form\Exception\FormException; class Application extends SilexApplication { use UrlGeneratorTrait; + use TranslationTrait; private static $availableLanguages = [ 'de_DE' => 'Deutsch', @@ -332,7 +334,10 @@ class Application extends SilexApplication $this->register(new PluginServiceProvider()); $this['phraseanet.exception_handler'] = $this->share(function ($app) { - return PhraseaExceptionHandler::register($app['debug']); + $handler = PhraseaExceptionHandler::register($app['debug']); + $handler->setTranslator($app['translator']); + + return $handler; }); $this['swiftmailer.transport'] = $this->share(function ($app) { @@ -617,7 +622,9 @@ class Application extends SilexApplication $twig->addFilter('count', new \Twig_Filter_Function('count')); $twig->addFilter('formatOctets', new \Twig_Filter_Function('p4string::format_octets')); $twig->addFilter('base_from_coll', new \Twig_Filter_Function('phrasea::baseFromColl')); - $twig->addFilter('AppName', new \Twig_Filter_Function('Alchemy\Phrasea\Controller\Admin\ConnectedUsers::appName')); + $twig->addFilter(new \Twig_SimpleFilter('AppName', function ($value) use ($app) { + return ConnectedUsers::appName($app['translator'], $value); + })); $twig->addFilter(new \Twig_SimpleFilter('escapeSimpleQuote', function ($value) { $ret = str_replace("'", "\'", $value); diff --git a/lib/Alchemy/Phrasea/Application/Api.php b/lib/Alchemy/Phrasea/Application/Api.php index 7e88af31cb..59216d7e8e 100644 --- a/lib/Alchemy/Phrasea/Application/Api.php +++ b/lib/Alchemy/Phrasea/Application/Api.php @@ -62,7 +62,7 @@ return call_user_func(function ($environment = PhraseaApplication::ENV_PROD) { $app->mount('/api/oauthv2', new Oauth2()); $app->mount('/api/v1', new V1()); - $app['dispatcher']->addSubscriber(new ApiOauth2ErrorsSubscriber($app['phraseanet.exception_handler'])); + $app['dispatcher']->addSubscriber(new ApiOauth2ErrorsSubscriber($app['phraseanet.exception_handler'], $app['translator'])); $app['dispatcher']->dispatch(PhraseaEvents::API_LOAD_END, new ApiLoadEndEvent()); return $app; diff --git a/lib/Alchemy/Phrasea/Border/Checker/CheckerInterface.php b/lib/Alchemy/Phrasea/Border/Checker/CheckerInterface.php index 61ec638036..dbb3656405 100644 --- a/lib/Alchemy/Phrasea/Border/Checker/CheckerInterface.php +++ b/lib/Alchemy/Phrasea/Border/Checker/CheckerInterface.php @@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Border\Checker; use Alchemy\Phrasea\Border\File; use Doctrine\ORM\EntityManager; +use Symfony\Component\Translation\TranslatorInterface; /** * The checker interface @@ -39,6 +40,10 @@ interface CheckerInterface /** * Get a localized message about the Checker + * + * @param TranslatorInterface $translator A translator + * + * @return string */ - public static function getMessage(); + public static function getMessage(TranslatorInterface $translator); } diff --git a/lib/Alchemy/Phrasea/Border/Checker/Colorspace.php b/lib/Alchemy/Phrasea/Border/Checker/Colorspace.php index 523ee6e4a3..4c4f905c74 100644 --- a/lib/Alchemy/Phrasea/Border/Checker/Colorspace.php +++ b/lib/Alchemy/Phrasea/Border/Checker/Colorspace.php @@ -14,6 +14,7 @@ namespace Alchemy\Phrasea\Border\Checker; use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Border\File; use Doctrine\ORM\EntityManager; +use Symfony\Component\Translation\TranslatorInterface; class Colorspace extends AbstractChecker { @@ -60,8 +61,8 @@ class Colorspace extends AbstractChecker return new Response($boolean, $this); } - public static function getMessage() + public static function getMessage(TranslatorInterface $translator) { - return _('The file does not match available color'); + return $translator->trans('The file does not match available color'); } } diff --git a/lib/Alchemy/Phrasea/Border/Checker/Dimension.php b/lib/Alchemy/Phrasea/Border/Checker/Dimension.php index a388eb8a99..196c10661b 100644 --- a/lib/Alchemy/Phrasea/Border/Checker/Dimension.php +++ b/lib/Alchemy/Phrasea/Border/Checker/Dimension.php @@ -14,6 +14,7 @@ namespace Alchemy\Phrasea\Border\Checker; use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Border\File; use Doctrine\ORM\EntityManager; +use Symfony\Component\Translation\TranslatorInterface; class Dimension extends AbstractChecker { @@ -52,8 +53,8 @@ class Dimension extends AbstractChecker return new Response($boolean, $this); } - public static function getMessage() + public static function getMessage(TranslatorInterface $translator) { - return _('The file does not match required dimension'); + return $translator->trans('The file does not match required dimension'); } } diff --git a/lib/Alchemy/Phrasea/Border/Checker/Extension.php b/lib/Alchemy/Phrasea/Border/Checker/Extension.php index aa0911fa43..f86f02ed5d 100644 --- a/lib/Alchemy/Phrasea/Border/Checker/Extension.php +++ b/lib/Alchemy/Phrasea/Border/Checker/Extension.php @@ -14,6 +14,7 @@ namespace Alchemy\Phrasea\Border\Checker; use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Border\File; use Doctrine\ORM\EntityManager; +use Symfony\Component\Translation\TranslatorInterface; class Extension extends AbstractChecker { @@ -40,8 +41,8 @@ class Extension extends AbstractChecker return new Response($boolean, $this); } - public static function getMessage() + public static function getMessage(TranslatorInterface $translator) { - return _('The file does not match available extensions'); + return $translator->trans('The file does not match available extensions'); } } diff --git a/lib/Alchemy/Phrasea/Border/Checker/Filename.php b/lib/Alchemy/Phrasea/Border/Checker/Filename.php index 372b66ae08..81ae5cb576 100644 --- a/lib/Alchemy/Phrasea/Border/Checker/Filename.php +++ b/lib/Alchemy/Phrasea/Border/Checker/Filename.php @@ -14,6 +14,7 @@ namespace Alchemy\Phrasea\Border\Checker; use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Border\File; use Doctrine\ORM\EntityManager; +use Symfony\Component\Translation\TranslatorInterface; /** * Checks if a file with the same filename already exists in the destination databox @@ -53,8 +54,8 @@ class Filename extends AbstractChecker /** * {@inheritdoc} */ - public static function getMessage() + public static function getMessage(TranslatorInterface $translator) { - return _('A file with the same filename already exists in database'); + return $translator->trans('A file with the same filename already exists in database'); } } diff --git a/lib/Alchemy/Phrasea/Border/Checker/MediaType.php b/lib/Alchemy/Phrasea/Border/Checker/MediaType.php index bac6e15bdb..b9c2b3f483 100644 --- a/lib/Alchemy/Phrasea/Border/Checker/MediaType.php +++ b/lib/Alchemy/Phrasea/Border/Checker/MediaType.php @@ -15,6 +15,7 @@ use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Border\File; use Doctrine\ORM\EntityManager; use MediaVorus\Media\MediaInterface; +use Symfony\Component\Translation\TranslatorInterface; class MediaType extends AbstractChecker { @@ -48,8 +49,8 @@ class MediaType extends AbstractChecker return new Response($boolean, $this); } - public static function getMessage() + public static function getMessage(TranslatorInterface $translator) { - return _('The file does not match required media type'); + return $translator->trans('The file does not match required media type'); } } diff --git a/lib/Alchemy/Phrasea/Border/Checker/Response.php b/lib/Alchemy/Phrasea/Border/Checker/Response.php index 065cabdd8c..ede770c4ed 100644 --- a/lib/Alchemy/Phrasea/Border/Checker/Response.php +++ b/lib/Alchemy/Phrasea/Border/Checker/Response.php @@ -11,6 +11,8 @@ namespace Alchemy\Phrasea\Border\Checker; +use Symfony\Component\Translation\TranslatorInterface; + /** * The response of a check */ @@ -54,9 +56,9 @@ class Response * * @return string */ - public function getMessage() + public function getMessage(TranslatorInterface $translator) { - return $this->checker->getMessage(); + return $this->checker->getMessage($translator); } /** diff --git a/lib/Alchemy/Phrasea/Border/Checker/Sha256.php b/lib/Alchemy/Phrasea/Border/Checker/Sha256.php index c3987f1d42..1475d54fd9 100644 --- a/lib/Alchemy/Phrasea/Border/Checker/Sha256.php +++ b/lib/Alchemy/Phrasea/Border/Checker/Sha256.php @@ -14,6 +14,7 @@ namespace Alchemy\Phrasea\Border\Checker; use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Border\File; use Doctrine\ORM\EntityManager; +use Symfony\Component\Translation\TranslatorInterface; /** * Checks if a file with the same Sha256 checksum already exists in the @@ -42,8 +43,8 @@ class Sha256 extends AbstractChecker /** * {@inheritdoc} */ - public static function getMessage() + public static function getMessage(TranslatorInterface $translator) { - return _('A file with the same checksum already exists in database'); + return $translator->trans('A file with the same checksum already exists in database'); } } diff --git a/lib/Alchemy/Phrasea/Border/Checker/UUID.php b/lib/Alchemy/Phrasea/Border/Checker/UUID.php index 52703fb8a5..b37655a237 100644 --- a/lib/Alchemy/Phrasea/Border/Checker/UUID.php +++ b/lib/Alchemy/Phrasea/Border/Checker/UUID.php @@ -14,6 +14,7 @@ namespace Alchemy\Phrasea\Border\Checker; use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Border\File; use Doctrine\ORM\EntityManager; +use Symfony\Component\Translation\TranslatorInterface; /** * Checks if a file with the same UUID already exists in the destination databox @@ -41,8 +42,8 @@ class UUID extends AbstractChecker /** * {@inheritdoc} */ - public static function getMessage() + public static function getMessage(TranslatorInterface $translator) { - return _('A file with the same UUID already exists in database'); + return $translator->trans('A file with the same UUID already exists in database'); } } diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Collection.php b/lib/Alchemy/Phrasea/Controller/Admin/Collection.php index 36f45b36d9..60287a29e4 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Collection.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Collection.php @@ -142,16 +142,16 @@ class Collection implements ControllerProviderInterface switch ($errorMsg = $request->query->get('error')) { case 'file-error': - $errorMsg = _('Error while sending the file'); + $errorMsg = $app->trans('Error while sending the file'); break; case 'file-invalid': - $errorMsg = _('Invalid file format'); + $errorMsg = $app->trans('Invalid file format'); break; case 'file-file-too-big': - $errorMsg = _('The file is too big'); + $errorMsg = $app->trans('The file is too big'); break; case 'collection-not-empty': - $errorMsg = _('Empty the collection before removing'); + $errorMsg = $app->trans('Empty the collection before removing'); break; } @@ -227,17 +227,17 @@ class Collection implements ControllerProviderInterface public function emptyCollection(Application $app, Request $request, $bas_id) { $success = false; - $msg = _('An error occurred'); + $msg = $app->trans('An error occurred'); $collection = \collection::get_from_base_id($app, $bas_id); try { if ($collection->get_record_amount() <= 500) { $collection->empty_collection(500); - $msg = _('Collection empty successful'); + $msg = $app->trans('Collection empty successful'); } else { $app['manipulator.task']->createEmptyCollectionJob($collection); - $msg = _('A task has been creted, please run it to complete empty collection'); + $msg = $app->trans('A task has been creted, please run it to complete empty collection'); } $success = true; @@ -283,7 +283,7 @@ class Collection implements ControllerProviderInterface if ('json' === $app['request']->getRequestFormat()) { return $app->json([ 'success' => $success, - 'msg' => $success ? _('Successful removal') : _('An error occured'), + 'msg' => $success ? $app->trans('Successful removal') : $app->trans('An error occured'), 'bas_id' => $collection->get_base_id() ]); } @@ -318,7 +318,7 @@ class Collection implements ControllerProviderInterface if ('json' === $app['request']->getRequestFormat()) { return $app->json([ 'success' => $success, - 'msg' => $success ? _('Successful removal') : _('An error occured'), + 'msg' => $success ? $app->trans('Successful removal') : $app->trans('An error occured'), 'bas_id' => $collection->get_base_id() ]); } @@ -353,7 +353,7 @@ class Collection implements ControllerProviderInterface if ('json' === $app['request']->getRequestFormat()) { return $app->json([ 'success' => $success, - 'msg' => $success ? _('Successful removal') : _('An error occured'), + 'msg' => $success ? $app->trans('Successful removal') : $app->trans('An error occured'), 'bas_id' => $collection->get_base_id() ]); } @@ -389,7 +389,7 @@ class Collection implements ControllerProviderInterface if ('json' === $app['request']->getRequestFormat()) { return $app->json([ 'success' => $success, - 'msg' => $success ? _('Successful removal') : _('An error occured'), + 'msg' => $success ? $app->trans('Successful removal') : $app->trans('An error occured'), 'bas_id' => $collection->get_base_id() ]); } @@ -609,18 +609,18 @@ class Collection implements ControllerProviderInterface public function delete(Application $app, Request $request, $bas_id) { $success = false; - $msg = _('An error occured'); + $msg = $app->trans('An error occured'); $collection = \collection::get_from_base_id($app, $bas_id); try { if ($collection->get_record_amount() > 0) { - $msg = _('Empty the collection before removing'); + $msg = $app->trans('Empty the collection before removing'); } else { $collection->unmount_collection($app); $collection->delete(); $success = true; - $msg = _('Successful removal'); + $msg = $app->trans('Successful removal'); } } catch (\Exception $e) { @@ -679,7 +679,7 @@ class Collection implements ControllerProviderInterface if ('json' === $app['request']->getRequestFormat()) { return $app->json([ 'success' => $success, - 'msg' => $success ? _('The publication has been stopped') : _('An error occured') + 'msg' => $success ? $app->trans('The publication has been stopped') : $app->trans('An error occured') ]); } @@ -700,7 +700,7 @@ class Collection implements ControllerProviderInterface public function rename(Application $app, Request $request, $bas_id) { if (trim($name = $request->request->get('name')) === '') { - $app->abort(400, _('Missing name parameter')); + $app->abort(400, $app->trans('Missing name parameter')); } $success = false; @@ -717,7 +717,7 @@ class Collection implements ControllerProviderInterface if ('json' === $app['request']->getRequestFormat()) { return $app->json([ 'success' => $success, - 'msg' => $success ? _('Successful update') : _('An error occured') + 'msg' => $success ? $app->trans('Successful update') : $app->trans('An error occured') ]); } @@ -731,10 +731,10 @@ class Collection implements ControllerProviderInterface public function labels(Application $app, Request $request, $bas_id) { if (null === $labels = $request->request->get('labels')) { - $app->abort(400, _('Missing labels parameter')); + $app->abort(400, $app->trans('Missing labels parameter')); } if (false === is_array($labels)) { - $app->abort(400, _('Invalid labels parameter')); + $app->abort(400, $app->trans('Invalid labels parameter')); } $collection = \collection::get_from_base_id($app, $bas_id); @@ -755,7 +755,7 @@ class Collection implements ControllerProviderInterface if ('json' === $app['request']->getRequestFormat()) { return $app->json([ 'success' => $success, - 'msg' => $success ? _('Successful update') : _('An error occured') + 'msg' => $success ? $app->trans('Successful update') : $app->trans('An error occured') ]); } @@ -794,7 +794,7 @@ class Collection implements ControllerProviderInterface if ('json' === $app['request']->getRequestFormat()) { return $app->json([ 'success' => $success, - 'msg' => $success ? _('Successful update') : _('An error occured') + 'msg' => $success ? $app->trans('Successful update') : $app->trans('An error occured') ]); } @@ -828,7 +828,7 @@ class Collection implements ControllerProviderInterface if ('json' === $app['request']->getRequestFormat()) { return $app->json([ 'success' => $success, - 'msg' => $success ? _('Successful update') : _('An error occured') + 'msg' => $success ? $app->trans('Successful update') : $app->trans('An error occured') ]); } @@ -862,7 +862,7 @@ class Collection implements ControllerProviderInterface if ('json' === $app['request']->getRequestFormat()) { return $app->json([ 'success' => $success, - 'msg' => $success ? _('Successful update') : _('An error occured') + 'msg' => $success ? $app->trans('Successful update') : $app->trans('An error occured') ]); } @@ -961,7 +961,7 @@ class Collection implements ControllerProviderInterface if ('json' === $app['request']->getRequestFormat()) { return $app->json([ 'success' => $success, - 'msg' => $success ? _('Successful update') : _('An error occured'), + 'msg' => $success ? $app->trans('Successful update') : $app->trans('An error occured'), 'bas_id' => $collection->get_base_id() ]); } diff --git a/lib/Alchemy/Phrasea/Controller/Admin/ConnectedUsers.php b/lib/Alchemy/Phrasea/Controller/Admin/ConnectedUsers.php index 942a7f47ec..02c52de6e9 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/ConnectedUsers.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/ConnectedUsers.php @@ -15,6 +15,7 @@ use Alchemy\Geonames\Exception\ExceptionInterface as GeonamesExceptionInterface; use Silex\Application; use Silex\ControllerProviderInterface; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Translation\TranslatorInterface; class ConnectedUsers implements ControllerProviderInterface { @@ -115,18 +116,18 @@ class ConnectedUsers implements ControllerProviderInterface * @return string * @return null */ - public static function appName($appId) + public static function appName(TranslatorInterface $translator, $appId) { $appRef = [ - '0' => _('admin::monitor: module inconnu'), - '1' => _('admin::monitor: module production'), - '2' => _('admin::monitor: module client'), - '3' => _('admin::monitor: module admin'), - '4' => _('admin::monitor: module report'), - '5' => _('admin::monitor: module thesaurus'), - '6' => _('admin::monitor: module comparateur'), - '7' => _('admin::monitor: module validation'), - '8' => _('admin::monitor: module upload'), + '0' => $translator->trans('admin::monitor: module inconnu'), + '1' => $translator->trans('admin::monitor: module production'), + '2' => $translator->trans('admin::monitor: module client'), + '3' => $translator->trans('admin::monitor: module admin'), + '4' => $translator->trans('admin::monitor: module report'), + '5' => $translator->trans('admin::monitor: module thesaurus'), + '6' => $translator->trans('admin::monitor: module comparateur'), + '7' => $translator->trans('admin::monitor: module validation'), + '8' => $translator->trans('admin::monitor: module upload'), ]; return isset($appRef[$appId]) ? $appRef[$appId] : null; diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php b/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php index 24287e6210..09d95bbf3b 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php @@ -60,10 +60,10 @@ class Dashboard implements ControllerProviderInterface { switch ($emailStatus = $request->query->get('email')) { case 'sent'; - $emailStatus = _('Mail sent'); + $emailStatus = $app->trans('Mail sent'); break; case 'error': - $emailStatus = _('Could not send email'); + $emailStatus = $app->trans('Could not send email'); break; } diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Databox.php b/lib/Alchemy/Phrasea/Controller/Admin/Databox.php index 372df014c0..11d5efe208 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Databox.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Databox.php @@ -166,13 +166,13 @@ class Databox implements ControllerProviderInterface switch ($errorMsg = $request->query->get('error')) { case 'file-error': - $errorMsg = _('Error while sending the file'); + $errorMsg = $app->trans('Error while sending the file'); break; case 'file-invalid': - $errorMsg = _('Invalid file format'); + $errorMsg = $app->trans('Invalid file format'); break; case 'file-too-big': - $errorMsg = _('The file is too big'); + $errorMsg = $app->trans('The file is too big'); break; } @@ -212,18 +212,18 @@ class Databox implements ControllerProviderInterface public function deleteBase(Application $app, Request $request, $databox_id) { $success = false; - $msg = _('An error occured'); + $msg = $app->trans('An error occured'); try { $databox = $app['phraseanet.appbox']->get_databox($databox_id); if ($databox->get_record_amount() > 0) { - $msg = _('admin::base: vider la base avant de la supprimer'); + $msg = $app->trans('admin::base: vider la base avant de la supprimer'); } else { $databox->unmount_databox(); $app['phraseanet.appbox']->write_databox_pic($app['media-alchemyst'], $app['filesystem'], $databox, null, \databox::PIC_PDF); $databox->delete(); $success = true; - $msg = _('Successful removal'); + $msg = $app->trans('Successful removal'); } } catch (\Exception $e) { @@ -252,10 +252,10 @@ class Databox implements ControllerProviderInterface public function setLabels(Application $app, Request $request, $databox_id) { if (null === $labels = $request->request->get('labels')) { - $app->abort(400, _('Missing labels parameter')); + $app->abort(400, $app->trans('Missing labels parameter')); } if (false === is_array($labels)) { - $app->abort(400, _('Invalid labels parameter')); + $app->abort(400, $app->trans('Invalid labels parameter')); } $databox = $app['phraseanet.appbox']->get_databox($databox_id); @@ -276,7 +276,7 @@ class Databox implements ControllerProviderInterface if ('json' === $app['request']->getRequestFormat()) { return $app->json([ 'success' => $success, - 'msg' => $success ? _('Successful update') : _('An error occured') + 'msg' => $success ? $app->trans('Successful update') : $app->trans('An error occured') ]); } @@ -305,7 +305,7 @@ class Databox implements ControllerProviderInterface if ('json' === $app['request']->getRequestFormat()) { return $app->json([ 'success' => $success, - 'msg' => $success ? _('Successful update') : _('An error occured'), + 'msg' => $success ? $app->trans('Successful update') : $app->trans('An error occured'), 'sbas_id' => $databox_id ]); } @@ -338,7 +338,7 @@ class Databox implements ControllerProviderInterface if ('json' === $app['request']->getRequestFormat()) { return $app->json([ 'success' => $success, - 'msg' => $success ? _('Successful update') : _('An error occured'), + 'msg' => $success ? $app->trans('Successful update') : $app->trans('An error occured'), 'sbas_id' => $databox_id ]); } @@ -493,7 +493,7 @@ class Databox implements ControllerProviderInterface if ('json' === $app['request']->getRequestFormat()) { return $app->json([ 'success' => $success, - 'msg' => $success ? _('Successful removal') : _('An error occured'), + 'msg' => $success ? $app->trans('Successful removal') : $app->trans('An error occured'), 'sbas_id' => $databox_id ]); } @@ -526,7 +526,7 @@ class Databox implements ControllerProviderInterface if ('json' === $app['request']->getRequestFormat()) { return $app->json([ 'success' => $success, - 'msg' => $success ? _('Successful update') : _('An error occured'), + 'msg' => $success ? $app->trans('Successful update') : $app->trans('An error occured'), 'sbas_id' => $databox_id ]); } @@ -548,7 +548,7 @@ class Databox implements ControllerProviderInterface public function changeViewName(Application $app, Request $request, $databox_id) { if (null === $viewName = $request->request->get('viewname')) { - $app->abort(400, _('Missing view name parameter')); + $app->abort(400, $app->trans('Missing view name parameter')); } $success = false; @@ -563,7 +563,7 @@ class Databox implements ControllerProviderInterface if ('json' === $app['request']->getRequestFormat()) { return $app->json([ 'success' => $success, - 'msg' => $success ? _('Successful update') : _('An error occured'), + 'msg' => $success ? $app->trans('Successful update') : $app->trans('An error occured'), 'sbas_id' => $databox_id ]); } @@ -598,7 +598,7 @@ class Databox implements ControllerProviderInterface if ('json' === $app['request']->getRequestFormat()) { return $app->json([ 'success' => $success, - 'msg' => $success ? _('The publication has been stopped') : _('An error occured'), + 'msg' => $success ? $app->trans('The publication has been stopped') : $app->trans('An error occured'), 'sbas_id' => $databox_id ]); } @@ -618,7 +618,7 @@ class Databox implements ControllerProviderInterface */ public function emptyDatabase(Application $app, Request $request, $databox_id) { - $msg = _('An error occurred'); + $msg = $app->trans('An error occurred'); $success = false; $taskCreated = false; @@ -633,11 +633,11 @@ class Databox implements ControllerProviderInterface } } - $msg = _('Base empty successful'); + $msg = $app->trans('Base empty successful'); $success = true; if ($taskCreated) { - $msg = _('A task has been created, please run it to complete empty collection'); + $msg = $app->trans('A task has been created, please run it to complete empty collection'); } } catch (\Exception $e) { @@ -668,14 +668,14 @@ class Databox implements ControllerProviderInterface public function progressBarInfos(Application $app, Request $request, $databox_id) { if (!$app['request']->isXmlHttpRequest() || 'json' !== $app['request']->getRequestFormat()) { - $app->abort(400, _('Bad request format, only JSON is allowed')); + $app->abort(400, $app->trans('Bad request format, only JSON is allowed')); } $app['phraseanet.appbox'] = $app['phraseanet.appbox']; $ret = [ 'success' => false, - 'msg' => _('An error occured'), + 'msg' => $app->trans('An error occured'), 'sbas_id' => null, 'indexable' => false, 'records' => 0, @@ -690,7 +690,7 @@ class Databox implements ControllerProviderInterface $datas = $databox->get_indexed_record_amount(); $ret['indexable'] = $app['phraseanet.appbox']->is_databox_indexable($databox); - $ret['viewname'] = (($databox->get_dbname() == $databox->get_viewname()) ? _('admin::base: aucun alias') : $databox->get_viewname()); + $ret['viewname'] = (($databox->get_dbname() == $databox->get_viewname()) ? $app->trans('admin::base: aucun alias') : $databox->get_viewname()); $ret['records'] = $databox->get_record_amount(); $ret['sbas_id'] = $databox_id; $ret['xml_indexed'] = $datas['xml_indexed']; @@ -701,7 +701,7 @@ class Databox implements ControllerProviderInterface } $ret['success'] = true; - $ret['msg'] = _('Successful update'); + $ret['msg'] = $app->trans('Successful update'); } catch (\Exception $e) { } @@ -747,7 +747,7 @@ class Databox implements ControllerProviderInterface if ('json' === $app['request']->getRequestFormat()) { return $app->json([ 'success' => $success, - 'msg' => $success ? _('Successful update') : _('An error occured'), + 'msg' => $success ? $app->trans('Successful update') : $app->trans('An error occured'), 'sbas_id' => $databox_id ]); } diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Databoxes.php b/lib/Alchemy/Phrasea/Controller/Admin/Databoxes.php index 1426a48595..ef5ea6eebf 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Databoxes.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Databoxes.php @@ -74,7 +74,7 @@ class Databoxes implements ControllerProviderInterface 'version' => 'unknown', 'image' => '/skins/icons/db-remove.png', 'server_info' => '', - 'name' => _('Unreachable server') + 'name' => $app->trans('Unreachable server') ]; try { @@ -93,31 +93,31 @@ class Databoxes implements ControllerProviderInterface switch ($errorMsg = $request->query->get('error')) { case 'scheduler-started' : - $errorMsg = _('Veuillez arreter le planificateur avant la mise a jour'); + $errorMsg = $app->trans('Veuillez arreter le planificateur avant la mise a jour'); break; case 'already-started' : - $errorMsg = _('The upgrade is already started'); + $errorMsg = $app->trans('The upgrade is already started'); break; case 'unknow' : - $errorMsg = _('An error occured'); + $errorMsg = $app->trans('An error occured'); break; case 'bad-email' : - $errorMsg = _('Please fix the database before starting'); + $errorMsg = $app->trans('Please fix the database before starting'); break; case 'special-chars' : - $errorMsg = _('Database name can not contains special characters'); + $errorMsg = $app->trans('Database name can not contains special characters'); break; case 'base-failed' : - $errorMsg = _('Base could not be created'); + $errorMsg = $app->trans('Base could not be created'); break; case 'database-failed' : - $errorMsg = _('Database does not exists or can not be accessed'); + $errorMsg = $app->trans('Database does not exists or can not be accessed'); break; case 'no-empty' : - $errorMsg = _('Database can not be empty'); + $errorMsg = $app->trans('Database can not be empty'); break; case 'mount-failed' : - $errorMsg = _('Database could not be mounted'); + $errorMsg = $app->trans('Database could not be mounted'); break; } diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Fields.php b/lib/Alchemy/Phrasea/Controller/Admin/Fields.php index ee4478999a..4e20cb190d 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Fields.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Fields.php @@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Controller\Admin; use Alchemy\Phrasea\Metadata\TagProvider; use Alchemy\Phrasea\Vocabulary\Controller as VocabularyController; +use JMS\TranslationBundle\Annotation\Ignore; use Silex\Application; use Silex\ControllerProviderInterface; use Symfony\Component\HttpFoundation\Request; @@ -113,7 +114,7 @@ class Fields implements ControllerProviderInterface $fields[] = $field->toArray(); } catch (\Exception $e) { $connection->rollback(); - $app->abort(500, _(sprintf('Field %s could not be saved, please try again or contact an admin.', $jsonField['name']))); + $app->abort(500, $app->trans('Field %name% could not be saved, please try again or contact an admin.', array('%name%' => $jsonField['name']))); break; } } @@ -126,16 +127,16 @@ class Fields implements ControllerProviderInterface public function getLanguage(Application $app, Request $request) { return $app->json([ - 'something_wrong' => _('Something wrong happened, please try again or contact an admin.'), - 'created_success' => _('%s field has been created with success.'), - 'deleted_success' => _('%s field has been deleted with success.'), - 'are_you_sure_delete' => _('Do you really want to delete the field %s ?'), - 'validation_blank' => _('Field can not be blank.'), - 'validation_name_exists' => _('Field name already exists.'), - 'validation_name_invalid' => _('Field name is not valid.'), - 'validation_tag_invalid' => _('Field source is not valid.'), - 'field_error' => _('Field %s contains errors.'), - 'fields_save' => _('Your configuration has been successfuly saved.'), + 'something_wrong' => $app->trans('Something wrong happened, please try again or contact an admin.'), + 'created_success' => $app->trans('%s field has been created with success.'), + 'deleted_success' => $app->trans('%s field has been deleted with success.'), + 'are_you_sure_delete' => $app->trans('Do you really want to delete the field %s ?'), + 'validation_blank' => $app->trans('Field can not be blank.'), + 'validation_name_exists' => $app->trans('Field name already exists.'), + 'validation_name_invalid' => $app->trans('Field name is not valid.'), + 'validation_tag_invalid' => $app->trans('Field source is not valid.'), + 'field_error' => $app->trans('Field %s contains errors.'), + 'fields_save' => $app->trans('Your configuration has been successfuly saved.'), ]); } @@ -201,6 +202,7 @@ class Fields implements ControllerProviderInterface $res[] = [ 'id' => $namespace . '/' . $tagname, + /** @Ignore */ 'label' => $datas['namespace'] . ' / ' . $datas['tagname'], 'value' => $datas['namespace'] . ':' . $datas['tagname'], ]; @@ -233,7 +235,7 @@ class Fields implements ControllerProviderInterface $this->updateFieldWithData($app, $field, $data); $field->save(); } catch (\Exception $e) { - $app->abort(500, _(sprintf('Field %s could not be created, please try again or contact an admin.', $data['name']))); + $app->abort(500, $app->trans('Field %name% could not be created, please try again or contact an admin.', array('%name%' => $data['name']))); } return $app->json($field->toArray(), 201, [ @@ -371,7 +373,7 @@ class Fields implements ControllerProviderInterface private function validateNameField(\databox_descriptionStructure $metaStructure, array $field) { if (null !== $metaStructure->get_element_by_name($field['name'])) { - throw new BadRequestHttpException(_(sprintf('Field %s already exists.', $field['name']))); + throw new BadRequestHttpException(sprintf('Field %s already exists.', $field['name'])); } } @@ -380,7 +382,7 @@ class Fields implements ControllerProviderInterface try { \databox_field::loadClassFromTagName($field['tag'], true); } catch (\Exception_Databox_metadataDescriptionNotFound $e) { - throw new BadRequestHttpException(_(sprintf('Provided tag %s is unknown.', $field['tag']))); + throw new BadRequestHttpException(sprintf('Provided tag %s is unknown.', $field['tag'])); } } diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Publications.php b/lib/Alchemy/Phrasea/Controller/Admin/Publications.php index 20971dad14..e43022a5ee 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Publications.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Publications.php @@ -107,7 +107,7 @@ class Publications implements ControllerProviderInterface $feed = $app["EM"]->find('Alchemy\Phrasea\Model\Entities\Feed', $request->attributes->get('id')); if (!$feed->isOwner($app['authentication']->getUser())) { - return $app->redirectPath('admin_feeds_feed', ['id' => $request->attributes->get('id'), 'error' => _('You are not the owner of this feed, you can not edit it')]); + return $app->redirectPath('admin_feeds_feed', ['id' => $request->attributes->get('id'), 'error' => $app->trans('You are not the owner of this feed, you can not edit it')]); } }) ->bind('admin_feeds_feed_update') @@ -179,7 +179,7 @@ class Publications implements ControllerProviderInterface $datas['success'] = true; } catch (\Exception $e) { - $datas['message'] = _('Unable to add file to Phraseanet'); + $datas['message'] = $app->trans('Unable to add file to Phraseanet'); } return $app->json($datas); diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Root.php b/lib/Alchemy/Phrasea/Controller/Admin/Root.php index 87454d6657..c269184ac6 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Root.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Root.php @@ -160,15 +160,15 @@ class Root implements ControllerProviderInterface $controllers->get('/test-paths/', function (Application $app, Request $request) { if (!$request->isXmlHttpRequest() || !array_key_exists($request->getMimeType('json'), array_flip($request->getAcceptableContentTypes()))) { - $app->abort(400, _('Bad request format, only JSON is allowed')); + $app->abort(400, $app->trans('Bad request format, only JSON is allowed')); } if (0 !== count($tests = $request->query->get('tests', []))) { - $app->abort(400, _('Missing tests parameter')); + $app->abort(400, $app->trans('Missing tests parameter')); } if (null !== $path = $request->query->get('path')) { - $app->abort(400, _('Missing path parameter')); + $app->abort(400, $app->trans('Missing path parameter')); } foreach ($tests as $test) { @@ -198,7 +198,7 @@ class Root implements ControllerProviderInterface $databox = $app['phraseanet.appbox']->get_databox((int) $databox_id); $structure = $databox->get_structure(); - $errors = \databox::get_structure_errors($structure); + $errors = \databox::get_structure_errors($app['translator'], $structure); if ($updateOk = !!$request->query->get('success', false)) { $updateOk = true; @@ -224,10 +224,10 @@ class Root implements ControllerProviderInterface } if (null === $structure = $request->request->get('structure')) { - $app->abort(400, _('Missing "structure" parameter')); + $app->abort(400, $app->trans('Missing "structure" parameter')); } - $errors = \databox::get_structure_errors($structure); + $errors = \databox::get_structure_errors($app['translator'], $structure); $domst = new \DOMDocument('1.0', 'UTF-8'); $domst->preserveWhiteSpace = false; @@ -266,19 +266,19 @@ class Root implements ControllerProviderInterface switch ($errorMsg = $request->query->get('error')) { case 'rights': - $errorMsg = _('You do not enough rights to update status'); + $errorMsg = $app->trans('You do not enough rights to update status'); break; case 'too-big': - $errorMsg = _('File is too big : 64k max'); + $errorMsg = $app->trans('File is too big : 64k max'); break; case 'upload-error': - $errorMsg = _('Status icon upload failed : upload error'); + $errorMsg = $app->trans('Status icon upload failed : upload error'); break; case 'wright-error': - $errorMsg = _('Status icon upload failed : can not write on disk'); + $errorMsg = $app->trans('Status icon upload failed : can not write on disk'); break; case 'unknow-error': - $errorMsg = _('Something wrong happend'); + $errorMsg = $app->trans('Something wrong happend'); break; } @@ -312,7 +312,7 @@ class Root implements ControllerProviderInterface $controllers->post('/statusbit/{databox_id}/status/{bit}/delete/', function (Application $app, Request $request, $databox_id, $bit) { if (!$request->isXmlHttpRequest() || !array_key_exists($request->getMimeType('json'), array_flip($request->getAcceptableContentTypes()))) { - $app->abort(400, _('Bad request format, only JSON is allowed')); + $app->abort(400, $app->trans('Bad request format, only JSON is allowed')); } if (!$app['acl']->get($app['authentication']->getUser())->has_right_on_sbas($databox_id, 'bas_modify_struct')) { diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Setup.php b/lib/Alchemy/Phrasea/Controller/Admin/Setup.php index 5839a66c2b..6a3f16c300 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Setup.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Setup.php @@ -52,9 +52,9 @@ class Setup implements ControllerProviderInterface if (null !== $update = $request->query->get('update')) { if (!!$update) { - $update = _('Update succeed'); + $update = $app->trans('Update succeed'); } else { - $update = _('Update failed'); + $update = $app->trans('Update failed'); } } diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Users.php b/lib/Alchemy/Phrasea/Controller/Admin/Users.php index 6615fda7da..e77478328c 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Users.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Users.php @@ -290,20 +290,20 @@ class Users implements ControllerProviderInterface $buffer[] = [ 'ID' , 'Login' - , _('admin::compte-utilisateur nom') - , _('admin::compte-utilisateur prenom') - , _('admin::compte-utilisateur email') + , $app->trans('admin::compte-utilisateur nom') + , $app->trans('admin::compte-utilisateur prenom') + , $app->trans('admin::compte-utilisateur email') , 'CreationDate' , 'ModificationDate' - , _('admin::compte-utilisateur adresse') - , _('admin::compte-utilisateur ville') - , _('admin::compte-utilisateur code postal') - , _('admin::compte-utilisateur pays') - , _('admin::compte-utilisateur telephone') - , _('admin::compte-utilisateur fax') - , _('admin::compte-utilisateur poste') - , _('admin::compte-utilisateur societe') - , _('admin::compte-utilisateur activite') + , $app->trans('admin::compte-utilisateur adresse') + , $app->trans('admin::compte-utilisateur ville') + , $app->trans('admin::compte-utilisateur code postal') + , $app->trans('admin::compte-utilisateur pays') + , $app->trans('admin::compte-utilisateur telephone') + , $app->trans('admin::compte-utilisateur fax') + , $app->trans('admin::compte-utilisateur poste') + , $app->trans('admin::compte-utilisateur societe') + , $app->trans('admin::compte-utilisateur activite') ]; do { $elligible_users->limit($offset, 20); @@ -558,10 +558,10 @@ class Users implements ControllerProviderInterface if (($accept != '' || $deny != '')) { $message = ''; if ($accept != '') { - $message .= "\n" . _('login::register:email: Vous avez ete accepte sur les collections suivantes : ') . implode(', ', $accept). "\n"; + $message .= "\n" . $app->trans('login::register:email: Vous avez ete accepte sur les collections suivantes :') . implode(', ', $accept). "\n"; } if ($deny != '') { - $message .= "\n" . _('login::register:email: Vous avez ete refuse sur les collections suivantes : ') . implode(', ', $deny) . "\n"; + $message .= "\n" . $app->trans('login::register:email: Vous avez ete refuse sur les collections suivantes :') . implode(', ', $deny) . "\n"; } $receiver = new Receiver(null, $row['usr_mail']); @@ -656,12 +656,12 @@ class Users implements ControllerProviderInterface if ($sqlField === 'usr_login') { $loginToAdd = $value; if ($loginToAdd === "") { - $out['errors'][] = sprintf(_("Login line %d is empty"), $nbLine + 1); + $out['errors'][] = $app->trans("Login line %line% is empty", array('%line%' => $nbLine + 1)); } elseif (in_array($loginToAdd, $loginNew)) { - $out['errors'][] = sprintf(_("Login %s is already defined in the file at line %d"), $loginToAdd, $nbLine); + $out['errors'][] = $app->trans("Login %login% is already defined in the file at line %line%", array('%login%' => $loginToAdd, '%line%' => $nbLine)); } else { if (\User_Adapter::get_usr_id_from_login($app, $loginToAdd)) { - $out['errors'][] = sprintf(_("Login %s already exists in database"), $loginToAdd); + $out['errors'][] = $app->trans("Login %login% already exists in database", array('%login%' => $loginToAdd)); } else { $loginValid = true; } @@ -672,9 +672,9 @@ class Users implements ControllerProviderInterface $mailToAdd = $value; if ($mailToAdd === "") { - $out['errors'][] = sprintf(_("Mail line %d is empty"), $nbLine + 1); + $out['errors'][] = $app->trans("Mail line %line% is empty", array('%line%' => $nbLine + 1)); } elseif (false !== \User_Adapter::get_usr_id_from_email($app, $mailToAdd)) { - $out['errors'][] = sprintf(_("Email '%s' for login '%s' already exists in database"), $mailToAdd, $loginToAdd); + $out['errors'][] = $app->trans("Email '%email%' for login '%login%' already exists in database", array('%email%' => $mailToAdd, '%login%' => $loginToAdd)); } else { $mailValid = true; } @@ -684,7 +684,7 @@ class Users implements ControllerProviderInterface $passwordToVerif = $value; if ($passwordToVerif === "") { - $out['errors'][] = sprintf(_("Password is empty at line %d"), $nbLine); + $out['errors'][] = $app->trans("Password is empty at line %line%", array('%line%' => $nbLine)); } else { $pwdValid = true; } diff --git a/lib/Alchemy/Phrasea/Controller/Api/Oauth2.php b/lib/Alchemy/Phrasea/Controller/Api/Oauth2.php index 72d15a18e8..79ec03dc5e 100644 --- a/lib/Alchemy/Phrasea/Controller/Api/Oauth2.php +++ b/lib/Alchemy/Phrasea/Controller/Api/Oauth2.php @@ -81,7 +81,7 @@ class Oauth2 implements ControllerProviderInterface $usr_id = $app['auth.native']->getUsrId($request->get("login"), $request->get("password"), $request); if (null === $usr_id) { - $app['session']->getFlashBag()->set('error', _('login::erreur: Erreur d\'authentification')); + $app['session']->getFlashBag()->set('error', $app->trans('login::erreur: Erreur d\'authentification')); return $app->redirectPath('oauth2_authorize'); } diff --git a/lib/Alchemy/Phrasea/Controller/Api/V1.php b/lib/Alchemy/Phrasea/Controller/Api/V1.php index 363797fe80..6393b9c81d 100644 --- a/lib/Alchemy/Phrasea/Controller/Api/V1.php +++ b/lib/Alchemy/Phrasea/Controller/Api/V1.php @@ -68,7 +68,7 @@ class V1 implements ControllerProviderInterface if ($oAuth2App->get_client_id() == \API_OAuth2_Application_Navigator::CLIENT_ID && !$app['phraseanet.registry']->get('GV_client_navigator')) { - throw new \API_V1_exception_forbidden(_('The use of phraseanet Navigator is not allowed')); + throw new \API_V1_exception_forbidden('The use of phraseanet Navigator is not allowed'); } if ($oAuth2App->get_client_id() == \API_OAuth2_Application_OfficePlugin::CLIENT_ID diff --git a/lib/Alchemy/Phrasea/Controller/Client/Root.php b/lib/Alchemy/Phrasea/Controller/Client/Root.php index e1eb73df46..54a38bad48 100644 --- a/lib/Alchemy/Phrasea/Controller/Client/Root.php +++ b/lib/Alchemy/Phrasea/Controller/Client/Root.php @@ -211,20 +211,20 @@ class Root implements ControllerProviderInterface public function getClientLanguage(Application $app, Request $request) { $out = []; - $out['createWinInvite'] = _('paniers:: Quel nom souhaitez vous donner a votre panier ?'); - $out['chuNameEmpty'] = _('paniers:: Quel nom souhaitez vous donner a votre panier ?'); - $out['noDLok'] = _('export:: aucun document n\'est disponible au telechargement'); - $out['confirmRedirectAuth'] = _('invite:: Redirection vers la zone d\'authentification, cliquez sur OK pour continuer ou annulez'); + $out['createWinInvite'] = $app->trans('paniers:: Quel nom souhaitez vous donner a votre panier ?'); + $out['chuNameEmpty'] = $app->trans('paniers:: Quel nom souhaitez vous donner a votre panier ?'); + $out['noDLok'] = $app->trans('export:: aucun document n\'est disponible au telechargement'); + $out['confirmRedirectAuth'] = $app->trans('invite:: Redirection vers la zone d\'authentification, cliquez sur OK pour continuer ou annulez'); $out['serverName'] = $app['phraseanet.registry']->get('GV_ServerName'); - $out['serverError'] = _('phraseanet::erreur: Une erreur est survenue, si ce probleme persiste, contactez le support technique'); - $out['serverTimeout'] = _('phraseanet::erreur: La connection au serveur Phraseanet semble etre indisponible'); - $out['serverDisconnected'] = _('phraseanet::erreur: Votre session est fermee, veuillez vous re-authentifier'); - $out['confirmDelBasket'] = _('paniers::Vous etes sur le point de supprimer ce panier. Cette action est irreversible. Souhaitez-vous continuer ?'); - $out['annuler'] = _('boutton::annuler'); - $out['fermer'] = _('boutton::fermer'); - $out['renewRss'] = _('boutton::renouveller'); - $out['print'] = _('Print'); - $out['no_basket'] = _('Please create a basket before adding an element'); + $out['serverError'] = $app->trans('phraseanet::erreur: Une erreur est survenue, si ce probleme persiste, contactez le support technique'); + $out['serverTimeout'] = $app->trans('phraseanet::erreur: La connection au serveur Phraseanet semble etre indisponible'); + $out['serverDisconnected'] = $app->trans('phraseanet::erreur: Votre session est fermee, veuillez vous re-authentifier'); + $out['confirmDelBasket'] = $app->trans('paniers::Vous etes sur le point de supprimer ce panier. Cette action est irreversible. Souhaitez-vous continuer ?'); + $out['annuler'] = $app->trans('boutton::annuler'); + $out['fermer'] = $app->trans('boutton::fermer'); + $out['renewRss'] = $app->trans('boutton::renouveller'); + $out['print'] = $app->trans('Print'); + $out['no_basket'] = $app->trans('Please create a basket before adding an element'); return $app->json($out); } @@ -246,7 +246,7 @@ class Root implements ControllerProviderInterface $renderTopics = ''; if ($app['phraseanet.registry']->get('GV_client_render_topics') == 'popups') { - $renderTopics = \queries::dropdown_topics($app['locale.I18n']); + $renderTopics = \queries::dropdown_topics($app['translator'], $app['locale.I18n']); } elseif ($app['phraseanet.registry']->get('GV_client_render_topics') == 'tree') { $renderTopics = \queries::tree_topics($app['locale.I18n']); } diff --git a/lib/Alchemy/Phrasea/Controller/Lightbox.php b/lib/Alchemy/Phrasea/Controller/Lightbox.php index a6a58091af..dcc4b74785 100644 --- a/lib/Alchemy/Phrasea/Controller/Lightbox.php +++ b/lib/Alchemy/Phrasea/Controller/Lightbox.php @@ -39,7 +39,7 @@ class Lightbox implements ControllerProviderInterface } if (false === $usr_id = $app['authentication.token-validator']->isValid($request->query->get('LOG'))) { - $app->addFlash('error', _('The URL you used is out of date, please login')); + $app->addFlash('error', $app->trans('The URL you used is out of date, please login')); return $app->redirectPath('homepage'); } @@ -238,7 +238,7 @@ class Lightbox implements ControllerProviderInterface 'basket' => $basket, 'local_title' => strip_tags($basket->getName()), 'module' => 'lightbox', - 'module_name' => _('admin::monitor: module validation') + 'module_name' => $app->trans('admin::monitor: module validation') ] )); $response->setCharset('UTF-8'); @@ -285,7 +285,7 @@ class Lightbox implements ControllerProviderInterface 'basket' => $basket, 'local_title' => strip_tags($basket->getName()), 'module' => 'lightbox', - 'module_name' => _('admin::monitor: module validation') + 'module_name' => $app->trans('admin::monitor: module validation') ] )); $response->setCharset('UTF-8'); @@ -319,7 +319,7 @@ class Lightbox implements ControllerProviderInterface 'first_item' => $first, 'local_title' => $feed_entry->getTitle(), 'module' => 'lightbox', - 'module_name' => _('admin::monitor: module validation') + 'module_name' => $app->trans('admin::monitor: module validation') ] ); $response = new Response($output, 200); @@ -337,7 +337,7 @@ class Lightbox implements ControllerProviderInterface ->assert('basket', '\d+'); $controllers->post('/ajax/SET_NOTE/{sselcont_id}/', function (SilexApplication $app, $sselcont_id) { - $output = ['error' => true, 'datas' => _('Erreur lors de l\'enregistrement des donnees')]; + $output = ['error' => true, 'datas' => $app->trans('Erreur lors de l\'enregistrement des donnees')]; $request = $app['request']; $note = $request->request->get('note'); @@ -390,7 +390,7 @@ class Lightbox implements ControllerProviderInterface $ret = [ 'error' => true, 'releasable' => false, - 'datas' => _('Erreur lors de la mise a jour des donnes ') + 'datas' => $app->trans('Erreur lors de la mise a jour des donnes') ]; $repository = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\BasketElement'); @@ -420,7 +420,7 @@ class Lightbox implements ControllerProviderInterface $releasable = false; if ($participant->isReleasable() === true) { - $releasable = _('Do you want to send your report ?'); + $releasable = $app->trans('Do you want to send your report ?'); } $ret = [ @@ -459,7 +459,7 @@ class Lightbox implements ControllerProviderInterface } if (!$agreed) { - throw new ControllerException(_('You have to give your feedback at least on one document to send a report')); + throw new ControllerException($app->trans('You have to give your feedback at least on one document to send a report')); } /* @var $basket Basket */ @@ -488,7 +488,7 @@ class Lightbox implements ControllerProviderInterface $app['EM']->merge($participant); $app['EM']->flush(); - $datas = ['error' => false, 'datas' => _('Envoie avec succes')]; + $datas = ['error' => false, 'datas' => $app->trans('Envoie avec succes')]; } catch (ControllerException $e) { $datas = ['error' => true, 'datas' => $e->getMessage()]; } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/BasketController.php b/lib/Alchemy/Phrasea/Controller/Prod/BasketController.php index 0ec8dc451a..949f38cd92 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/BasketController.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/BasketController.php @@ -149,7 +149,7 @@ class BasketController implements ControllerProviderInterface if ($request->getRequestFormat() === 'json') { $data = [ 'success' => true - , 'message' => _('Basket created') + , 'message' => $app->trans('Basket created') , 'basket' => [ 'id' => $Basket->getId() ] @@ -168,7 +168,7 @@ class BasketController implements ControllerProviderInterface $data = [ 'success' => true - , 'message' => _('Basket has been deleted') + , 'message' => $app->trans('Basket has been deleted') ]; if ($request->getRequestFormat() === 'json') { @@ -191,7 +191,7 @@ class BasketController implements ControllerProviderInterface $data = [ 'success' => true - , 'message' => _('Record removed from basket') + , 'message' => $app->trans('Record removed from basket') ]; if ($request->getRequestFormat() === 'json') { @@ -213,13 +213,13 @@ class BasketController implements ControllerProviderInterface $app['EM']->flush(); $success = true; - $msg = _('Basket has been updated'); + $msg = $app->trans('Basket has been updated'); } catch (NotFoundHttpException $e) { - $msg = _('The requested basket does not exist'); + $msg = $app->trans('The requested basket does not exist'); } catch (AccessDeniedHttpException $e) { - $msg = _('You do not have access to this basket'); + $msg = $app->trans('You do not have access to this basket'); } catch (\Exception $e) { - $msg = _('An error occurred'); + $msg = $app->trans('An error occurred'); } $data = [ @@ -247,7 +247,7 @@ class BasketController implements ControllerProviderInterface public function reorder(Application $app, BasketEntity $basket) { - $ret = ['success' => false, 'message' => _('An error occured')]; + $ret = ['success' => false, 'message' => $app->trans('An error occured')]; try { $order = $app['request']->request->get('element'); @@ -261,7 +261,7 @@ class BasketController implements ControllerProviderInterface } $app['EM']->flush(); - $ret = ['success' => true, 'message' => _('Basket updated')]; + $ret = ['success' => true, 'message' => $app->trans('Basket updated')]; } catch (\Exception $e) { } @@ -279,9 +279,9 @@ class BasketController implements ControllerProviderInterface $app['EM']->flush(); if ($archive_status) { - $message = _('Basket has been archived'); + $message = $app->trans('Basket has been archived'); } else { - $message = _('Basket has been unarchived'); + $message = $app->trans('Basket has been unarchived'); } $data = [ @@ -335,7 +335,7 @@ class BasketController implements ControllerProviderInterface $data = [ 'success' => true - , 'message' => sprintf(_('%d records added'), $n) + , 'message' => $app->trans('%quantity% records added', array('%quantity%' => $n)) ]; if ($request->getRequestFormat() === 'json') { @@ -367,7 +367,7 @@ class BasketController implements ControllerProviderInterface $data = [ 'success' => true - , 'message' => sprintf(_('%d records moved'), $n) + , 'message' => $app->trans('%quantity% records moved', array('%quantity%' => $n)) ]; if ($request->getRequestFormat() === 'json') { diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php b/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php index 396d8108df..7c25d86c7a 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php @@ -178,9 +178,9 @@ class Bridge implements ControllerProviderInterface $account->delete(); $success = true; } catch (\Bridge_Exception_AccountNotFound $e) { - $message = _('Account is not found.'); + $message = $app->trans('Account is not found.'); } catch (\Exception $e) { - $message = _('Something went wrong, please contact an administrator'); + $message = $app->trans('Something went wrong, please contact an administrator'); } return $app->json(['success' => $success, 'message' => $message]); @@ -274,7 +274,7 @@ class Bridge implements ControllerProviderInterface 'account_id' => $account_id, 'type' => $element_type, 'page' => '', - 'error' => _('Vous ne pouvez pas editer plusieurs elements simultanement'), + 'error' => $app->trans('Vous ne pouvez pas editer plusieurs elements simultanement'), ]); } foreach ($elements as $element_id) { @@ -295,7 +295,7 @@ class Bridge implements ControllerProviderInterface break; default: - throw new \Exception(_('Vous essayez de faire une action que je ne connais pas !')); + throw new \Exception($app->trans('Vous essayez de faire une action que je ne connais pas !')); break; } @@ -333,7 +333,7 @@ class Bridge implements ControllerProviderInterface switch ($action) { case 'modify': if (count($elements) != 1) { - return $app->redirect('/prod/bridge/action/' . $account_id . '/' . $action . '/' . $element_type . '/?elements_list=' . implode(';', $elements) . '&error=' . _('Vous ne pouvez pas editer plusieurs elements simultanement')); + return $app->redirect('/prod/bridge/action/' . $account_id . '/' . $action . '/' . $element_type . '/?elements_list=' . implode(';', $elements) . '&error=' . $app->trans('Vous ne pouvez pas editer plusieurs elements simultanement')); } try { foreach ($elements as $element_id) { @@ -350,7 +350,7 @@ class Bridge implements ControllerProviderInterface 'action' => $action, 'elements' => $elements, 'adapter_action' => $action, - 'error_message' => _('Request contains invalid datas'), + 'error_message' => $app->trans('Request contains invalid datas'), 'constraint_errors' => $errors, 'notice_message' => $request->request->get('notice'), ]; @@ -451,7 +451,7 @@ class Bridge implements ControllerProviderInterface $params = [ 'route' => $route, 'account' => $account, - 'error_message' => _('Request contains invalid datas'), + 'error_message' => $app->trans('Request contains invalid datas'), 'constraint_errors' => $errors, 'notice_message' => $request->request->get('notice'), 'adapter_action' => 'upload', @@ -467,6 +467,6 @@ class Bridge implements ControllerProviderInterface \Bridge_Element::create($app, $account, $record, $title, \Bridge_Element::STATUS_PENDING, $default_type, $datas); } - return $app->redirect('/prod/bridge/adapter/' . $account->get_id() . '/load-records/?notice=' . sprintf(_('%d elements en attente'), count($route->get_elements()))); + return $app->redirect('/prod/bridge/adapter/' . $account->get_id() . '/load-records/?notice=' . $app->trans('%quantity% elements en attente', array('%quantity%' => count($route->get_elements())))); } } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/DoDownload.php b/lib/Alchemy/Phrasea/Controller/Prod/DoDownload.php index d01b1197d7..96133da475 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/DoDownload.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/DoDownload.php @@ -82,8 +82,8 @@ class DoDownload implements ControllerProviderInterface return new Response($app['twig']->render( '/prod/actions/Download/prepare.html.twig', [ - 'module_name' => _('Export'), - 'module' => _('Export'), + 'module_name' => $app->trans('Export'), + 'module' => $app->trans('Export'), 'list' => $list, 'records' => $records, 'token' => $token, diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Edit.php b/lib/Alchemy/Phrasea/Controller/Prod/Edit.php index 83dc31ef01..f140170f50 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Edit.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Edit.php @@ -55,25 +55,27 @@ class Edit implements ControllerProviderInterface $separator = $meta->get_separator(); + /** @Ignore */ $JSFields[$meta->get_id()] = [ - 'meta_struct_id' => $meta->get_id() - , 'name' => $meta->get_name() - , '_status' => 0 - , '_value' => '' - , '_sgval' => [] - , 'required' => $meta->is_required() - , 'label' => $meta->get_label($app['locale.I18n']) - , 'readonly' => $meta->is_readonly() - , 'type' => $meta->get_type() - , 'format' => '' - , 'explain' => '' - , 'tbranch' => $meta->get_tbranch() - , 'maxLength' => $meta->get_tag()->getMaxLength() - , 'minLength' => $meta->get_tag()->getMinLength() - , 'multi' => $meta->is_multi() - , 'separator' => $separator - , 'vocabularyControl' => $meta->getVocabularyControl() ? $meta->getVocabularyControl()->getType() : null - , 'vocabularyRestricted' => $meta->getVocabularyControl() ? $meta->isVocabularyRestricted() : false + 'meta_struct_id' => $meta->get_id(), + 'name' => $meta->get_name(), + '_status' => 0, + '_value' => '', + '_sgval' => [], + 'required' => $meta->is_required(), + /** @Ignore */ + 'label' => $meta->get_label($app['locale.I18n']), + 'readonly' => $meta->is_readonly(), + 'type' => $meta->get_type(), + 'format' => '', + 'explain' => '', + 'tbranch' => $meta->get_tbranch(), + 'maxLength' => $meta->get_tag()->getMaxLength(), + 'minLength' => $meta->get_tag()->getMinLength(), + 'multi' => $meta->is_multi(), + 'separator' => $separator, + 'vocabularyControl' => $meta->getVocabularyControl() ? $meta->getVocabularyControl()->getType() : null, + 'vocabularyRestricted' => $meta->getVocabularyControl() ? $meta->isVocabularyRestricted() : false, ]; if (trim($meta->get_tbranch()) !== '') { @@ -237,7 +239,7 @@ class Edit implements ControllerProviderInterface $VC = VocabularyController::get($app, $vocabulary); $databox = $app['phraseanet.appbox']->get_databox($sbas_id); } catch (\Exception $e) { - $datas['message'] = _('Vocabulary not found'); + $datas['message'] = $app->trans('Vocabulary not found'); return $app->json($datas); } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Export.php b/lib/Alchemy/Phrasea/Controller/Prod/Export.php index fa20e9cefe..ed4af90e54 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Export.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Export.php @@ -94,10 +94,10 @@ class Export implements ControllerProviderInterface $ftpClient = $app['phraseanet.ftp.client']($request->request->get('address', ''), 21, 90, !!$request->request->get('ssl')); $ftpClient->login($request->request->get('login', 'anonymous'), $request->request->get('password', 'anonymous')); $ftpClient->close(); - $msg = _('Connection to FTP succeed'); + $msg = $app->trans('Connection to FTP succeed'); $success = true; } catch (\Exception $e) { - $msg = sprintf(_('Error while connecting to FTP')); + $msg = $app->trans('Error while connecting to FTP'); } return $app->json([ @@ -127,7 +127,7 @@ class Export implements ControllerProviderInterface if (count($download->get_display_ftp()) == 0) { return $app->json([ 'success' => false, - 'message' => _("You do not have required rights to send these documents over FTP") + 'message' => $app->trans("You do not have required rights to send these documents over FTP") ]); } @@ -155,12 +155,12 @@ class Export implements ControllerProviderInterface return $app->json([ 'success' => true, - 'message' => _('Export saved in the waiting queue') + 'message' => $app->trans('Export saved in the waiting queue') ]); } catch (\Exception $e) { return $app->json([ 'success' => false, - 'message' => _('Something went wrong') + 'message' => $app->trans('Something went wrong') ]); } } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Feed.php b/lib/Alchemy/Phrasea/Controller/Prod/Feed.php index 5dfe675260..4eb3d76107 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Feed.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Feed.php @@ -187,7 +187,7 @@ class Feed implements ControllerProviderInterface $app->abort(404, 'Entry not found'); } if (!$entry->isPublisher($app['authentication']->getUser()) && $entry->getFeed()->isOwner($app['authentication']->getUser()) === false) { - $app->abort(403, _('Action Forbidden : You are not the publisher')); + $app->abort(403, $app->trans('Action Forbidden : You are not the publisher')); } $app['EM']->remove($entry); @@ -245,10 +245,10 @@ class Feed implements ControllerProviderInterface ); $output = [ - 'texte' => '

' . _('publication::Voici votre fil RSS personnel. Il vous permettra d\'etre tenu au courrant des publications.') - . '

' . _('publications::Ne le partagez pas, il est strictement confidentiel') . '

+ 'texte' => '

' . $app->trans('publication::Voici votre fil RSS personnel. Il vous permettra d\'etre tenu au courrant des publications.') + . '

' . $app->trans('publications::Ne le partagez pas, il est strictement confidentiel') . '

', - 'titre' => _('publications::votre rss personnel') + 'titre' => $app->trans('publications::votre rss personnel') ]; return $app->json($output); @@ -264,10 +264,10 @@ class Feed implements ControllerProviderInterface $link = $app['feed.user-link-generator']->generate($feed, $app['authentication']->getUser(), FeedLinkGenerator::FORMAT_RSS, null, $renew); $output = [ - 'texte' => '

' . _('publication::Voici votre fil RSS personnel. Il vous permettra d\'etre tenu au courrant des publications.') - . '

' . _('publications::Ne le partagez pas, il est strictement confidentiel') . '

+ 'texte' => '

' . $app->trans('publication::Voici votre fil RSS personnel. Il vous permettra d\'etre tenu au courrant des publications.') + . '

' . $app->trans('publications::Ne le partagez pas, il est strictement confidentiel') . '

', - 'titre' => _('publications::votre rss personnel') + 'titre' => $app->trans('publications::votre rss personnel') ]; return $app->json($output); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Language.php b/lib/Alchemy/Phrasea/Controller/Prod/Language.php index c7cee2c7e1..7395ec4c62 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Language.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Language.php @@ -25,88 +25,88 @@ class Language implements ControllerProviderInterface $controller->get("/", function (Application $app) { $out = []; - $out['thesaurusBasesChanged'] = _('prod::recherche: Attention : la liste des bases selectionnees pour la recherche a ete changee.'); - $out['confirmDel'] = _('paniers::Vous etes sur le point de supprimer ce panier. Cette action est irreversible. Souhaitez-vous continuer ?'); - $out['serverError'] = _('phraseanet::erreur: Une erreur est survenue, si ce probleme persiste, contactez le support technique'); + $out['thesaurusBasesChanged'] = $app->trans('prod::recherche: Attention : la liste des bases selectionnees pour la recherche a ete changee.'); + $out['confirmDel'] = $app->trans('paniers::Vous etes sur le point de supprimer ce panier. Cette action est irreversible. Souhaitez-vous continuer ?'); + $out['serverError'] = $app->trans('phraseanet::erreur: Une erreur est survenue, si ce probleme persiste, contactez le support technique'); $out['serverName'] = $app['phraseanet.registry']->get('GV_ServerName'); - $out['serverTimeout'] = _('phraseanet::erreur: La connection au serveur Phraseanet semble etre indisponible'); - $out['serverDisconnected'] = _('phraseanet::erreur: Votre session est fermee, veuillez vous re-authentifier'); - $out['hideMessage'] = _('phraseanet::Ne plus afficher ce message'); - $out['confirmGroup'] = _('Supprimer egalement les documents rattaches a ces regroupements'); - $out['confirmDelete'] = _('reponses:: Ces enregistrements vont etre definitivement supprimes et ne pourront etre recuperes. Etes vous sur ?'); - $out['cancel'] = _('boutton::annuler'); - $out['deleteTitle'] = _('boutton::supprimer'); - $out['deleteRecords'] = _('Delete records'); - $out['edit_hetero'] = _('prod::editing valeurs heterogenes, choisir \'remplacer\', \'ajouter\' ou \'annuler\''); - $out['confirm_abandon'] = _('prod::editing::annulation: abandonner les modification ?'); - $out['loading'] = _('phraseanet::chargement'); - $out['valider'] = _('boutton::valider'); - $out['annuler'] = _('boutton::annuler'); - $out['create'] = _('boutton::creer'); - $out['rechercher'] = _('boutton::rechercher'); - $out['renewRss'] = _('boutton::renouveller'); - $out['candeletesome'] = _('Vous n\'avez pas les droits pour supprimer certains documents'); - $out['candeletedocuments'] = _('Vous n\'avez pas les droits pour supprimer ces documents'); - $out['needTitle'] = _('Vous devez donner un titre'); - $out['newPreset'] = _('Nouveau modele'); - $out['fermer'] = _('boutton::fermer'); - $out['feed_require_fields'] = _('Vous n\'avez pas rempli tous les champ requis'); - $out['feed_require_feed'] = _('Vous n\'avez pas selectionne de fil de publication'); - $out['removeTitle'] = _('panier::Supression d\'un element d\'un reportage'); - $out['confirmRemoveReg'] = _('panier::Attention, vous etes sur le point de supprimer un element du reportage. Merci de confirmer votre action.'); - $out['advsearch_title'] = _('phraseanet::recherche avancee'); - $out['bask_rename'] = _('panier:: renommer le panier'); - $out['reg_wrong_sbas'] = _('panier:: Un reportage ne peux recevoir que des elements provenants de la base ou il est enregistre'); - $out['error'] = _('phraseanet:: Erreur'); - $out['warningDenyCgus'] = _('cgus :: Attention, si vous refuser les CGUs de cette base, vous n\'y aures plus acces'); - $out['cgusRelog'] = _('cgus :: Vous devez vous reauthentifier pour que vos parametres soient pris en compte.'); - $out['editDelMulti'] = _('edit:: Supprimer %s du champ dans les records selectionnes'); - $out['editAddMulti'] = _('edit:: Ajouter %s au champ courrant pour les records selectionnes'); - $out['editDelSimple'] = _('edit:: Supprimer %s du champ courrant'); - $out['editAddSimple'] = _('edit:: Ajouter %s au champ courrant'); - $out['cantDeletePublicOne'] = _('panier:: vous ne pouvez pas supprimer un panier public'); - $out['wrongsbas'] = _('panier:: Un reportage ne peux recevoir que des elements provenants de la base ou il est enregistre'); - $out['max_record_selected'] = _('Vous ne pouvez pas selectionner plus de 800 enregistrements'); - $out['confirmRedirectAuth'] = _('invite:: Redirection vers la zone d\'authentification, cliquez sur OK pour continuer ou annulez'); - $out['error_test_publi'] = _('Erreur : soit les parametres sont incorrects, soit le serveur distant ne repond pas'); - $out['test_publi_ok'] = _('Les parametres sont corrects, le serveur distant est operationnel'); - $out['some_not_published'] = _('Certaines publications n\'ont pu etre effectuees, verifiez vos parametres'); - $out['error_not_published'] = _('Aucune publication effectuee, verifiez vos parametres'); - $out['warning_delete_publi'] = _('Attention, en supprimant ce preregalge, vous ne pourrez plus modifier ou supprimer de publications prealablement effectues avec celui-ci'); - $out['some_required_fields'] = _('edit::certains documents possedent des champs requis non remplis. Merci de les remplir pour valider votre editing'); - $out['nodocselected'] = _('Aucun document selectionne'); - $out['sureToRemoveList'] = _('Are you sure you want to delete this list ?'); - $out['newListName'] = _('New list name ?'); - $out['listNameCannotBeEmpty'] = _('List name can not be empty'); - $out['FeedBackName'] = _('Name'); - $out['FeedBackMessage'] = _('Message'); - $out['FeedBackDuration'] = _('Time for feedback (days)'); - $out['FeedBackNameMandatory'] = _('Please provide a name for this selection.'); - $out['send'] = _('Send'); - $out['Recept'] = _('Accuse de reception'); - $out['nFieldsChanged'] = _('%d fields have been updated'); - $out['FeedBackNoUsersSelected'] = _('No users selected'); - $out['errorFileApi'] = _('An error occurred reading this file'); - $out['errorFileApiTooBig'] = _('This file is too big'); - $out['selectOneRecord'] = _('Please select one record'); - $out['onlyOneRecord'] = _('You can choose only one record'); - $out['errorAjaxRequest'] = _('An error occured, please retry'); - $out['fileBeingDownloaded'] = _('Some files are being downloaded'); - $out['warning'] = _('Attention'); - $out['browserFeatureSupport'] = _('This feature is not supported by your browser'); - $out['noActiveBasket'] = _('No active basket'); - $out['pushUserCanDownload'] = _('User can download HD'); - $out['feedbackCanContribute'] = _('User contribute to the feedback'); - $out['feedbackCanSeeOthers'] = _('User can see others choices'); - $out['forceSendDocument'] = _('Force sending of the document ?'); - $out['export'] = _('Export'); - $out['share'] = _('Share'); - $out['move'] = _('Move'); - $out['push'] = _('Push'); - $out['feedback'] = _('Feedback'); - $out['toolbox'] = _('Tool box'); - $out['print'] = _('Print'); - $out['attention'] = _('Attention !'); + $out['serverTimeout'] = $app->trans('phraseanet::erreur: La connection au serveur Phraseanet semble etre indisponible'); + $out['serverDisconnected'] = $app->trans('phraseanet::erreur: Votre session est fermee, veuillez vous re-authentifier'); + $out['hideMessage'] = $app->trans('phraseanet::Ne plus afficher ce message'); + $out['confirmGroup'] = $app->trans('Supprimer egalement les documents rattaches a ces regroupements'); + $out['confirmDelete'] = $app->trans('reponses:: Ces enregistrements vont etre definitivement supprimes et ne pourront etre recuperes. Etes vous sur ?'); + $out['cancel'] = $app->trans('boutton::annuler'); + $out['deleteTitle'] = $app->trans('boutton::supprimer'); + $out['deleteRecords'] = $app->trans('Delete records'); + $out['edit_hetero'] = $app->trans('prod::editing valeurs heterogenes, choisir \'remplacer\', \'ajouter\' ou \'annuler\''); + $out['confirm_abandon'] = $app->trans('prod::editing::annulation: abandonner les modification ?'); + $out['loading'] = $app->trans('phraseanet::chargement'); + $out['valider'] = $app->trans('boutton::valider'); + $out['annuler'] = $app->trans('boutton::annuler'); + $out['create'] = $app->trans('boutton::creer'); + $out['rechercher'] = $app->trans('boutton::rechercher'); + $out['renewRss'] = $app->trans('boutton::renouveller'); + $out['candeletesome'] = $app->trans('Vous n\'avez pas les droits pour supprimer certains documents'); + $out['candeletedocuments'] = $app->trans('Vous n\'avez pas les droits pour supprimer ces documents'); + $out['needTitle'] = $app->trans('Vous devez donner un titre'); + $out['newPreset'] = $app->trans('Nouveau modele'); + $out['fermer'] = $app->trans('boutton::fermer'); + $out['feed_require_fields'] = $app->trans('Vous n\'avez pas rempli tous les champ requis'); + $out['feed_require_feed'] = $app->trans('Vous n\'avez pas selectionne de fil de publication'); + $out['removeTitle'] = $app->trans('panier::Supression d\'un element d\'un reportage'); + $out['confirmRemoveReg'] = $app->trans('panier::Attention, vous etes sur le point de supprimer un element du reportage. Merci de confirmer votre action.'); + $out['advsearch_title'] = $app->trans('phraseanet::recherche avancee'); + $out['bask_rename'] = $app->trans('panier:: renommer le panier'); + $out['reg_wrong_sbas'] = $app->trans('panier:: Un reportage ne peux recevoir que des elements provenants de la base ou il est enregistre'); + $out['error'] = $app->trans('phraseanet:: Erreur'); + $out['warningDenyCgus'] = $app->trans('cgus :: Attention, si vous refuser les CGUs de cette base, vous n\'y aures plus acces'); + $out['cgusRelog'] = $app->trans('cgus :: Vous devez vous reauthentifier pour que vos parametres soient pris en compte.'); + $out['editDelMulti'] = $app->trans('edit:: Supprimer %s du champ dans les records selectionnes'); + $out['editAddMulti'] = $app->trans('edit:: Ajouter %s au champ courrant pour les records selectionnes'); + $out['editDelSimple'] = $app->trans('edit:: Supprimer %s du champ courrant'); + $out['editAddSimple'] = $app->trans('edit:: Ajouter %s au champ courrant'); + $out['cantDeletePublicOne'] = $app->trans('panier:: vous ne pouvez pas supprimer un panier public'); + $out['wrongsbas'] = $app->trans('panier:: Un reportage ne peux recevoir que des elements provenants de la base ou il est enregistre'); + $out['max_record_selected'] = $app->trans('Vous ne pouvez pas selectionner plus de 800 enregistrements'); + $out['confirmRedirectAuth'] = $app->trans('invite:: Redirection vers la zone d\'authentification, cliquez sur OK pour continuer ou annulez'); + $out['error_test_publi'] = $app->trans('Erreur : soit les parametres sont incorrects, soit le serveur distant ne repond pas'); + $out['test_publi_ok'] = $app->trans('Les parametres sont corrects, le serveur distant est operationnel'); + $out['some_not_published'] = $app->trans('Certaines publications n\'ont pu etre effectuees, verifiez vos parametres'); + $out['error_not_published'] = $app->trans('Aucune publication effectuee, verifiez vos parametres'); + $out['warning_delete_publi'] = $app->trans('Attention, en supprimant ce preregalge, vous ne pourrez plus modifier ou supprimer de publications prealablement effectues avec celui-ci'); + $out['some_required_fields'] = $app->trans('edit::certains documents possedent des champs requis non remplis. Merci de les remplir pour valider votre editing'); + $out['nodocselected'] = $app->trans('Aucun document selectionne'); + $out['sureToRemoveList'] = $app->trans('Are you sure you want to delete this list ?'); + $out['newListName'] = $app->trans('New list name ?'); + $out['listNameCannotBeEmpty'] = $app->trans('List name can not be empty'); + $out['FeedBackName'] = $app->trans('Name'); + $out['FeedBackMessage'] = $app->trans('Message'); + $out['FeedBackDuration'] = $app->trans('Time for feedback (days)'); + $out['FeedBackNameMandatory'] = $app->trans('Please provide a name for this selection.'); + $out['send'] = $app->trans('Send'); + $out['Recept'] = $app->trans('Accuse de reception'); + $out['nFieldsChanged'] = $app->trans('%d fields have been updated'); + $out['FeedBackNoUsersSelected'] = $app->trans('No users selected'); + $out['errorFileApi'] = $app->trans('An error occurred reading this file'); + $out['errorFileApiTooBig'] = $app->trans('This file is too big'); + $out['selectOneRecord'] = $app->trans('Please select one record'); + $out['onlyOneRecord'] = $app->trans('You can choose only one record'); + $out['errorAjaxRequest'] = $app->trans('An error occured, please retry'); + $out['fileBeingDownloaded'] = $app->trans('Some files are being downloaded'); + $out['warning'] = $app->trans('Attention'); + $out['browserFeatureSupport'] = $app->trans('This feature is not supported by your browser'); + $out['noActiveBasket'] = $app->trans('No active basket'); + $out['pushUserCanDownload'] = $app->trans('User can download HD'); + $out['feedbackCanContribute'] = $app->trans('User contribute to the feedback'); + $out['feedbackCanSeeOthers'] = $app->trans('User can see others choices'); + $out['forceSendDocument'] = $app->trans('Force sending of the document ?'); + $out['export'] = $app->trans('Export'); + $out['share'] = $app->trans('Share'); + $out['move'] = $app->trans('Move'); + $out['push'] = $app->trans('Push'); + $out['feedback'] = $app->trans('Feedback'); + $out['toolbox'] = $app->trans('Tool box'); + $out['print'] = $app->trans('Print'); + $out['attention'] = $app->trans('Attention !'); return $app->json($out); }); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Lazaret.php b/lib/Alchemy/Phrasea/Controller/Prod/Lazaret.php index 1c0f709e90..4ca3427a87 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Lazaret.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Lazaret.php @@ -113,7 +113,7 @@ class Lazaret implements ControllerProviderInterface /* @var $lazaretFile LazaretFile */ if (null === $lazaretFile) { - $ret['message'] = _('File is not present in quarantine anymore, please refresh'); + $ret['message'] = $app->trans('File is not present in quarantine anymore, please refresh'); return $app->json($ret); } @@ -157,7 +157,7 @@ class Lazaret implements ControllerProviderInterface //Mandatory parameter if (null === $request->request->get('bas_id')) { - $ret['message'] = _('You must give a destination collection'); + $ret['message'] = $app->trans('You must give a destination collection'); return $app->json($ret); } @@ -166,7 +166,7 @@ class Lazaret implements ControllerProviderInterface /* @var $lazaretFile LazaretFile */ if (null === $lazaretFile) { - $ret['message'] = _('File is not present in quarantine anymore, please refresh'); + $ret['message'] = $app->trans('File is not present in quarantine anymore, please refresh'); return $app->json($ret); } @@ -246,7 +246,7 @@ class Lazaret implements ControllerProviderInterface $ret['success'] = true; } catch (\Exception $e) { - $ret['message'] = _('An error occured'); + $ret['message'] = $app->trans('An error occured'); } try { @@ -274,7 +274,7 @@ class Lazaret implements ControllerProviderInterface $lazaretFile = $app['EM']->find('Alchemy\Phrasea\Model\Entities\LazaretFile', $file_id); /* @var $lazaretFile LazaretFile */ if (null === $lazaretFile) { - $ret['message'] = _('File is not present in quarantine anymore, please refresh'); + $ret['message'] = $app->trans('File is not present in quarantine anymore, please refresh'); return $app->json($ret); } @@ -330,7 +330,7 @@ class Lazaret implements ControllerProviderInterface $ret['success'] = true; } catch (\Exception $e) { $app['EM']->rollback(); - $ret['message'] = _('An error occured'); + $ret['message'] = $app->trans('An error occured'); } return $app->json($ret); @@ -351,7 +351,7 @@ class Lazaret implements ControllerProviderInterface //Mandatory parameter if (null === $recordId = $request->request->get('record_id')) { - $ret['message'] = _('You must give a destination record'); + $ret['message'] = $app->trans('You must give a destination record'); return $app->json($ret); } @@ -360,7 +360,7 @@ class Lazaret implements ControllerProviderInterface /* @var $lazaretFile LazaretFile */ if (null === $lazaretFile) { - $ret['message'] = _('File is not present in quarantine anymore, please refresh'); + $ret['message'] = $app->trans('File is not present in quarantine anymore, please refresh'); return $app->json($ret); } @@ -378,7 +378,7 @@ class Lazaret implements ControllerProviderInterface } if (!$found) { - $ret['message'] = _('The destination record provided is not allowed'); + $ret['message'] = $app->trans('The destination record provided is not allowed'); return $app->json($ret); } @@ -404,7 +404,7 @@ class Lazaret implements ControllerProviderInterface $ret['success'] = true; } catch (\Exception $e) { - $ret['message'] = _('An error occured'); + $ret['message'] = $app->trans('An error occured'); } try { diff --git a/lib/Alchemy/Phrasea/Controller/Prod/MoveCollection.php b/lib/Alchemy/Phrasea/Controller/Prod/MoveCollection.php index c30b57173d..3740d109c7 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/MoveCollection.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/MoveCollection.php @@ -70,13 +70,13 @@ class MoveCollection implements ControllerProviderInterface try { if (null === $request->request->get('base_id')) { - $datas['message'] = _('Missing target collection'); + $datas['message'] = $app->trans('Missing target collection'); return $app->json($datas); } if (!$app['acl']->get($app['authentication']->getUser())->has_right_on_base($request->request->get('base_id'), 'canaddrecord')) { - $datas['message'] = sprintf(_("You do not have the permission to move records to %s"), \phrasea::bas_labels($move->getBaseIdDestination(), $app)); + $datas['message'] = $app->trans("You do not have the permission to move records to %collection%", array('%collection%', \phrasea::bas_labels($request->request->get('base_id'), $app))); return $app->json($datas); } @@ -84,7 +84,7 @@ class MoveCollection implements ControllerProviderInterface try { $collection = \collection::get_from_base_id($app, $request->request->get('base_id')); } catch (\Exception_Databox_CollectionNotFound $e) { - $datas['message'] = _('Invalid target collection'); + $datas['message'] = $app->trans('Invalid target collection'); return $app->json($datas); } @@ -103,12 +103,12 @@ class MoveCollection implements ControllerProviderInterface $ret = [ 'success' => true, - 'message' => _('Records have been successfuly moved'), + 'message' => $app->trans('Records have been successfuly moved'), ]; } catch (\Exception $e) { $ret = [ 'success' => false, - 'message' => _('An error occured'), + 'message' => $app->trans('An error occured'), ]; } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Order.php b/lib/Alchemy/Phrasea/Controller/Prod/Order.php index a5dc6c8694..4363669f83 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Order.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Order.php @@ -135,7 +135,7 @@ class Order implements ControllerProviderInterface }); if ($noAdmins) { - $msg = _('There is no one to validate orders, please contact an administrator'); + $msg = $app->trans('There is no one to validate orders, please contact an administrator'); } $order->setTodo($order->getElements()->count()); @@ -154,12 +154,12 @@ class Order implements ControllerProviderInterface } if ($success) { - $msg = _('The records have been properly ordered'); + $msg = $app->trans('The records have been properly ordered'); } else { - $msg = _('An error occured'); + $msg = $app->trans('An error occured'); } } else { - $msg = _('There is no record eligible for an order'); + $msg = $app->trans('There is no record eligible for an order'); } if ('json' === $app['request']->getRequestFormat()) { @@ -247,7 +247,7 @@ class Order implements ControllerProviderInterface if (null === $basket) { $basket = new Basket(); - $basket->setName(sprintf(_('Commande du %s'), $order->getCreatedOn()->format('Y-m-d'))); + $basket->setName($app->trans('Commande du %date%', array('%date%' => $order->getCreatedOn()->format('Y-m-d')))); $basket->setOwner($dest_user); $basket->setPusher($app['authentication']->getUser()); @@ -301,7 +301,7 @@ class Order implements ControllerProviderInterface if ('json' === $app['request']->getRequestFormat()) { return $app->json([ 'success' => $success, - 'msg' => $success ? _('Order has been sent') : _('An error occured while sending, please retry or contact an admin if problem persists'), + 'msg' => $success ? $app->trans('Order has been sent') : $app->trans('An error occured while sending, please retry or contact an admin if problem persists'), 'order_id' => $order_id ]); } @@ -361,7 +361,7 @@ class Order implements ControllerProviderInterface if ('json' === $app['request']->getRequestFormat()) { return $app->json([ 'success' => $success, - 'msg' => $success ? _('Order has been denied') : _('An error occured while denying, please retry or contact an admin if problem persists'), + 'msg' => $success ? $app->trans('Order has been denied') : $app->trans('An error occured while denying, please retry or contact an admin if problem persists'), 'order_id' => $order_id ]); } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Push.php b/lib/Alchemy/Phrasea/Controller/Prod/Push.php index fd90a1a9cc..ed389c9656 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Push.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Push.php @@ -154,30 +154,30 @@ class Push implements ControllerProviderInterface $ret = [ 'success' => false, - 'message' => _('Unable to send the documents') + 'message' => $app->trans('Unable to send the documents') ]; try { $pusher = new RecordHelper\Push($app, $app['request']); - $push_name = $request->request->get('name', sprintf(_('Push from %s'), $app['authentication']->getUser()->get_display_name())); + $push_name = $request->request->get('name', $app->trans('Push from %user%', array('%user%' => $app['authentication']->getUser()->get_display_name()))); $push_description = $request->request->get('push_description'); $receivers = $request->request->get('participants'); if (!is_array($receivers) || count($receivers) === 0) { - throw new ControllerException(_('No receivers specified')); + throw new ControllerException($app->trans('No receivers specified')); } if (!is_array($pusher->get_elements()) || count($pusher->get_elements()) === 0) { - throw new ControllerException(_('No elements to push')); + throw new ControllerException($app->trans('No elements to push')); } foreach ($receivers as $receiver) { try { $user_receiver = \User_Adapter::getInstance($receiver['usr_id'], $app); } catch (\Exception $e) { - throw new ControllerException(sprintf(_('Unknown user %d'), $receiver['usr_id'])); + throw new ControllerException($app->trans('Unknown user %user_id%', array('%user_id%' => $receiver['usr_id']))); } $Basket = new Basket(); @@ -247,11 +247,10 @@ class Push implements ControllerProviderInterface $app['EM']->flush(); - $message = sprintf( - _('%1$d records have been sent to %2$d users') - , count($pusher->get_elements()) - , count($receivers) - ); + $message = $app->trans('%quantity_records% records have been sent to %quantity_users% users', array( + '%quantity_records%' => count($pusher->get_elements()), + '%quantity_users%' => count($receivers), + )); $ret = [ 'success' => true, @@ -269,7 +268,7 @@ class Push implements ControllerProviderInterface $ret = [ 'success' => false, - 'message' => _('Unable to send the documents') + 'message' => $app->trans('Unable to send the documents') ]; $app['EM']->beginTransaction(); @@ -279,17 +278,17 @@ class Push implements ControllerProviderInterface $repository = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Basket'); - $validation_name = $request->request->get('name', sprintf(_('Validation from %s'), $app['authentication']->getUser()->get_display_name())); + $validation_name = $request->request->get('name', $app->trans('Validation from %user%', array('%user%' => $app['authentication']->getUser()->get_display_name()))); $validation_description = $request->request->get('validation_description'); $participants = $request->request->get('participants'); if (!is_array($participants) || count($participants) === 0) { - throw new ControllerException(_('No participants specified')); + throw new ControllerException($app->trans('No participants specified')); } if (!is_array($pusher->get_elements()) || count($pusher->get_elements()) === 0) { - throw new ControllerException(_('No elements to validate')); + throw new ControllerException($app->trans('No elements to validate')); } if ($pusher->is_basket()) { @@ -355,13 +354,13 @@ class Push implements ControllerProviderInterface foreach ($participants as $key => $participant) { foreach (['see_others', 'usr_id', 'agree', 'HD'] as $mandatoryparam) { if (!array_key_exists($mandatoryparam, $participant)) - throw new ControllerException(sprintf(_('Missing mandatory parameter %s'), $mandatoryparam)); + throw new ControllerException($app->trans('Missing mandatory parameter %parameter%', array('%parameter%' => $mandatoryparam))); } try { $participant_user = \User_Adapter::getInstance($participant['usr_id'], $app); } catch (\Exception $e) { - throw new ControllerException(sprintf(_('Unknown user %d'), $receiver['usr_id'])); + throw new ControllerException($app->trans('Unknown user %usr_id%', array('%usr_id%' => $participant['usr_id']))); } try { @@ -446,11 +445,10 @@ class Push implements ControllerProviderInterface $app['EM']->flush(); - $message = sprintf( - _('%1$d records have been sent for validation to %2$d users') - , count($pusher->get_elements()) - , count($request->request->get('participants')) - ); + $message = $app->trans('%quantity_records% records have been sent for validation to %quantity_users% users', array( + '%quantity_records%' => count($pusher->get_elements()), + '%quantity_users%' => count($request->request->get('participants')), + )); $ret = [ 'success' => true, @@ -511,19 +509,19 @@ class Push implements ControllerProviderInterface try { if (!$app['acl']->get($app['authentication']->getUser())->has_right('manageusers')) - throw new ControllerException(_('You are not allowed to add users')); + throw new ControllerException($app->trans('You are not allowed to add users')); if (!$request->request->get('firstname')) - throw new ControllerException(_('First name is required')); + throw new ControllerException($app->trans('First name is required')); if (!$request->request->get('lastname')) - throw new ControllerException(_('Last name is required')); + throw new ControllerException($app->trans('Last name is required')); if (!$request->request->get('email')) - throw new ControllerException(_('Email is required')); + throw new ControllerException($app->trans('Email is required')); if (!\Swift_Validate::email($request->request->get('email'))) - throw new ControllerException(_('Email is invalid')); + throw new ControllerException($app->trans('Email is invalid')); } catch (ControllerException $e) { $result['message'] = $e->getMessage(); @@ -537,7 +535,7 @@ class Push implements ControllerProviderInterface $usr_id = \User_Adapter::get_usr_id_from_email($app, $email); $user = \User_Adapter::getInstance($usr_id, $app); - $result['message'] = _('User already exists'); + $result['message'] = $app->trans('User already exists'); $result['success'] = true; $result['user'] = $userFormatter($user); } catch (\Exception $e) { @@ -560,11 +558,11 @@ class Push implements ControllerProviderInterface if ($request->request->get('form_geonameid')) $user->set_geonameid($request->request->get('form_geonameid')); - $result['message'] = _('User successfully created'); + $result['message'] = $app->trans('User successfully created'); $result['success'] = true; $result['user'] = $userFormatter($user); } catch (\Exception $e) { - $result['message'] = _('Error while creating user'); + $result['message'] = $app->trans('Error while creating user'); } } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Query.php b/lib/Alchemy/Phrasea/Controller/Prod/Query.php index c49c8c8e2a..01c4cdb0b6 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Query.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Query.php @@ -153,16 +153,16 @@ class Query implements ControllerProviderInterface $explain .= ""; if ($result->getTotal() != $result->getAvailable()) { - $explain .= sprintf(_('reponses:: %d Resultats rappatries sur un total de %d trouves'), $result->getAvailable(), $result->getTotal()); + $explain .= $app->trans('reponses:: %available% Resultats rappatries sur un total de %total% trouves', array('available' => $result->getAvailable(), '%total%' => $result->getTotal())); } else { - $explain .= sprintf(_('reponses:: %d Resultats'), $result->getTotal()); + $explain .= $app->trans('reponses:: %total% Resultats', array('%total%' => $result->getTotal())); } $explain .= " "; $explain .= '
' . $result->getDuration() . ' s
dans index ' . $result->getIndexes(); $explain .= ""; - $infoResult = '' . sprintf(_('reponses:: %d reponses'), $result->getTotal()) . ' | ' . sprintf(_('reponses:: %s documents selectionnes'), ''); + $infoResult = '' . $app->trans('reponses:: %total% reponses', array('%total%' => $result->getTotal())) . ' | ' . $app->trans('reponses:: %number% documents selectionnes', array('%number%' => '')); $json['infos'] = $infoResult; $json['navigation'] = $string; diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Root.php b/lib/Alchemy/Phrasea/Controller/Prod/Root.php index 63cf73e046..f956336a56 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Root.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Root.php @@ -77,7 +77,7 @@ class Root implements ControllerProviderInterface $queries_topics = ''; if ($app['phraseanet.registry']->get('GV_client_render_topics') == 'popups') { - $queries_topics = \queries::dropdown_topics($app['locale.I18n']); + $queries_topics = \queries::dropdown_topics($app['translator'], $app['locale.I18n']); } elseif ($app['phraseanet.registry']->get('GV_client_render_topics') == 'tree') { $queries_topics = \queries::tree_topics($app['locale.I18n']); } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Story.php b/lib/Alchemy/Phrasea/Controller/Prod/Story.php index 33b008cf99..66b0ddfaed 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Story.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Story.php @@ -87,7 +87,7 @@ class Story implements ControllerProviderInterface if ($request->getRequestFormat() == 'json') { $data = [ 'success' => true - , 'message' => _('Story created') + , 'message' => $app->trans('Story created') , 'WorkZone' => $StoryWZ->getId() , 'story' => [ 'sbas_id' => $Story->get_sbas_id(), @@ -136,7 +136,7 @@ class Story implements ControllerProviderInterface $data = [ 'success' => true - , 'message' => sprintf(_('%d records added'), $n) + , 'message' => $app->trans('%quantity% records added', array('%quantity%' => $n)) ]; if ($request->getRequestFormat() == 'json') { @@ -158,7 +158,7 @@ class Story implements ControllerProviderInterface $data = [ 'success' => true - , 'message' => _('Record removed from story') + , 'message' => $app->trans('Record removed from story') ]; if ($request->getRequestFormat() == 'json') { @@ -195,7 +195,7 @@ class Story implements ControllerProviderInterface ->assert('record_id', '\d+'); $controllers->post('/{sbas_id}/{record_id}/reorder/', function (Application $app, $sbas_id, $record_id) { - $ret = ['success' => false, 'message' => _('An error occured')]; + $ret = ['success' => false, 'message' => $app->trans('An error occured')]; try { $story = new \record_adapter($app, $sbas_id, $record_id); @@ -205,7 +205,7 @@ class Story implements ControllerProviderInterface } if (!$app['acl']->get($app['authentication']->getUser())->has_right_on_base($story->get_base_id(), 'canmodifrecord')) { - throw new ControllerException(_('You can not edit this story')); + throw new ControllerException($app->trans('You can not edit this story')); } $sql = 'UPDATE regroup SET ord = :ord @@ -223,7 +223,7 @@ class Story implements ControllerProviderInterface $stmt->closeCursor(); - $ret = ['success' => true, 'message' => _('Story updated')]; + $ret = ['success' => true, 'message' => $app->trans('Story updated')]; } catch (ControllerException $e) { $ret = ['success' => false, 'message' => $e->getMessage()]; } catch (\Exception $e) { diff --git a/lib/Alchemy/Phrasea/Controller/Prod/TOU.php b/lib/Alchemy/Phrasea/Controller/Prod/TOU.php index 1ce737297a..cb4fbf994e 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/TOU.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/TOU.php @@ -95,7 +95,7 @@ class TOU implements ControllerProviderInterface return new Response($app['twig']->render('/prod/TOU.html.twig', [ 'TOUs' => $data, - 'local_title' => _('Terms of use') + 'local_title' => $app->trans('Terms of use') ])); } } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Tools.php b/lib/Alchemy/Phrasea/Controller/Prod/Tools.php index 81eb24243d..e67c51e741 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Tools.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Tools.php @@ -111,7 +111,7 @@ class Tools implements ControllerProviderInterface $controllers->post('/hddoc/', function (Application $app, Request $request) { $success = false; - $message = _('An error occured'); + $message = $app->trans('An error occured'); if ($file = $request->files->get('newHD')) { @@ -153,12 +153,12 @@ class Tools implements ControllerProviderInterface unlink($tempoFile); rmdir($tempoDir); $success = true; - $message = _('Document has been successfully substitued'); + $message = $app->trans('Document has been successfully substitued'); } catch (\Exception $e) { - $message = _('file is not valid'); + $message = $app->trans('file is not valid'); } } else { - $message = _('file is not valid'); + $message = $app->trans('file is not valid'); } } else { $app->abort(400, 'Missing file parameter'); @@ -172,7 +172,7 @@ class Tools implements ControllerProviderInterface $controllers->post('/chgthumb/', function (Application $app, Request $request) { $success = false; - $message = _('An error occured'); + $message = $app->trans('An error occured'); if ($file = $request->files->get('newThumb')) { @@ -207,12 +207,12 @@ class Tools implements ControllerProviderInterface unlink($tempoFile); rmdir($tempoDir); $success = true; - $message = _('Thumbnail has been successfully substitued'); + $message = $app->trans('Thumbnail has been successfully substitued'); } catch (\Exception $e) { - $message = _('file is not valid'); + $message = $app->trans('file is not valid'); } } else { - $message = _('file is not valid'); + $message = $app->trans('file is not valid'); } } else { $app->abort(400, 'Missing file parameter'); @@ -236,7 +236,7 @@ class Tools implements ControllerProviderInterface ]; $return['datas'] = $app['twig']->render($template, $var); } catch (\Exception $e) { - $return['datas'] = _('an error occured'); + $return['datas'] = $app->trans('an error occured'); $return['error'] = true; } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Upload.php b/lib/Alchemy/Phrasea/Controller/Prod/Upload.php index aeb1e6dd95..607ba7d6fb 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Upload.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Upload.php @@ -180,10 +180,10 @@ class Upload implements ControllerProviderInterface $reasons = []; $elementCreated = null; - $callback = function ($element, $visa, $code) use (&$reasons, &$elementCreated) { + $callback = function ($element, $visa, $code) use ($app, &$reasons, &$elementCreated) { foreach ($visa->getResponses() as $response) { if (!$response->isOk()) { - $reasons[] = $response->getMessage(); + $reasons[] = $response->getMessage($app['translator']); } } @@ -203,7 +203,7 @@ class Upload implements ControllerProviderInterface if ($elementCreated instanceof \record_adapter) { $id = $elementCreated->get_serialize_key(); $element = 'record'; - $message = _('The record was successfully created'); + $message = $app->trans('The record was successfully created'); $app['phraseanet.SE']->addRecord($elementCreated); // try to create thumbnail from data URI @@ -235,7 +235,7 @@ class Upload implements ControllerProviderInterface $id = $elementCreated->getId(); $element = 'lazaret'; - $message = _('The file was moved to the quarantine'); + $message = $app->trans('The file was moved to the quarantine'); } $datas = [ @@ -247,7 +247,7 @@ class Upload implements ControllerProviderInterface 'id' => $id, ]; } catch (\Exception $e) { - $datas['message'] = _('Unable to add file to Phraseanet'); + $datas['message'] = $app->trans('Unable to add file to Phraseanet'); } $response = $app->json($datas); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php b/lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php index b1cff393ed..0df6380246 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php @@ -153,13 +153,13 @@ class UsrLists implements ControllerProviderInterface $datas = [ 'success' => false - , 'message' => sprintf(_('Unable to create list %s'), $list_name) + , 'message' => $app->trans('Unable to create list %name%', array('%name%' => $list_name)) , 'list_id' => null ]; try { if (!$list_name) { - throw new ControllerException(_('List name is required')); + throw new ControllerException($app->trans('List name is required')); } $List = new UsrList(); @@ -178,7 +178,7 @@ class UsrLists implements ControllerProviderInterface $datas = [ 'success' => true - , 'message' => sprintf(_('List %s has been created'), $list_name) + , 'message' => $app->trans('List %name% has been created', array('%name%' => $list_name)) , 'list_id' => $List->getId() ]; } catch (ControllerException $e) { @@ -243,14 +243,14 @@ class UsrLists implements ControllerProviderInterface $datas = [ 'success' => false - , 'message' => _('Unable to update list') + , 'message' => $app->trans('Unable to update list') ]; try { $list_name = $request->request->get('name'); if (!$list_name) { - throw new ControllerException(_('List name is required')); + throw new ControllerException($app->trans('List name is required')); } $repository = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\UsrList'); @@ -258,7 +258,7 @@ class UsrLists implements ControllerProviderInterface $list = $repository->findUserListByUserAndId($app, $app['authentication']->getUser(), $list_id); if ($list->getOwner($app['authentication']->getUser(), $app)->getRole() < UsrListOwner::ROLE_EDITOR) { - throw new ControllerException(_('You are not authorized to do this')); + throw new ControllerException($app->trans('You are not authorized to do this')); } $list->setName($list_name); @@ -267,7 +267,7 @@ class UsrLists implements ControllerProviderInterface $datas = [ 'success' => true - , 'message' => _('List has been updated') + , 'message' => $app->trans('List has been updated') ]; } catch (ControllerException $e) { $datas = [ @@ -289,7 +289,7 @@ class UsrLists implements ControllerProviderInterface $list = $repository->findUserListByUserAndId($app, $app['authentication']->getUser(), $list_id); if ($list->getOwner($app['authentication']->getUser(), $app)->getRole() < UsrListOwner::ROLE_ADMIN) { - throw new ControllerException(_('You are not authorized to do this')); + throw new ControllerException($app->trans('You are not authorized to do this')); } $app['EM']->remove($list); @@ -297,7 +297,7 @@ class UsrLists implements ControllerProviderInterface $datas = [ 'success' => true - , 'message' => sprintf(_('List has been deleted')) + , 'message' => $app->trans('List has been deleted') ]; } catch (ControllerException $e) { $datas = [ @@ -308,7 +308,7 @@ class UsrLists implements ControllerProviderInterface $datas = [ 'success' => false - , 'message' => sprintf(_('Unable to delete list')) + , 'message' => $app->trans('Unable to delete list') ]; } @@ -324,7 +324,7 @@ class UsrLists implements ControllerProviderInterface /* @var $list UsrList */ if ($list->getOwner($app['authentication']->getUser(), $app)->getRole() < UsrListOwner::ROLE_EDITOR) { - throw new ControllerException(_('You are not authorized to do this')); + throw new ControllerException($app->trans('You are not authorized to do this')); } $entry_repository = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\UsrListEntry'); @@ -336,7 +336,7 @@ class UsrLists implements ControllerProviderInterface $datas = [ 'success' => true - , 'message' => _('Entry removed from list') + , 'message' => $app->trans('Entry removed from list') ]; } catch (ControllerException $e) { $datas = [ @@ -344,10 +344,9 @@ class UsrLists implements ControllerProviderInterface , 'message' => $e->getMessage() ]; } catch (\Exception $e) { - $datas = [ - 'success' => false - , 'message' => _('Unable to remove entry from list ' . $e->getMessage()) + 'success' => false, + 'message' => $app->trans('Unable to remove entry from list'), ]; } @@ -367,7 +366,7 @@ class UsrLists implements ControllerProviderInterface /* @var $list UsrList */ if ($list->getOwner($app['authentication']->getUser(), $app)->getRole() < UsrListOwner::ROLE_EDITOR) { - throw new ControllerException(_('You are not authorized to do this')); + throw new ControllerException($app->trans('You are not authorized to do this')); } $inserted_usr_ids = []; @@ -394,13 +393,13 @@ class UsrLists implements ControllerProviderInterface if (count($inserted_usr_ids) > 1) { $datas = [ 'success' => true - , 'message' => sprintf(_('%d Users added to list'), count($inserted_usr_ids)) + , 'message' => $app->trans('%quantity% Users added to list', array('%quantity%' => count($inserted_usr_ids))) , 'result' => $inserted_usr_ids ]; } else { $datas = [ 'success' => true - , 'message' => sprintf(_('%d User added to list'), count($inserted_usr_ids)) + , 'message' => $app->trans('%quantity% User added to list', array('%quantity%' => count($inserted_usr_ids))) , 'result' => $inserted_usr_ids ]; } @@ -413,7 +412,7 @@ class UsrLists implements ControllerProviderInterface $datas = [ 'success' => false - , 'message' => _('Unable to add usr to list') + , 'message' => $app->trans('Unable to add usr to list') ]; } @@ -432,7 +431,7 @@ class UsrLists implements ControllerProviderInterface if ($list->getOwner($app['authentication']->getUser(), $app)->getRole() < UsrListOwner::ROLE_ADMIN) { $list = null; - throw new \Exception(_('You are not authorized to do this')); + throw new \Exception($app->trans('You are not authorized to do this')); } } catch (\Exception $e) { @@ -461,7 +460,7 @@ class UsrLists implements ControllerProviderInterface /* @var $list UsrList */ if ($list->getOwner($app['authentication']->getUser(), $app)->getRole() < UsrListOwner::ROLE_EDITOR) { - throw new ControllerException(_('You are not authorized to do this')); + throw new ControllerException($app->trans('You are not authorized to do this')); } $new_owner = \User_Adapter::getInstance($usr_id, $app); @@ -490,7 +489,7 @@ class UsrLists implements ControllerProviderInterface $datas = [ 'success' => true - , 'message' => _('List shared to user') + , 'message' => $app->trans('List shared to user') ]; } catch (ControllerException $e) { $datas = [ @@ -501,7 +500,7 @@ class UsrLists implements ControllerProviderInterface $datas = [ 'success' => false - , 'message' => _('Unable to share the list with the usr') + , 'message' => $app->trans('Unable to share the list with the usr') ]; } @@ -517,7 +516,7 @@ class UsrLists implements ControllerProviderInterface /* @var $list UsrList */ if ($list->getOwner($app['authentication']->getUser(), $app)->getRole() < UsrListOwner::ROLE_ADMIN) { - throw new \Exception(_('You are not authorized to do this')); + throw new \Exception($app->trans('You are not authorized to do this')); } $owners_repository = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\UsrListOwner'); @@ -529,7 +528,7 @@ class UsrLists implements ControllerProviderInterface $datas = [ 'success' => true - , 'message' => _('Owner removed from list') + , 'message' => $app->trans('Owner removed from list') ]; } catch (ControllerException $e) { $datas = [ @@ -539,7 +538,7 @@ class UsrLists implements ControllerProviderInterface } catch (\Exception $e) { $datas = [ 'success' => false - , 'message' => _('Unable to remove usr from list') + , 'message' => $app->trans('Unable to remove usr from list') ]; } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/WorkZone.php b/lib/Alchemy/Phrasea/Controller/Prod/WorkZone.php index 14cd04cc29..7c531c8e4c 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/WorkZone.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/WorkZone.php @@ -158,29 +158,15 @@ class WorkZone implements ControllerProviderInterface if ($alreadyFixed === 0) { if ($done <= 1) { - $message = sprintf( - _('%d Story attached to the WorkZone') - , $done - ); + $message = $app->trans('%quantity% Story attached to the WorkZone', array('%quantity%' => $done)); } else { - $message = sprintf( - _('%d Stories attached to the WorkZone') - , $done - ); + $message = $app->trans('%quantity% Stories attached to the WorkZone', array('%quantity%' => $done)); } } else { if ($done <= 1) { - $message = sprintf( - _('%1$d Story attached to the WorkZone, %2$d already attached') - , $done - , $alreadyFixed - ); + $message = $app->trans('%quantity% Story attached to the WorkZone, %quantity_already% already attached', array('%quantity%' => $done, '%quantity_already%' => $alreadyFixed)); } else { - $message = sprintf( - _('%1$d Stories attached to the WorkZone, %2$d already attached') - , $done - , $alreadyFixed - ); + $message = $app->trans('%quantity% Stories attached to the WorkZone, %quantity_already% already attached', array('%quantity%' => $done, '%quantity_already%' => $alreadyFixed)); } } @@ -200,7 +186,6 @@ class WorkZone implements ControllerProviderInterface $repository = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\StoryWZ'); - /* @var $repository Alchemy\Phrasea\Model\Repositories\StoryWZRepository */ $StoryWZ = $repository->findUserStory($app, $app['authentication']->getUser(), $Story); if (!$StoryWZ) { @@ -213,7 +198,7 @@ class WorkZone implements ControllerProviderInterface if ($request->getRequestFormat() == 'json') { return $app->json([ 'success' => true - , 'message' => _('Story detached from the WorkZone') + , 'message' => $app->trans('Story detached from the WorkZone') ]); } diff --git a/lib/Alchemy/Phrasea/Controller/Report/Activity.php b/lib/Alchemy/Phrasea/Controller/Report/Activity.php index d6ba29bd16..2260ec8d3f 100644 --- a/lib/Alchemy/Phrasea/Controller/Report/Activity.php +++ b/lib/Alchemy/Phrasea/Controller/Report/Activity.php @@ -134,11 +134,11 @@ class Activity implements ControllerProviderInterface public function doReportDownloadsByUsers(Application $app, Request $request) { $conf = [ - 'user' => [_('report:: utilisateur'), 0, 1, 0, 0], - 'nbdoc' => [_('report:: nombre de documents'), 0, 0, 0, 0], - 'poiddoc' => [_('report:: poids des documents'), 0, 0, 0, 0], - 'nbprev' => [_('report:: nombre de preview'), 0, 0, 0, 0], - 'poidprev' => [_('report:: poids des previews'), 0, 0, 0, 0] + 'user' => [$app->trans('report:: utilisateur'), 0, 1, 0, 0], + 'nbdoc' => [$app->trans('report:: nombre de documents'), 0, 0, 0, 0], + 'poiddoc' => [$app->trans('report:: poids des documents'), 0, 0, 0, 0], + 'nbprev' => [$app->trans('report:: nombre de preview'), 0, 0, 0, 0], + 'poidprev' => [$app->trans('report:: poids des previews'), 0, 0, 0, 0] ]; $activity = new \module_report_activity( @@ -198,9 +198,9 @@ class Activity implements ControllerProviderInterface public function doReportBestOfQuestions(Application $app, Request $request) { $conf = [ - 'search' => [_('report:: question'), 0, 0, 0, 0], - 'nb' => [_('report:: nombre'), 0, 0, 0, 0], - 'nb_rep' => [_('report:: nombre de reponses'), 0, 0, 0, 0] + 'search' => [$app->trans('report:: question'), 0, 0, 0, 0], + 'nb' => [$app->trans('report:: nombre'), 0, 0, 0, 0], + 'nb_rep' => [$app->trans('report:: nombre de reponses'), 0, 0, 0, 0] ]; $activity = new \module_report_activity( @@ -256,9 +256,9 @@ class Activity implements ControllerProviderInterface public function doReportNoBestOfQuestions(Application $app, Request $request) { $conf = [ - 'search' => [_('report:: question'), 0, 0, 0, 0], - 'nb' => [_('report:: nombre'), 0, 0, 0, 0], - 'nb_rep' => [_('report:: nombre de reponses'), 0, 0, 0, 0] + 'search' => [$app->trans('report:: question'), 0, 0, 0, 0], + 'nb' => [$app->trans('report:: nombre'), 0, 0, 0, 0], + 'nb_rep' => [$app->trans('report:: nombre de reponses'), 0, 0, 0, 0] ]; $activity = new \module_report_activity( @@ -369,10 +369,10 @@ class Activity implements ControllerProviderInterface public function doReportSiteActiviyPerDays(Application $app, Request $request) { $conf = [ - 'ddate' => [_('report:: jour'), 0, 0, 0, 0], - 'total' => [_('report:: total des telechargements'), 0, 0, 0, 0], - 'preview' => [_('report:: preview'), 0, 0, 0, 0], - 'document' => [_('report:: document original'), 0, 0, 0, 0] + 'ddate' => [$app->trans('report:: jour'), 0, 0, 0, 0], + 'total' => [$app->trans('report:: total des telechargements'), 0, 0, 0, 0], + 'preview' => [$app->trans('report:: preview'), 0, 0, 0, 0], + 'document' => [$app->trans('report:: document original'), 0, 0, 0, 0] ]; $activity = new \module_report_activity( @@ -700,7 +700,7 @@ class Activity implements ControllerProviderInterface 'record_id' => ['', 1, 1, 1, 1], 'file' => ['', 1, 0, 1, 1], 'mime' => ['', 1, 0, 1, 1], - 'comment' => [_('Receiver'), 1, 0, 1, 1], + 'comment' => [$app->trans('Receiver'), 1, 0, 1, 1], ]; $activity = new \module_report_sent( @@ -792,7 +792,7 @@ class Activity implements ControllerProviderInterface if ($request->request->get('conf') == 'on') { return $app->json(['liste' => $app['twig']->render('report/listColumn.html.twig', [ 'conf' => $base_conf - ]), "title" => _("configuration")]); + ]), "title" => $app->trans("configuration")]); } //set order @@ -819,7 +819,7 @@ class Activity implements ControllerProviderInterface return $app->json(['diag' => $app['twig']->render('report/colFilter.html.twig', [ 'result' => $report->colFilter($field), 'field' => $field - ]), "title" => sprintf(_('filtrer les resultats sur la colonne %s'), $field)]); + ]), "title" => $app->trans('filtrer les resultats sur la colonne %colonne%', array('%colonne%' => $field))]); } if ($field === $value) { @@ -864,7 +864,7 @@ class Activity implements ControllerProviderInterface 'is_doc' => false ]), 'display_nav' => false, - 'title' => _(sprintf('Groupement des resultats sur le champ %s', $groupField)) + 'title' => $app->trans('Groupement des resultats sur le champ %name%', array('%name%' => $groupField)) ]); } diff --git a/lib/Alchemy/Phrasea/Controller/Report/Informations.php b/lib/Alchemy/Phrasea/Controller/Report/Informations.php index 9a68ac4fa9..efd8ee88ca 100644 --- a/lib/Alchemy/Phrasea/Controller/Report/Informations.php +++ b/lib/Alchemy/Phrasea/Controller/Report/Informations.php @@ -52,34 +52,34 @@ class Informations implements ControllerProviderInterface { $conf = [ 'config' => [ - 'photo' => [_('report:: document'), 0, 0, 0, 0], - 'record_id' => [_('report:: record id'), 0, 0, 0, 0], - 'date' => [_('report:: date'), 0, 0, 0, 0], - 'type' => [_('phrseanet:: sous definition'), 0, 0, 0, 0], - 'titre' => [_('report:: titre'), 0, 0, 0, 0], - 'taille' => [_('report:: poids'), 0, 0, 0, 0] + 'photo' => [$app->trans('report:: document'), 0, 0, 0, 0], + 'record_id' => [$app->trans('report:: record id'), 0, 0, 0, 0], + 'date' => [$app->trans('report:: date'), 0, 0, 0, 0], + 'type' => [$app->trans('phrseanet:: sous definition'), 0, 0, 0, 0], + 'titre' => [$app->trans('report:: titre'), 0, 0, 0, 0], + 'taille' => [$app->trans('report:: poids'), 0, 0, 0, 0] ], 'conf' => [ - 'identifiant' => [_('report:: identifiant'), 0, 0, 0, 0], - 'nom' => [_('report:: nom'), 0, 0, 0, 0], - 'mail' => [_('report:: email'), 0, 0, 0, 0], - 'adresse' => [_('report:: adresse'), 0, 0, 0, 0], - 'tel' => [_('report:: telephone'), 0, 0, 0, 0] + 'identifiant' => [$app->trans('report:: identifiant'), 0, 0, 0, 0], + 'nom' => [$app->trans('report:: nom'), 0, 0, 0, 0], + 'mail' => [$app->trans('report:: email'), 0, 0, 0, 0], + 'adresse' => [$app->trans('report:: adresse'), 0, 0, 0, 0], + 'tel' => [$app->trans('report:: telephone'), 0, 0, 0, 0] ], 'config_cnx' => [ - 'ddate' => [_('report:: date'), 0, 0, 0, 0], - 'appli' => [_('report:: modules'), 0, 0, 0, 0], + 'ddate' => [$app->trans('report:: date'), 0, 0, 0, 0], + 'appli' => [$app->trans('report:: modules'), 0, 0, 0, 0], ], 'config_dl' => [ - 'ddate' => [_('report:: date'), 0, 0, 0, 0], - 'record_id' => [_('report:: record id'), 0, 1, 0, 0], - 'final' => [_('phrseanet:: sous definition'), 0, 0, 0, 0], - 'coll_id' => [_('report:: collections'), 0, 0, 0, 0], - 'comment' => [_('report:: commentaire'), 0, 0, 0, 0], + 'ddate' => [$app->trans('report:: date'), 0, 0, 0, 0], + 'record_id' => [$app->trans('report:: record id'), 0, 1, 0, 0], + 'final' => [$app->trans('phrseanet:: sous definition'), 0, 0, 0, 0], + 'coll_id' => [$app->trans('report:: collections'), 0, 0, 0, 0], + 'comment' => [$app->trans('report:: commentaire'), 0, 0, 0, 0], ], 'config_ask' => [ - 'search' => [_('report:: question'), 0, 0, 0, 0], - 'ddate' => [_('report:: date'), 0, 0, 0, 0] + 'search' => [$app->trans('report:: question'), 0, 0, 0, 0], + 'ddate' => [$app->trans('report:: date'), 0, 0, 0, 0] ] ]; @@ -96,7 +96,7 @@ class Informations implements ControllerProviderInterface if ('' !== $on && $app['phraseanet.registry']->get('GV_anonymousReport') == true) { $conf['conf'] = [ $on => [$on, 0, 0, 0, 0], - 'nb' => [_('report:: nombre'), 0, 0, 0, 0] + 'nb' => [$app->trans('report:: nombre'), 0, 0, 0, 0] ]; } @@ -109,7 +109,7 @@ class Informations implements ControllerProviderInterface $request->request->get('collection' )); $conf_array = $conf['config_cnx']; - $title = _('report:: historique des connexions'); + $title = $app->trans('report:: historique des connexions'); } elseif ($from == 'USR' || $from == 'GEN') { $report = new \module_report_download( $app, @@ -119,7 +119,7 @@ class Informations implements ControllerProviderInterface $request->request->get('collection') ); $conf_array = $conf['config_dl']; - $title = _('report:: historique des telechargements'); + $title = $app->trans('report:: historique des telechargements'); } elseif ($from == 'ASK') { $report = new \module_report_question( $app, @@ -129,7 +129,7 @@ class Informations implements ControllerProviderInterface $request->request->get('collection') ); $conf_array = $conf['config_ask']; - $title = _('report:: historique des questions'); + $title = $app->trans('report:: historique des questions'); } if ($report) { @@ -151,7 +151,7 @@ class Informations implements ControllerProviderInterface return $app->json(['diag' => $app['twig']->render('report/colFilter.html.twig', [ 'result' => $report->colFilter($field), 'field' => $field - ]), 'title' => sprintf(_('filtrer les resultats sur la colonne %s'), $field)]); + ]), 'title' => $app->trans('filtrer les resultats sur la colonne %colonne%', array('%colonne%' => $field))]); } if ($field === $value) { @@ -252,8 +252,8 @@ class Informations implements ControllerProviderInterface public function doReportinformationsBrowser(Application $app, Request $request) { $conf = [ - 'version' => [_('report::version '), 0, 0, 0, 0], - 'nb' => [_('report:: nombre'), 0, 0, 0, 0] + 'version' => [$app->trans('report::version'), 0, 0, 0, 0], + 'nb' => [$app->trans('report:: nombre'), 0, 0, 0, 0] ]; $info = new \module_report_nav( @@ -297,24 +297,24 @@ class Informations implements ControllerProviderInterface public function doReportInformationsDocument(Application $app, Request $request) { $config = [ - 'photo' => [_('report:: document'), 0, 0, 0, 0], - 'record_id' => [_('report:: record id'), 0, 0, 0, 0], - 'date' => [_('report:: date'), 0, 0, 0, 0], - 'type' => [_('phrseanet:: sous definition'), 0, 0, 0, 0], - 'titre' => [_('report:: titre'), 0, 0, 0, 0], - 'taille' => [_('report:: poids'), 0, 0, 0, 0] + 'photo' => [$app->trans('report:: document'), 0, 0, 0, 0], + 'record_id' => [$app->trans('report:: record id'), 0, 0, 0, 0], + 'date' => [$app->trans('report:: date'), 0, 0, 0, 0], + 'type' => [$app->trans('phrseanet:: sous definition'), 0, 0, 0, 0], + 'titre' => [$app->trans('report:: titre'), 0, 0, 0, 0], + 'taille' => [$app->trans('report:: poids'), 0, 0, 0, 0] ]; $config_dl = [ - 'ddate' => [_('report:: date'), 0, 0, 0, 0], - 'user' => [_('report:: utilisateurs'), 0, 0, 0, 0], - 'final' => [_('phrseanet:: sous definition'), 0, 0, 0, 0], - 'coll_id' => [_('report:: collections'), 0, 0, 0, 0], - 'comment' => [_('report:: commentaire'), 0, 0, 0, 0], - 'fonction' => [_('report:: fonction'), 0, 0, 0, 0], - 'activite' => [_('report:: activite'), 0, 0, 0, 0], - 'pays' => [_('report:: pays'), 0, 0, 0, 0], - 'societe' => [_('report:: societe'), 0, 0, 0, 0] + 'ddate' => [$app->trans('report:: date'), 0, 0, 0, 0], + 'user' => [$app->trans('report:: utilisateurs'), 0, 0, 0, 0], + 'final' => [$app->trans('phrseanet:: sous definition'), 0, 0, 0, 0], + 'coll_id' => [$app->trans('report:: collections'), 0, 0, 0, 0], + 'comment' => [$app->trans('report:: commentaire'), 0, 0, 0, 0], + 'fonction' => [$app->trans('report:: fonction'), 0, 0, 0, 0], + 'activite' => [$app->trans('report:: activite'), 0, 0, 0, 0], + 'pays' => [$app->trans('report:: pays'), 0, 0, 0, 0], + 'societe' => [$app->trans('report:: societe'), 0, 0, 0, 0] ]; //format conf according user preferences @@ -409,7 +409,7 @@ class Informations implements ControllerProviderInterface return $app->json(['diag' => $app['twig']->render('report/colFilter.html.twig', [ 'result' => $download->colFilter($field), 'field' => $field - ]), 'title' => sprintf(_('filtrer les resultats sur la colonne %s'), $field)]); + ]), 'title' => $app->trans('filtrer les resultats sur la colonne %colonne%', array('%colonne%' => $field))]); } if ($field === $value) { @@ -423,7 +423,7 @@ class Informations implements ControllerProviderInterface $download->setFilter($filter->getTabFilter()); $download->setOrder('ddate', 'DESC'); - $download->setTitle(_('report:: historique des telechargements')); + $download->setTitle($app->trans('report:: historique des telechargements')); $download->setConfig(false); $reportArray = $download->buildReport($config_dl); @@ -458,11 +458,11 @@ class Informations implements ControllerProviderInterface if ($app['phraseanet.registry']->get('GV_anonymousReport') == false && $from !== 'DOC' && $from !== 'DASH' && $from !== 'GEN' && $from !== 'PUSHDOC') { $conf = [ - 'identifiant' => [_('report:: identifiant'), 0, 0, 0, 0], - 'nom' => [_('report:: nom'), 0, 0, 0, 0], - 'mail' => [_('report:: email'), 0, 0, 0, 0], - 'adresse' => [_('report:: adresse'), 0, 0, 0, 0], - 'tel' => [_('report:: telephone'), 0, 0, 0, 0] + 'identifiant' => [$app->trans('report:: identifiant'), 0, 0, 0, 0], + 'nom' => [$app->trans('report:: nom'), 0, 0, 0, 0], + 'mail' => [$app->trans('report:: email'), 0, 0, 0, 0], + 'adresse' => [$app->trans('report:: adresse'), 0, 0, 0, 0], + 'tel' => [$app->trans('report:: telephone'), 0, 0, 0, 0] ]; $info = new \module_report_nav( @@ -475,11 +475,11 @@ class Informations implements ControllerProviderInterface $info->setPeriode(''); $info->setConfig(false); - $info->setTitle(_('report:: utilisateur')); + $info->setTitle($app->trans('report:: utilisateur')); $reportArray = $info->buildTabGrpInfo(false, [], $request->request->get('user'), $conf, false); - if ($request->request->get('printcsv') == 'on') { + if ($request->request->get('printcsv') == 'on' && isset($download)) { $download->setPrettyString(false); try { diff --git a/lib/Alchemy/Phrasea/Controller/Report/Root.php b/lib/Alchemy/Phrasea/Controller/Report/Root.php index 8f3f818307..63167c9888 100644 --- a/lib/Alchemy/Phrasea/Controller/Report/Root.php +++ b/lib/Alchemy/Phrasea/Controller/Report/Root.php @@ -169,14 +169,14 @@ class Root implements ControllerProviderInterface ); $conf = [ - 'user' => [_('phraseanet::utilisateurs'), 1, 1, 1, 1], - 'ddate' => [_('report:: date'), 1, 0, 1, 1], - 'ip' => [_('report:: IP'), 1, 0, 0, 0], - 'appli' => [_('report:: modules'), 1, 0, 0, 0], - 'fonction' => [_('report::fonction'), 1, 1, 1, 1], - 'activite' => [_('report::activite'), 1, 1, 1, 1], - 'pays' => [_('report::pays'), 1, 1, 1, 1], - 'societe' => [_('report::societe'), 1, 1, 1, 1] + 'user' => [$app->trans('phraseanet::utilisateurs'), 1, 1, 1, 1], + 'ddate' => [$app->trans('report:: date'), 1, 0, 1, 1], + 'ip' => [$app->trans('report:: IP'), 1, 0, 0, 0], + 'appli' => [$app->trans('report:: modules'), 1, 0, 0, 0], + 'fonction' => [$app->trans('report::fonction'), 1, 1, 1, 1], + 'activite' => [$app->trans('report::activite'), 1, 1, 1, 1], + 'pays' => [$app->trans('report::pays'), 1, 1, 1, 1], + 'societe' => [$app->trans('report::societe'), 1, 1, 1, 1] ]; if ($request->request->get('printcsv') == 'on') { @@ -235,13 +235,13 @@ class Root implements ControllerProviderInterface ); $conf = [ - 'user' => [_('report:: utilisateur'), 1, 1, 1, 1], - 'search' => [_('report:: question'), 1, 0, 1, 1], - 'ddate' => [_('report:: date'), 1, 0, 1, 1], - 'fonction' => [_('report:: fonction'), 1, 1, 1, 1], - 'activite' => [_('report:: activite'), 1, 1, 1, 1], - 'pays' => [_('report:: pays'), 1, 1, 1, 1], - 'societe' => [_('report:: societe'), 1, 1, 1, 1] + 'user' => [$app->trans('report:: utilisateur'), 1, 1, 1, 1], + 'search' => [$app->trans('report:: question'), 1, 0, 1, 1], + 'ddate' => [$app->trans('report:: date'), 1, 0, 1, 1], + 'fonction' => [$app->trans('report:: fonction'), 1, 1, 1, 1], + 'activite' => [$app->trans('report:: activite'), 1, 1, 1, 1], + 'pays' => [$app->trans('report:: pays'), 1, 1, 1, 1], + 'societe' => [$app->trans('report:: societe'), 1, 1, 1, 1] ]; if ($request->request->get('printcsv') == 'on') { @@ -306,16 +306,16 @@ class Root implements ControllerProviderInterface } $conf = array_merge([ - 'user' => [_('report:: utilisateurs'), 1, 1, 1, 1], - 'ddate' => [_('report:: date'), 1, 0, 1, 1], - 'record_id' => [_('report:: record id'), 1, 1, 1, 1], - 'final' => [_('phrseanet:: sous definition'), 1, 0, 1, 1], - 'coll_id' => [_('report:: collections'), 1, 0, 1, 1], - 'comment' => [_('report:: commentaire'), 1, 0, 0, 0], - 'fonction' => [_('report:: fonction'), 1, 1, 1, 1], - 'activite' => [_('report:: activite'), 1, 1, 1, 1], - 'pays' => [_('report:: pays'), 1, 1, 1, 1], - 'societe' => [_('report:: societe'), 1, 1, 1, 1] + 'user' => [$app->trans('report:: utilisateurs'), 1, 1, 1, 1], + 'ddate' => [$app->trans('report:: date'), 1, 0, 1, 1], + 'record_id' => [$app->trans('report:: record id'), 1, 1, 1, 1], + 'final' => [$app->trans('phrseanet:: sous definition'), 1, 0, 1, 1], + 'coll_id' => [$app->trans('report:: collections'), 1, 0, 1, 1], + 'comment' => [$app->trans('report:: commentaire'), 1, 0, 0, 0], + 'fonction' => [$app->trans('report:: fonction'), 1, 1, 1, 1], + 'activite' => [$app->trans('report:: activite'), 1, 1, 1, 1], + 'pays' => [$app->trans('report:: pays'), 1, 1, 1, 1], + 'societe' => [$app->trans('report:: societe'), 1, 1, 1, 1] ], $conf_pref); if ($request->request->get('printcsv') == 'on') { @@ -380,12 +380,12 @@ class Root implements ControllerProviderInterface } $conf = array_merge([ - 'telechargement' => [_('report:: telechargements'), 1, 0, 0, 0], - 'record_id' => [_('report:: record id'), 1, 1, 1, 0], - 'final' => [_('phraseanet:: sous definition'), 1, 0, 1, 1], - 'file' => [_('report:: fichier'), 1, 0, 0, 1], - 'mime' => [_('report:: type'), 1, 0, 1, 1], - 'size' => [_('report:: taille'), 1, 0, 1, 1] + 'telechargement' => [$app->trans('report:: telechargements'), 1, 0, 0, 0], + 'record_id' => [$app->trans('report:: record id'), 1, 1, 1, 0], + 'final' => [$app->trans('phraseanet:: sous definition'), 1, 0, 1, 1], + 'file' => [$app->trans('report:: fichier'), 1, 0, 0, 1], + 'mime' => [$app->trans('report:: type'), 1, 0, 1, 1], + 'size' => [$app->trans('report:: taille'), 1, 0, 1, 1] ], $conf_pref); if ($request->request->get('printcsv') == 'on') { @@ -444,30 +444,30 @@ class Root implements ControllerProviderInterface ); $conf_nav = [ - 'nav' => [_('report:: navigateur'), 0, 1, 0, 0], - 'nb' => [_('report:: nombre'), 0, 0, 0, 0], - 'pourcent' => [_('report:: pourcentage'), 0, 0, 0, 0] + 'nav' => [$app->trans('report:: navigateur'), 0, 1, 0, 0], + 'nb' => [$app->trans('report:: nombre'), 0, 0, 0, 0], + 'pourcent' => [$app->trans('report:: pourcentage'), 0, 0, 0, 0] ]; $conf_combo = [ - 'combo' => [_('report:: navigateurs et plateforme'), 0, 0, 0, 0], - 'nb' => [_('report:: nombre'), 0, 0, 0, 0], - 'pourcent' => [_('report:: pourcentage'), 0, 0, 0, 0] + 'combo' => [$app->trans('report:: navigateurs et plateforme'), 0, 0, 0, 0], + 'nb' => [$app->trans('report:: nombre'), 0, 0, 0, 0], + 'pourcent' => [$app->trans('report:: pourcentage'), 0, 0, 0, 0] ]; $conf_os = [ - 'os' => [_('report:: plateforme'), 0, 0, 0, 0], - 'nb' => [_('report:: nombre'), 0, 0, 0, 0], - 'pourcent' => [_('report:: pourcentage'), 0, 0, 0, 0] + 'os' => [$app->trans('report:: plateforme'), 0, 0, 0, 0], + 'nb' => [$app->trans('report:: nombre'), 0, 0, 0, 0], + 'pourcent' => [$app->trans('report:: pourcentage'), 0, 0, 0, 0] ]; $conf_res = [ - 'res' => [_('report:: resolution'), 0, 0, 0, 0], - 'nb' => [_('report:: nombre'), 0, 0, 0, 0], - 'pourcent' => [_('report:: pourcentage'), 0, 0, 0, 0] + 'res' => [$app->trans('report:: resolution'), 0, 0, 0, 0], + 'nb' => [$app->trans('report:: nombre'), 0, 0, 0, 0], + 'pourcent' => [$app->trans('report:: pourcentage'), 0, 0, 0, 0] ]; $conf_mod = [ - 'appli' => [_('report:: module'), 0, 0, 0, 0], - 'nb' => [_('report:: nombre'), 0, 0, 0, 0], - 'pourcent' => [_('report:: pourcentage'), 0, 0, 0, 0] + 'appli' => [$app->trans('report:: module'), 0, 0, 0, 0], + 'nb' => [$app->trans('report:: nombre'), 0, 0, 0, 0], + 'pourcent' => [$app->trans('report:: pourcentage'), 0, 0, 0, 0] ]; $report = [ @@ -543,7 +543,7 @@ class Root implements ControllerProviderInterface if ($request->request->get('conf') == 'on') { return $app->json(['liste' => $app['twig']->render('report/listColumn.html.twig', [ 'conf' => $base_conf - ]), 'title' => _('configuration')]); + ]), 'title' => $app->trans('configuration')]); } //set order @@ -570,7 +570,7 @@ class Root implements ControllerProviderInterface return $app->json(['diag' => $app['twig']->render('report/colFilter.html.twig', [ 'result' => $report->colFilter($field), 'field' => $field - ]), 'title' => sprintf(_('filtrer les resultats sur la colonne %s'), $field)]); + ]), 'title' => $app->trans('filtrer les resultats sur la colonne %colonne%', array('%colonne%' => $field))]); } if ($field === $value) { @@ -615,7 +615,7 @@ class Root implements ControllerProviderInterface 'is_doc' => false ]), 'display_nav' => false, - 'title' => _(sprintf('Groupement des resultats sur le champ %s', $groupField)) + 'title' => $app->trans('Groupement des resultats sur le champ %name%', array('%name%' => $groupField)) ]); } diff --git a/lib/Alchemy/Phrasea/Controller/Root/Account.php b/lib/Alchemy/Phrasea/Controller/Root/Account.php index 492eeeab5a..d63c7ef4a0 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/Account.php +++ b/lib/Alchemy/Phrasea/Controller/Root/Account.php @@ -97,11 +97,11 @@ class Account implements ControllerProviderInterface if ($app['auth.password-encoder']->isPasswordValid($user->get_password(), $data['oldPassword'], $user->get_nonce())) { $user->set_password($data['password']); - $app->addFlash('success', _('login::notification: Mise a jour du mot de passe avec succes')); + $app->addFlash('success', $app->trans('login::notification: Mise a jour du mot de passe avec succes')); return $app->redirectPath('account'); } else { - $app->addFlash('error', _('Invalid password provided')); + $app->addFlash('error', $app->trans('Invalid password provided')); } } } @@ -123,25 +123,25 @@ class Account implements ControllerProviderInterface { if (null === ($password = $request->request->get('form_password')) || null === ($email = $request->request->get('form_email')) || null === ($emailConfirm = $request->request->get('form_email_confirm'))) { - $app->abort(400, _('Could not perform request, please contact an administrator.')); + $app->abort(400, $app->trans('Could not perform request, please contact an administrator.')); } $user = $app['authentication']->getUser(); if (!$app['auth.password-encoder']->isPasswordValid($user->get_password(), $password, $user->get_nonce())) { - $app->addFlash('error', _('admin::compte-utilisateur:ftp: Le mot de passe est errone')); + $app->addFlash('error', $app->trans('admin::compte-utilisateur:ftp: Le mot de passe est errone')); return $app->redirectPath('account_reset_email'); } if (!\Swift_Validate::email($email)) { - $app->addFlash('error', _('forms::l\'email semble invalide')); + $app->addFlash('error', $app->trans('forms::l\'email semble invalide')); return $app->redirectPath('account_reset_email'); } if ($email !== $emailConfirm) { - $app->addFlash('error', _('forms::les emails ne correspondent pas')); + $app->addFlash('error', $app->trans('forms::les emails ne correspondent pas')); return $app->redirectPath('account_reset_email'); } @@ -153,7 +153,7 @@ class Account implements ControllerProviderInterface try { $receiver = Receiver::fromUser($app['authentication']->getUser()); } catch (InvalidArgumentException $e) { - $app->addFlash('error', _('phraseanet::erreur: echec du serveur de mail')); + $app->addFlash('error', $app->trans('phraseanet::erreur: echec du serveur de mail')); return $app->redirectPath('account_reset_email'); } @@ -164,7 +164,7 @@ class Account implements ControllerProviderInterface $app['notification.deliverer']->deliver($mail); - $app->addFlash('info', _('admin::compte-utilisateur un email de confirmation vient de vous etre envoye. Veuillez suivre les instructions contenue pour continuer')); + $app->addFlash('info', $app->trans('admin::compte-utilisateur un email de confirmation vient de vous etre envoye. Veuillez suivre les instructions contenue pour continuer')); return $app->redirectPath('account'); } @@ -185,11 +185,11 @@ class Account implements ControllerProviderInterface $user->set_email($datas['datas']); $app['tokens']->removeToken($token); - $app->addFlash('success', _('admin::compte-utilisateur: L\'email a correctement ete mis a jour')); + $app->addFlash('success', $app->trans('admin::compte-utilisateur: L\'email a correctement ete mis a jour')); return $app->redirectPath('account'); } catch (\Exception $e) { - $app->addFlash('error', _('admin::compte-utilisateur: erreur lors de la mise a jour')); + $app->addFlash('error', $app->trans('admin::compte-utilisateur: erreur lors de la mise a jour')); return $app->redirectPath('account'); } @@ -210,7 +210,7 @@ class Account implements ControllerProviderInterface public function grantAccess(Application $app, Request $request, $application_id) { if (!$request->isXmlHttpRequest() || !array_key_exists($request->getMimeType('json'), array_flip($request->getAcceptableContentTypes()))) { - $app->abort(400, _('Bad request format, only JSON is allowed')); + $app->abort(400, $app->trans('Bad request format, only JSON is allowed')); } $error = false; @@ -344,7 +344,7 @@ class Account implements ControllerProviderInterface foreach ($demands as $baseId) { try { $register->add_request($app['authentication']->getUser(), \collection::get_from_base_id($app, $baseId)); - $app->addFlash('success', _('login::notification: Vos demandes ont ete prises en compte')); + $app->addFlash('success', $app->trans('login::notification: Vos demandes ont ete prises en compte')); } catch (\Exception $e) { } @@ -403,9 +403,9 @@ class Account implements ControllerProviderInterface $app['phraseanet.appbox']->get_connection()->commit(); $app['EM']->persist($ftpCredential); $app['EM']->flush(); - $app->addFlash('success', _('login::notification: Changements enregistres')); + $app->addFlash('success', $app->trans('login::notification: Changements enregistres')); } catch (\Exception $e) { - $app->addFlash('error', _('forms::erreurs lors de l\'enregistrement des modifications')); + $app->addFlash('error', $app->trans('forms::erreurs lors de l\'enregistrement des modifications')); $app['phraseanet.appbox']->get_connection()->rollBack(); } } diff --git a/lib/Alchemy/Phrasea/Controller/Root/Developers.php b/lib/Alchemy/Phrasea/Controller/Root/Developers.php index f7964aed6c..9815535c9a 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/Developers.php +++ b/lib/Alchemy/Phrasea/Controller/Root/Developers.php @@ -73,7 +73,7 @@ class Developers implements ControllerProviderInterface public function deleteApp(Application $app, Request $request, $id) { if (!$request->isXmlHttpRequest() || !array_key_exists($request->getMimeType('json'), array_flip($request->getAcceptableContentTypes()))) { - $app->abort(400, _('Bad request format, only JSON is allowed')); + $app->abort(400, 'Bad request format, only JSON is allowed'); } $error = false; @@ -99,7 +99,7 @@ class Developers implements ControllerProviderInterface public function renewAppCallback(Application $app, Request $request, $id) { if (!$request->isXmlHttpRequest() || !array_key_exists($request->getMimeType('json'), array_flip($request->getAcceptableContentTypes()))) { - $app->abort(400, _('Bad request format, only JSON is allowed')); + $app->abort(400, 'Bad request format, only JSON is allowed'); } $error = false; @@ -130,7 +130,7 @@ class Developers implements ControllerProviderInterface public function renewAccessToken(Application $app, Request $request, $id) { if (!$request->isXmlHttpRequest() || !array_key_exists($request->getMimeType('json'), array_flip($request->getAcceptableContentTypes()))) { - $app->abort(400, _('Bad request format, only JSON is allowed')); + $app->abort(400, 'Bad request format, only JSON is allowed'); } $error = false; @@ -167,7 +167,7 @@ class Developers implements ControllerProviderInterface public function authorizeGrantpassword(Application $app, Request $request, $id) { if (!$request->isXmlHttpRequest() || !array_key_exists($request->getMimeType('json'), array_flip($request->getAcceptableContentTypes()))) { - $app->abort(400, _('Bad request format, only JSON is allowed')); + $app->abort(400, 'Bad request format, only JSON is allowed'); } $error = false; diff --git a/lib/Alchemy/Phrasea/Controller/Root/Login.php b/lib/Alchemy/Phrasea/Controller/Root/Login.php index 2cfb59c44f..f753f0dfed 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/Login.php +++ b/lib/Alchemy/Phrasea/Controller/Root/Login.php @@ -217,23 +217,23 @@ class Login implements ControllerProviderInterface public function getLanguage(Application $app, Request $request) { $response = $app->json([ - 'validation_blank' => _('Please provide a value.'), - 'validation_choice_min' => _('Please select at least %s choice.'), - 'validation_email' => _('Please provide a valid email address.'), - 'validation_ip' => _('Please provide a valid IP address.'), - 'validation_length_min' => _('Please provide a longer value. It should have %s character or more.'), - 'password_match' => _('Please provide the same passwords.'), - 'email_match' => _('Please provide the same emails.'), - 'accept_tou' => _('Please accept the terms of use to register.'), - 'no_collection_selected' => _('No collection selected'), - 'one_collection_selected' => _('%d collection selected'), - 'collections_selected' => _('%d collections selected'), - 'all_collections' => _('Select all collections'), + 'validation_blank' => $app->trans('Please provide a value.'), + 'validation_choice_min' => $app->trans('Please select at least %s choice.'), + 'validation_email' => $app->trans('Please provide a valid email address.'), + 'validation_ip' => $app->trans('Please provide a valid IP address.'), + 'validation_length_min' => $app->trans('Please provide a longer value. It should have %s character or more.'), + 'password_match' => $app->trans('Please provide the same passwords.'), + 'email_match' => $app->trans('Please provide the same emails.'), + 'accept_tou' => $app->trans('Please accept the terms of use to register.'), + 'no_collection_selected' => $app->trans('No collection selected'), + 'one_collection_selected' => $app->trans('%d collection selected'), + 'collections_selected' => $app->trans('%d collections selected'), + 'all_collections' => $app->trans('Select all collections'), // password strength - 'weak' => _('Weak'), - 'ordinary' => _('Ordinary'), - 'good' => _('Good'), - 'great' => _('Great'), + 'weak' => $app->trans('Weak'), + 'ordinary' => $app->trans('Ordinary'), + 'good' => $app->trans('Good'), + 'great' => $app->trans('Great'), ]); $response->setExpires(new \DateTime('+1 day')); @@ -268,7 +268,7 @@ class Login implements ControllerProviderInterface try { $provider = $this->findProvider($app, $data['provider-id']); } catch (NotFoundHttpException $e) { - $app->addFlash('error', _('You tried to register with an unknown provider')); + $app->addFlash('error', $app->trans('You tried to register with an unknown provider')); return $app->redirectPath('login_register'); } @@ -276,7 +276,7 @@ class Login implements ControllerProviderInterface try { $token = $provider->getToken(); } catch (NotAuthenticatedException $e) { - $app->addFlash('error', _('You tried to register with an unknown provider')); + $app->addFlash('error', $app->trans('You tried to register with an unknown provider')); return $app->redirectPath('login_register'); } @@ -303,7 +303,7 @@ class Login implements ControllerProviderInterface $captcha = $app['recaptcha']->bind($request); if ($app['phraseanet.registry']->get('GV_captchas') && !$captcha->isValid()) { - throw new FormProcessingException(_('Invalid captcha answer.')); + throw new FormProcessingException($app->trans('Invalid captcha answer.')); } require_once $app['root.path'] . '/lib/classes/deprecated/inscript.api.php'; @@ -408,10 +408,10 @@ class Login implements ControllerProviderInterface try { $this->sendAccountUnlockEmail($app, $user); - $app->addFlash('info', _('login::notification: demande de confirmation par mail envoyee')); + $app->addFlash('info', $app->trans('login::notification: demande de confirmation par mail envoyee')); } catch (InvalidArgumentException $e) { // todo, log this failure - $app->addFlash('error', _('Unable to send your account unlock email.')); + $app->addFlash('error', $app->trans('Unable to send your account unlock email.')); } return $app->redirectPath('homepage'); @@ -472,17 +472,17 @@ class Login implements ControllerProviderInterface try { $user = \User_Adapter::getInstance((int) $usrId, $app); } catch (\Exception $e) { - $app->addFlash('error', _('Invalid link.')); + $app->addFlash('error', $app->trans('Invalid link.')); return $app->redirectPath('homepage'); } try { $this->sendAccountUnlockEmail($app, $user); - $app->addFlash('success', _('login::notification: demande de confirmation par mail envoyee')); + $app->addFlash('success', $app->trans('login::notification: demande de confirmation par mail envoyee')); } catch (InvalidArgumentException $e) { // todo, log this failure - $app->addFlash('error', _('Unable to send your account unlock email.')); + $app->addFlash('error', $app->trans('Unable to send your account unlock email.')); } return $app->redirectPath('homepage'); @@ -521,7 +521,7 @@ class Login implements ControllerProviderInterface public function registerConfirm(PhraseaApplication $app, Request $request) { if (null === $code = $request->query->get('code')) { - $app->addFlash('error', _('Invalid unlock link.')); + $app->addFlash('error', $app->trans('Invalid unlock link.')); return $app->redirectPath('homepage'); } @@ -529,7 +529,7 @@ class Login implements ControllerProviderInterface try { $datas = $app['tokens']->helloToken($code); } catch (NotFoundHttpException $e) { - $app->addFlash('error', _('Invalid unlock link.')); + $app->addFlash('error', $app->trans('Invalid unlock link.')); return $app->redirectPath('homepage'); } @@ -537,13 +537,13 @@ class Login implements ControllerProviderInterface try { $user = \User_Adapter::getInstance((int) $datas['usr_id'], $app); } catch (\Exception $e) { - $app->addFlash('error', _('Invalid unlock link.')); + $app->addFlash('error', $app->trans('Invalid unlock link.')); return $app->redirectPath('homepage'); } if (!$user->get_mail_locked()) { - $app->addFlash('info', _('Account is already unlocked, you can login.')); + $app->addFlash('info', $app->trans('Account is already unlocked, you can login.')); return $app->redirectPath('homepage'); } @@ -554,7 +554,7 @@ class Login implements ControllerProviderInterface try { $receiver = Receiver::fromUser($user); } catch (InvalidArgumentException $e) { - $app->addFlash('success', _('Account has been unlocked, you can now login.')); + $app->addFlash('success', $app->trans('Account has been unlocked, you can now login.')); return $app->redirectPath('homepage'); } @@ -565,12 +565,12 @@ class Login implements ControllerProviderInterface $mail = MailSuccessEmailConfirmationRegistered::create($app, $receiver); $app['notification.deliverer']->deliver($mail); - $app->addFlash('success', _('Account has been unlocked, you can now login.')); + $app->addFlash('success', $app->trans('Account has been unlocked, you can now login.')); } else { $mail = MailSuccessEmailConfirmationUnregistered::create($app, $receiver); $app['notification.deliverer']->deliver($mail); - $app->addFlash('info', _('Account has been unlocked, you still have to wait for admin approval.')); + $app->addFlash('info', $app->trans('Account has been unlocked, you still have to wait for admin approval.')); } return $app->redirectPath('homepage'); @@ -604,7 +604,7 @@ class Login implements ControllerProviderInterface $app['tokens']->removeToken($token); - $app->addFlash('success', _('login::notification: Mise a jour du mot de passe avec succes')); + $app->addFlash('success', $app->trans('login::notification: Mise a jour du mot de passe avec succes')); return $app->redirectPath('homepage'); } @@ -640,13 +640,13 @@ class Login implements ControllerProviderInterface try { $user = \User_Adapter::getInstance(\User_Adapter::get_usr_id_from_email($app, $data['email']), $app); } catch (\Exception $e) { - throw new FormProcessingException(_('phraseanet::erreur: Le compte n\'a pas ete trouve')); + throw new FormProcessingException($app->trans('phraseanet::erreur: Le compte n\'a pas ete trouve')); } try { $receiver = Receiver::fromUser($user); } catch (InvalidArgumentException $e) { - throw new FormProcessingException(_('Invalid email address')); + throw new FormProcessingException($app->trans('Invalid email address')); } $token = $app['tokens']->getUrlToken(\random::TYPE_PASSWORD, $user->get_id(), new \DateTime('+1 day')); @@ -662,7 +662,7 @@ class Login implements ControllerProviderInterface $mail->setButtonUrl($url); $app['notification.deliverer']->deliver($mail); - $app->addFlash('info', _('phraseanet:: Un email vient de vous etre envoye')); + $app->addFlash('info', $app->trans('phraseanet:: Un email vient de vous etre envoye')); return $app->redirectPath('login_forgot_password'); } @@ -710,7 +710,7 @@ class Login implements ControllerProviderInterface $app['dispatcher']->dispatch(PhraseaEvents::LOGOUT, new LogoutEvent($app)); $app['authentication']->closeAccount(); - $app->addFlash('info', _('Vous etes maintenant deconnecte. A bientot.')); + $app->addFlash('info', $app->trans('Vous etes maintenant deconnecte. A bientot.')); $response = $app->redirectPath('homepage', [ 'redirect' => $request->query->get("redirect") @@ -737,7 +737,7 @@ class Login implements ControllerProviderInterface try { $app['phraseanet.appbox']->get_connection(); } catch (\Exception $e) { - $app->addFlash('error', _('login::erreur: No available connection - Please contact sys-admin')); + $app->addFlash('error', $app->trans('login::erreur: No available connection - Please contact sys-admin')); } $feeds = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->findBy(['public' => true], ['updatedOn' => 'DESC']); @@ -779,7 +779,7 @@ class Login implements ControllerProviderInterface public function authenticateAsGuest(PhraseaApplication $app, Request $request) { if (!$app->isGuestAllowed()) { - $app->abort(403, _('Phraseanet guest-access is disabled')); + $app->abort(403, $app->trans('Phraseanet guest-access is disabled')); } $context = new Context(Context::CONTEXT_GUEST); @@ -899,7 +899,7 @@ class Login implements ControllerProviderInterface $provider->onCallback($request); $token = $provider->getToken(); } catch (NotAuthenticatedException $e) { - $app['session']->getFlashBag()->add('error', sprintf(_('Unable to authenticate with %s'), $provider->getName())); + $app['session']->getFlashBag()->add('error', $app->trans('Unable to authenticate with %provider_name%', array('%provider_name%' => $provider->getName()))); return $app->redirectPath('homepage'); } @@ -923,7 +923,7 @@ class Login implements ControllerProviderInterface try { $user = $app['authentication.suggestion-finder']->find($token); } catch (NotAuthenticatedException $e) { - $app->addFlash('error', _('Unable to retrieve provider identity')); + $app->addFlash('error', $app->trans('Unable to retrieve provider identity')); return $app->redirectPath('homepage'); } @@ -962,7 +962,7 @@ class Login implements ControllerProviderInterface return $app->redirectPath('login_register_classic', ['providerId' => $providerId]); } - $app->addFlash('error', _('Your identity is not recognized.')); + $app->addFlash('error', $app->trans('Your identity is not recognized.')); return $app->redirectPath('homepage'); } @@ -994,7 +994,7 @@ class Login implements ControllerProviderInterface $form->bind($request); if (!$form->isValid()) { - $app->addFlash('error', _('An unexpected error occured during authentication process, please contact an admin')); + $app->addFlash('error', $app->trans('An unexpected error occured during authentication process, please contact an admin')); throw new AuthenticationException(call_user_func($redirector)); } @@ -1009,18 +1009,18 @@ class Login implements ControllerProviderInterface $usr_id = $app['auth.native']->getUsrId($request->request->get('login'), $request->request->get('password'), $request); } catch (RequireCaptchaException $e) { $app->requireCaptcha(); - $app->addFlash('warning', _('Please fill the captcha')); + $app->addFlash('warning', $app->trans('Please fill the captcha')); throw new AuthenticationException(call_user_func($redirector, $params)); } catch (AccountLockedException $e) { - $app->addFlash('warning', _('login::erreur: Vous n\'avez pas confirme votre email')); + $app->addFlash('warning', $app->trans('login::erreur: Vous n\'avez pas confirme votre email')); $app->addUnlockAccountData($e->getUsrId()); throw new AuthenticationException(call_user_func($redirector, $params)); } if (null === $usr_id) { - $app['session']->getFlashBag()->set('error', _('login::erreur: Erreur d\'authentification')); + $app['session']->getFlashBag()->set('error', $app->trans('login::erreur: Erreur d\'authentification')); throw new AuthenticationException(call_user_func($redirector, $params)); } diff --git a/lib/Alchemy/Phrasea/Controller/Root/Session.php b/lib/Alchemy/Phrasea/Controller/Root/Session.php index 0f4072a47b..59e6d90de2 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/Session.php +++ b/lib/Alchemy/Phrasea/Controller/Root/Session.php @@ -111,7 +111,7 @@ class Session implements ControllerProviderInterface if (in_array($app['session']->get('phraseanet.message'), ['1', null])) { if ($app['conf']->get(['main', 'maintenance'])) { - $ret['message'] .= _('The application is going down for maintenance, please logout.'); + $ret['message'] .= $app->trans('The application is going down for maintenance, please logout.'); } if ($app['phraseanet.registry']->get('GV_message_on')) { diff --git a/lib/Alchemy/Phrasea/Controller/Setup.php b/lib/Alchemy/Phrasea/Controller/Setup.php index c86ea983d3..36de8267c6 100644 --- a/lib/Alchemy/Phrasea/Controller/Setup.php +++ b/lib/Alchemy/Phrasea/Controller/Setup.php @@ -96,7 +96,7 @@ class Setup implements ControllerProviderInterface } if ($request->getScheme() == 'http') { - $warnings[] = _('It is not recommended to install Phraseanet without HTTPS support'); + $warnings[] = $app->trans('It is not recommended to install Phraseanet without HTTPS support'); } return $app['twig']->render('/setup/step2.html.twig', [ @@ -131,7 +131,7 @@ class Setup implements ControllerProviderInterface $abConn = new \connection_pdo('appbox', $hostname, $port, $user_ab, $ab_password, $appbox_name, [], $app['debug']); } catch (\Exception $e) { return $app->redirectPath('install_step2', [ - 'error' => _('Appbox is unreachable'), + 'error' => $app->trans('Appbox is unreachable'), ]); } @@ -141,7 +141,7 @@ class Setup implements ControllerProviderInterface } } catch (\Exception $e) { return $app->redirectPath('install_step2', [ - 'error' => _('Databox is unreachable'), + 'error' => $app->trans('Databox is unreachable'), ]); } @@ -180,7 +180,7 @@ class Setup implements ControllerProviderInterface ]); } catch (\Exception $e) { return $app->redirectPath('install_step2', [ - 'error' => sprintf(_('an error occured : %s'), $e->getMessage()), + 'error' => $app->trans('an error occured : %message%', array('%message%' => $e->getMessage())), ]); } } diff --git a/lib/Alchemy/Phrasea/Controller/Thesaurus/Thesaurus.php b/lib/Alchemy/Phrasea/Controller/Thesaurus/Thesaurus.php index 3c7d6598b2..37f99cbd73 100644 --- a/lib/Alchemy/Phrasea/Controller/Thesaurus/Thesaurus.php +++ b/lib/Alchemy/Phrasea/Controller/Thesaurus/Thesaurus.php @@ -429,13 +429,13 @@ class Thesaurus implements ControllerProviderInterface $dom->formatOutput = true; $root = $dom->appendChild($dom->createElementNS('www.phraseanet.com', 'phraseanet:topics')); - $root->appendChild($dom->createComment(sprintf(_('thesaurus:: fichier genere le %s'), $now))); + $root->appendChild($dom->createComment($app->trans('thesaurus:: fichier genere le %date%', array('%date%' => $now)))); $root->appendChild($dom->createElement('display')) ->appendChild($dom->createElement('defaultview')) ->appendChild($dom->createTextNode($default_display)); - $this->export0Topics($xpathth->query($q)->item(0), $dom, $root, $lng, $request->get("srt"), $request->get("sth"), $request->get("sand"), $opened_display, $obr); + $this->export0Topics($app, $xpathth->query($q)->item(0), $dom, $root, $lng, $request->get("srt"), $request->get("sth"), $request->get("sand"), $opened_display, $obr); if ($request->get("ofm") == 'toscreen') { $lngs[$lng] = str_replace(['&', '<', '>'], ['&', '<', '>'], $dom->saveXML()); @@ -445,9 +445,9 @@ class Thesaurus implements ControllerProviderInterface @rename($app['root.path'] . '/config/topics/' . $fname, $app['root.path'] . '/config/topics/topics_' . $lng . '_BKP_' . $now . '.xml'); if ($dom->save($app['root.path'] . '/config/topics/' . $fname)) { - $lngs[$lng] = \p4string::MakeString(sprintf(_('thesaurus:: fichier genere : %s'), $fname)); + $lngs[$lng] = \p4string::MakeString($app->trans('thesaurus:: fichier genere : %filename%', array('%filename%' => $fname))); } else { - $lngs[$lng] = \p4string::MakeString(_('thesaurus:: erreur lors de l\'enregsitrement du fichier')); + $lngs[$lng] = \p4string::MakeString($app->trans('thesaurus:: erreur lors de l\'enregsitrement du fichier')); } } } @@ -462,13 +462,13 @@ class Thesaurus implements ControllerProviderInterface ]); } - private function export0Topics($znode, \DOMDocument $dom, \DOMNode $root, $lng, $srt, $sth, $sand, $opened_display, $obr) + private function export0Topics(Application $app, $znode, \DOMDocument $dom, \DOMNode $root, $lng, $srt, $sth, $sand, $opened_display, $obr) { $topics = $root->appendChild($dom->createElement('topics')); - $this->doExportTopics($znode, $dom, $topics, '', $lng, $srt, $sth, $sand, $opened_display, $obr, 0); + $this->doExportTopics($app, $znode, $dom, $topics, '', $lng, $srt, $sth, $sand, $opened_display, $obr, 0); } - private function doExportTopics($node, \DOMDocument $dom, \DOMNode $topics, $prevQuery, $lng, $srt, $sth, $sand, $opened_display, $obr, $depth = 0) + private function doExportTopics(Application $app, $node, \DOMDocument $dom, \DOMNode $topics, $prevQuery, $lng, $srt, $sth, $sand, $opened_display, $obr, $depth = 0) { $ntopics = 0; if ($node->nodeType == XML_ELEMENT_NODE) { @@ -506,7 +506,11 @@ class Thesaurus implements ControllerProviderInterface } $t_sort[$i] = $query; // tri sur w - $t_node[$i] = ['label' => $label, 'node' => $n]; + $t_node[$i] = [ + /** @Ignore */ + 'label' => $label, + 'node' => $n + ]; $i ++; } @@ -531,14 +535,14 @@ class Thesaurus implements ControllerProviderInterface } if ($sand && $prevQuery != '') { - $query = $prevQuery . ' ' . _('phraseanet::technique:: et') . ' ' . $query . ''; + $query = $prevQuery . ' ' . $app->trans('phraseanet::technique:: et') . ' ' . $query . ''; } $topic->appendChild($dom->createElement('query'))->appendChild($dom->createTextNode('' . $query . '')); $topics2 = $dom->createElement('topics'); - if ($this->doExportTopics($t_node[$i]['node'], $dom, $topics2, $query, $lng, $srt, $sth, $sand, $opened_display, $obr, $depth + 1) > 0) { + if ($this->doExportTopics($app, $t_node[$i]['node'], $dom, $topics2, $query, $lng, $srt, $sth, $sand, $opened_display, $obr, $depth + 1) > 0) { $topic->appendChild($topics2); } } @@ -604,20 +608,20 @@ class Thesaurus implements ControllerProviderInterface $line = substr($line, 1); } if ($depth > $curdepth + 1) { - $err = sprintf(_("over-indent at line %s"), $iline); + $err = $app->trans("over-indent at line %line%", array('%line%' => $iline)); continue; } $line = trim($line); if ( ! $this->checkEncoding($line, 'UTF-8')) { - $err = sprintf(_("bad encoding at line %s"), $iline); + $err = $app->trans("bad encoding at line %line%", array('%line%' => $iline)); continue; } $line = str_replace($cbad, $cok, ($oldline = $line)); if ($line != $oldline) { - $err = sprintf(_("bad character at line %s"), $iline); + $err = $app->trans("bad character at line %line%", array('%line%' => $iline)); continue; } @@ -1751,7 +1755,7 @@ class Thesaurus implements ControllerProviderInterface $domct->documentElement->setAttribute("nextid", (int) ($id) + 1); $del = $domct->documentElement->appendChild($domct->createElement("te")); $del->setAttribute("id", "C" . $id); - $del->setAttribute("field", _('thesaurus:: corbeille')); + $del->setAttribute("field", $app->trans('thesaurus:: corbeille')); $del->setAttribute("nextid", "0"); $del->setAttribute("delbranch", "1"); @@ -1881,7 +1885,7 @@ class Thesaurus implements ControllerProviderInterface $domct->documentElement->setAttribute("nextid", (int) ($id) + 1); $ct = $domct->documentElement->appendChild($domct->createElement("te")); $ct->setAttribute("id", "C" . $id); - $ct->setAttribute("field", _('thesaurus:: corbeille')); + $ct->setAttribute("field", $app->trans('thesaurus:: corbeille')); $ct->setAttribute("nextid", "0"); $ct->setAttribute("delbranch", "1"); @@ -2978,7 +2982,7 @@ class Thesaurus implements ControllerProviderInterface } // on considere que la source 'deleted' est toujours valide $fields["[deleted]"] = [ - "name" => _('thesaurus:: corbeille'), + "name" => $app->trans('thesaurus:: corbeille'), "tbranch" => null, "cid" => null, "sourceok" => true diff --git a/lib/Alchemy/Phrasea/Controller/Thesaurus/Xmlhttp.php b/lib/Alchemy/Phrasea/Controller/Thesaurus/Xmlhttp.php index f50393917b..572f9c2257 100644 --- a/lib/Alchemy/Phrasea/Controller/Thesaurus/Xmlhttp.php +++ b/lib/Alchemy/Phrasea/Controller/Thesaurus/Xmlhttp.php @@ -486,7 +486,7 @@ class Xmlhttp implements ControllerProviderInterface

- + trans('boutton::supprimer') ?>

@@ -963,6 +963,7 @@ class Xmlhttp implements ControllerProviderInterface } } $tts[$key0 . '_' . $uniq] = [ + /** @Ignore */ 'label' => $label, 'nts' => $nts0, 'n' => $n @@ -1507,10 +1508,10 @@ class Xmlhttp implements ControllerProviderInterface $databox->saveCterms($sbas['domct']); } } - $ret['msg'] = sprintf(_('prod::thesaurusTab:dlg:%d record(s) updated'), $ret['nRecsUpdated']); + $ret['msg'] = $app->trans('prod::thesaurusTab:dlg:%number% record(s) updated', array('%number%' => $ret['nRecsUpdated'])); } else { // too many records to update - $ret['msg'] = sprintf(_('prod::thesaurusTab:dlg:too many (%1$d) records to update (limit=%2$d)'), $ret['nRecsToUpdate'], self::SEARCH_REPLACE_MAXREC); + $ret['msg'] = $app->trans('prod::thesaurusTab:dlg:too many (%number%) records to update (limit=%maximum%)', array('%number%' => $ret['nRecsToUpdate'], '%maximum%' => self::SEARCH_REPLACE_MAXREC)); } return $app->json($ret); @@ -1659,7 +1660,12 @@ class Xmlhttp implements ControllerProviderInterface if (!isset($tts[$key0 . '_' . $uniq])) break; } - $tts[$key0 . '_' . $uniq] = ['label' => $label, 'nts' => $nts0, 'n' => $n]; + $tts[$key0 . '_' . $uniq] = [ + /** @Ignore */ + 'label' => $label, + 'nts' => $nts0, + 'n' => $n + ]; $ntsopened++; } $nts++; diff --git a/lib/Alchemy/Phrasea/Controller/User/Preferences.php b/lib/Alchemy/Phrasea/Controller/User/Preferences.php index fa2b4f86b2..07ff94b9df 100644 --- a/lib/Alchemy/Phrasea/Controller/User/Preferences.php +++ b/lib/Alchemy/Phrasea/Controller/User/Preferences.php @@ -57,12 +57,12 @@ class Preferences implements ControllerProviderInterface $prop = $request->request->get('prop'); $value = $request->request->get('value'); $success = false; - $msg = _('Error while saving preference'); + $msg = $app->trans('Error while saving preference'); if ($prop && $value) { $app['session']->set('phraseanet.' . $prop, $value); $success = true; - $msg = _('Preference saved !'); + $msg = $app->trans('Preference saved !'); } return new JsonResponse(['success' => $success, 'message' => $msg]); @@ -81,7 +81,7 @@ class Preferences implements ControllerProviderInterface $app->abort(400); } - $msg = _('Error while saving preference'); + $msg = $app->trans('Error while saving preference'); $prop = $request->request->get('prop'); $value = $request->request->get('value'); @@ -89,7 +89,7 @@ class Preferences implements ControllerProviderInterface if (null !== $prop && null !== $value) { $app['authentication']->getUser()->setPrefs($prop, $value); $success = true; - $msg = _('Preference saved !'); + $msg = $app->trans('Preference saved !'); } return new JsonResponse(['success' => $success, 'message' => $msg]); diff --git a/lib/Alchemy/Phrasea/Core/CLIProvider/TaskManagerServiceProvider.php b/lib/Alchemy/Phrasea/Core/CLIProvider/TaskManagerServiceProvider.php index 973e683b24..153af6f3db 100644 --- a/lib/Alchemy/Phrasea/Core/CLIProvider/TaskManagerServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/CLIProvider/TaskManagerServiceProvider.php @@ -13,7 +13,6 @@ namespace Alchemy\Phrasea\Core\CLIProvider; use Alchemy\TaskManager\TaskManager; use Alchemy\Phrasea\TaskManager\TaskList; -use Monolog\Logger; use Monolog\Handler\NullHandler; use Silex\Application; use Silex\ServiceProviderInterface; @@ -24,7 +23,7 @@ class TaskManagerServiceProvider implements ServiceProviderInterface public function register(Application $app) { $app['task-manager.logger'] = $app->share(function (Application $app) { - $logger = new Logger('task-manager logger'); + $logger = new $app['monolog.logger.class']('task-manager logger'); $logger->pushHandler(new NullHandler()); return $logger; diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/ApiOauth2ErrorsSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/ApiOauth2ErrorsSubscriber.php index b4a837ad29..cd43a07371 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/ApiOauth2ErrorsSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/ApiOauth2ErrorsSubscriber.php @@ -17,14 +17,17 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Debug\ExceptionHandler; use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; +use Symfony\Component\Translation\TranslatorInterface; class ApiOauth2ErrorsSubscriber implements EventSubscriberInterface { private $handler; + private $translator; - public function __construct(ExceptionHandler $handler) + public function __construct(ExceptionHandler $handler, TranslatorInterface $translator) { $this->handler = $handler; + $this->translator = $translator; } public static function getSubscribedEvents() @@ -45,7 +48,7 @@ class ApiOauth2ErrorsSubscriber implements EventSubscriberInterface $e = $event->getException(); $code = 500; - $msg = _('Whoops, looks like something went wrong.'); + $msg = $this->translator->trans('Whoops, looks like something went wrong.'); $headers = []; if ($e instanceof HttpExceptionInterface) { diff --git a/lib/Alchemy/Phrasea/Core/PhraseaExceptionHandler.php b/lib/Alchemy/Phrasea/Core/PhraseaExceptionHandler.php index 0c1fff318b..60b6a475dd 100644 --- a/lib/Alchemy/Phrasea/Core/PhraseaExceptionHandler.php +++ b/lib/Alchemy/Phrasea/Core/PhraseaExceptionHandler.php @@ -15,9 +15,17 @@ use Symfony\Component\Debug\ExceptionHandler as SymfonyExceptionHandler; use Symfony\Component\Debug\Exception\FlattenException; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\Translation\TranslatorInterface; class PhraseaExceptionHandler extends SymfonyExceptionHandler { + private $translator; + + public function setTranslator(TranslatorInterface $translator) + { + $this->translator = $translator; + } + public function createResponseBasedOnRequest(Request $request, $exception) { return parent::createResponse($exception); @@ -27,22 +35,42 @@ class PhraseaExceptionHandler extends SymfonyExceptionHandler { switch (true) { case 404 === $exception->getStatusCode(): - $title = _('Sorry, the page you are looking for could not be found.'); + if (null !== $this->translator) { + $title = $this->translator->trans('Sorry, the page you are looking for could not be found.'); + } else { + $title = 'Sorry, the page you are looking for could not be found.'; + } break; case 403 === $exception->getStatusCode(): - $title = _('Sorry, you do have access to the page you are looking for.'); + if (null !== $this->translator) { + $title = $this->translator->trans('Sorry, you do have access to the page you are looking for.'); + } else { + $title = 'Sorry, you do have access to the page you are looking for.'; + } break; case 500 === $exception->getStatusCode(): - $title = _('Whoops, looks like something went wrong.'); + if (null !== $this->translator) { + $title = $this->translator->trans('Whoops, looks like something went wrong.'); + } else { + $title = 'Whoops, looks like something went wrong.'; + } break; case 503 === $exception->getStatusCode(): - $title = _('Sorry, site is currently undergoing maintenance, come back soon.'); + if (null !== $this->translator) { + $title = $this->translator->trans('Sorry, site is currently undergoing maintenance, come back soon.'); + } else { + $title = 'Sorry, site is currently undergoing maintenance, come back soon.'; + } break; case isset(Response::$statusTexts[$exception->getStatusCode()]): $title = $exception->getStatusCode() . ' : ' . Response::$statusTexts[$exception->getStatusCode()]; break; default: - $title = 'Whoops, looks like something went wrong.'; + if (null !== $this->translator) { + $title = $this->translator->trans('Whoops, looks like something went wrong.'); + } else { + $title = 'Whoops, looks like something went wrong.'; + } } $content = parent::getContent($exception); diff --git a/lib/Alchemy/Phrasea/Core/Provider/ManipulatorServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/ManipulatorServiceProvider.php index c5043bc33e..5e1a2045ae 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/ManipulatorServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/ManipulatorServiceProvider.php @@ -23,7 +23,7 @@ class ManipulatorServiceProvider implements ServiceProviderInterface public function register(SilexApplication $app) { $app['manipulator.task'] = $app->share(function (SilexApplication $app) { - return new TaskManipulator($app['EM'], $app['task-manager.notifier']); + return new TaskManipulator($app['EM'], $app['task-manager.notifier'], $app['translator']); }); $app['manipulator.user'] = $app->share(function ($app) { diff --git a/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php index 26fcc7fec4..19cce3918d 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php @@ -24,7 +24,6 @@ use Doctrine\ORM\Configuration as ORMConfiguration; use Doctrine\DBAL\Types\Type; use Gedmo\DoctrineExtensions; use Gedmo\Timestampable\TimestampableListener; -use Monolog\Logger; use Monolog\Handler\RotatingFileHandler; use Silex\Application; use Silex\ServiceProviderInterface; @@ -37,7 +36,7 @@ class ORMServiceProvider implements ServiceProviderInterface $app['EM.sql-logger.max-files'] = 5; $app['EM.sql-logger'] = $app->share(function (Application $app) { - $logger = new Logger('doctrine-logger'); + $logger = new $app['monolog.logger.class']('doctrine-logger'); $logger->pushHandler(new RotatingFileHandler($app['EM.sql-logger.file'], $app['EM.sql-logger.max-files'])); return new MonologSQLLogger($logger, 'yaml'); diff --git a/lib/Alchemy/Phrasea/Core/Provider/RegistrationServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/RegistrationServiceProvider.php index b990581dc6..5893f48e54 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/RegistrationServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/RegistrationServiceProvider.php @@ -43,7 +43,7 @@ class RegistrationServiceProvider implements ServiceProviderInterface $app['registration.optional-fields'] = $app->share(function (Application $app) { return [ 'login'=> [ - 'label' => _('admin::compte-utilisateur identifiant'), + 'label' => 'admin::compte-utilisateur identifiant', 'type' => 'text', 'constraints' => [ new Assert\NotBlank(), @@ -51,81 +51,81 @@ class RegistrationServiceProvider implements ServiceProviderInterface ] ], 'gender' => [ - 'label' => _('admin::compte-utilisateur sexe'), + 'label' => 'admin::compte-utilisateur sexe', 'type' => 'choice', 'multiple' => false, 'expanded' => false, 'choices' => [ - '0' => _('admin::compte-utilisateur:sexe: mademoiselle'), - '1' => _('admin::compte-utilisateur:sexe: madame'), - '2' => _('admin::compte-utilisateur:sexe: monsieur'), + '0' => 'admin::compte-utilisateur:sexe: mademoiselle', + '1' => 'admin::compte-utilisateur:sexe: madame', + '2' => 'admin::compte-utilisateur:sexe: monsieur', ] ], 'firstname' => [ - 'label' => _('admin::compte-utilisateur prenom'), + 'label' => 'admin::compte-utilisateur prenom', 'type' => 'text', 'constraints' => [ new Assert\NotBlank(), ] ], 'lastname' => [ - 'label' => _('admin::compte-utilisateur nom'), + 'label' => 'admin::compte-utilisateur nom', 'type' => 'text', 'constraints' => [ new Assert\NotBlank(), ] ], 'address' => [ - 'label' => _('admin::compte-utilisateur adresse'), + 'label' => 'admin::compte-utilisateur adresse', 'type' => 'textarea', 'constraints' => [ new Assert\NotBlank(), ] ], 'zipcode' => [ - 'label' => _('admin::compte-utilisateur code postal'), + 'label' => 'admin::compte-utilisateur code postal', 'type' => 'text', 'constraints' => [ new Assert\NotBlank(), ] ], 'geonameid' => [ - 'label' => _('admin::compte-utilisateur ville'), + 'label' => 'admin::compte-utilisateur ville', 'type' => new \Alchemy\Phrasea\Form\Type\GeonameType(), 'constraints' => [ new Assert\NotBlank(), ] ], 'position' => [ - 'label' => _('admin::compte-utilisateur poste'), + 'label' => 'admin::compte-utilisateur poste', 'type' => 'text', 'constraints' => [ new Assert\NotBlank(), ] ], 'company' => [ - 'label' => _('admin::compte-utilisateur societe'), + 'label' => 'admin::compte-utilisateur societe', 'type' => 'text', 'constraints' => [ new Assert\NotBlank(), ] ], 'job' => [ - 'label' => _('admin::compte-utilisateur activite'), + 'label' => 'admin::compte-utilisateur activite', 'type' => 'text', 'constraints' => [ new Assert\NotBlank(), ] ], 'tel' => [ - 'label' => _('admin::compte-utilisateur tel'), + 'label' => 'admin::compte-utilisateur tel', 'type' => 'text', 'constraints' => [ new Assert\NotBlank(), ] ], 'fax' => [ - 'label' => _('admin::compte-utilisateur fax'), + 'label' => 'admin::compte-utilisateur fax', 'type' => 'text', 'constraints' => [ new Assert\NotBlank(), diff --git a/lib/Alchemy/Phrasea/Core/Provider/TasksServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/TasksServiceProvider.php index 1b187ecb2a..1ef5c9c472 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/TasksServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/TasksServiceProvider.php @@ -45,7 +45,7 @@ class TasksServiceProvider implements ServiceProviderInterface }); $app['task-manager.job-factory'] = $app->share(function (Application $app) { - return new JobFactory($app['dispatcher'],isset($app['task-manager.logger']) ? $app['task-manager.logger'] : $app['logger']); + return new JobFactory($app['dispatcher'],isset($app['task-manager.logger']) ? $app['task-manager.logger'] : $app['logger'], $app['translator']); }); $app['task-manager.status'] = $app->share(function (Application $app) { @@ -66,14 +66,14 @@ class TasksServiceProvider implements ServiceProviderInterface $app['task-manager.available-jobs'] = $app->share(function (Application $app) { return [ - new FtpJob(), - new ArchiveJob(), - new BridgeJob(), - new FtpPullJob(), - new PhraseanetIndexerJob(), - new RecordMoverJob(), - new SubdefsJob(), - new WriteMetadataJob(), + new FtpJob($app['dispatcher'], $app['logger'], $app['translator']), + new ArchiveJob($app['dispatcher'], $app['logger'], $app['translator']), + new BridgeJob($app['dispatcher'], $app['logger'], $app['translator']), + new FtpPullJob($app['dispatcher'], $app['logger'], $app['translator']), + new PhraseanetIndexerJob($app['dispatcher'], $app['logger'], $app['translator']), + new RecordMoverJob($app['dispatcher'], $app['logger'], $app['translator']), + new SubdefsJob($app['dispatcher'], $app['logger'], $app['translator']), + new WriteMetadataJob($app['dispatcher'], $app['logger'], $app['translator']), ]; }); } diff --git a/lib/Alchemy/Phrasea/Feed/RSS/Image.php b/lib/Alchemy/Phrasea/Feed/RSS/Image.php index c7124e02ce..5ee7788b86 100644 --- a/lib/Alchemy/Phrasea/Feed/RSS/Image.php +++ b/lib/Alchemy/Phrasea/Feed/RSS/Image.php @@ -11,7 +11,7 @@ namespace Alchemy\Phrasea\Feed\RSS; -class Image implements FeedRSSImageInterface +class Image implements ImageInterface { /** * diff --git a/lib/Alchemy/Phrasea/Form/Constraint/Geoname.php b/lib/Alchemy/Phrasea/Form/Constraint/Geoname.php index ace2f3529d..814cea64ef 100644 --- a/lib/Alchemy/Phrasea/Form/Constraint/Geoname.php +++ b/lib/Alchemy/Phrasea/Form/Constraint/Geoname.php @@ -11,6 +11,7 @@ namespace Alchemy\Phrasea\Form\Constraint; +use Alchemy\Phrasea\Application; use Symfony\Component\Validator\Constraint; use Alchemy\Geonames\Connector; use Alchemy\Geonames\Exception\TransportException; @@ -18,12 +19,11 @@ use Alchemy\Geonames\Exception\NotFoundException; class Geoname extends Constraint { + public $message = 'This place does not seem to exist.'; private $connector; - private $message; public function __construct(Connector $connector) { - $this->message = _('This place does not seem to exist.'); $this->connector = $connector; parent::__construct(); } @@ -40,4 +40,9 @@ class Geoname extends Constraint return true; } + + public static function create(Application $app) + { + return new static($app['geonames.connector']); + } } diff --git a/lib/Alchemy/Phrasea/Form/Constraint/GeonameValidator.php b/lib/Alchemy/Phrasea/Form/Constraint/GeonameValidator.php index 899f0c66fe..64972784a2 100644 --- a/lib/Alchemy/Phrasea/Form/Constraint/GeonameValidator.php +++ b/lib/Alchemy/Phrasea/Form/Constraint/GeonameValidator.php @@ -22,7 +22,7 @@ class GeonameValidator extends ConstraintValidator public function validate($value, Constraint $constraint) { if (!$constraint->isValid($value)) { - $this->context->addViolation(_('This place does not seem to exist.')); + $this->context->addViolation($constraint->message); } } } diff --git a/lib/Alchemy/Phrasea/Form/Constraint/NewEmail.php b/lib/Alchemy/Phrasea/Form/Constraint/NewEmail.php index e6873eb17f..b4f6cf1088 100644 --- a/lib/Alchemy/Phrasea/Form/Constraint/NewEmail.php +++ b/lib/Alchemy/Phrasea/Form/Constraint/NewEmail.php @@ -16,12 +16,11 @@ use Symfony\Component\Validator\Constraint; class NewEmail extends Constraint { + public $message = 'This email is already bound to an account'; private $app; - private $message; public function __construct(Application $app) { - $this->message = _('This email is already bound to an account'); $this->app = $app; parent::__construct(); } @@ -32,4 +31,9 @@ class NewEmail extends Constraint return $ret; } + + public static function create(Application $app) + { + return new static($app); + } } diff --git a/lib/Alchemy/Phrasea/Form/Constraint/NewEmailValidator.php b/lib/Alchemy/Phrasea/Form/Constraint/NewEmailValidator.php index ed1b1afe79..ac6462d205 100644 --- a/lib/Alchemy/Phrasea/Form/Constraint/NewEmailValidator.php +++ b/lib/Alchemy/Phrasea/Form/Constraint/NewEmailValidator.php @@ -22,7 +22,7 @@ class NewEmailValidator extends ConstraintValidator public function validate($value, Constraint $constraint) { if ($constraint->isAlreadyRegistered($value)) { - $this->context->addViolation(_('There is already an account bound to this email address')); + $this->context->addViolation($constraint->message); } } } diff --git a/lib/Alchemy/Phrasea/Form/Constraint/NewLogin.php b/lib/Alchemy/Phrasea/Form/Constraint/NewLogin.php index 13fde2ba66..9411ab9f33 100644 --- a/lib/Alchemy/Phrasea/Form/Constraint/NewLogin.php +++ b/lib/Alchemy/Phrasea/Form/Constraint/NewLogin.php @@ -16,12 +16,11 @@ use Symfony\Component\Validator\Constraint; class NewLogin extends Constraint { + public $message = 'This login is already registered'; private $app; - private $message; public function __construct(Application $app) { - $this->message = _('This login is already registered'); $this->app = $app; parent::__construct(); } @@ -32,4 +31,9 @@ class NewLogin extends Constraint return $ret; } + + public static function create(Application $app) + { + return new static($app); + } } diff --git a/lib/Alchemy/Phrasea/Form/Constraint/NewLoginValidator.php b/lib/Alchemy/Phrasea/Form/Constraint/NewLoginValidator.php index fe17020d8b..3d876f8261 100644 --- a/lib/Alchemy/Phrasea/Form/Constraint/NewLoginValidator.php +++ b/lib/Alchemy/Phrasea/Form/Constraint/NewLoginValidator.php @@ -22,7 +22,7 @@ class NewLoginValidator extends ConstraintValidator public function validate($value, Constraint $constraint) { if ($constraint->isAlreadyRegistered($value)) { - $this->context->addViolation(_('This login is already registered')); + $this->context->addViolation($constraint->message); } } } diff --git a/lib/Alchemy/Phrasea/Form/Constraint/PasswordToken.php b/lib/Alchemy/Phrasea/Form/Constraint/PasswordToken.php index 9fddddc466..86bb23ace8 100644 --- a/lib/Alchemy/Phrasea/Form/Constraint/PasswordToken.php +++ b/lib/Alchemy/Phrasea/Form/Constraint/PasswordToken.php @@ -17,13 +17,12 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; class PasswordToken extends Constraint { + public $message = 'The token provided is not valid anymore'; private $app; private $random; - private $message; public function __construct(Application $app, \random $random) { - $this->message = _('The token provided is not valid anymore'); $this->app = $app; $this->random = $random; parent::__construct(); @@ -39,4 +38,9 @@ class PasswordToken extends Constraint return \random::TYPE_PASSWORD === $data['type']; } + + public static function create(Application $app) + { + return new static($app, $app['tokens']); + } } diff --git a/lib/Alchemy/Phrasea/Form/Constraint/PasswordTokenValidator.php b/lib/Alchemy/Phrasea/Form/Constraint/PasswordTokenValidator.php index b2fcc0eecb..0f1b743243 100644 --- a/lib/Alchemy/Phrasea/Form/Constraint/PasswordTokenValidator.php +++ b/lib/Alchemy/Phrasea/Form/Constraint/PasswordTokenValidator.php @@ -22,7 +22,7 @@ class PasswordTokenValidator extends ConstraintValidator public function validate($value, Constraint $constraint) { if (!$constraint->isValid($value)) { - $this->context->addViolation('The token provided is not valid anymore'); + $this->context->addViolation($constraint->message); } } } diff --git a/lib/Alchemy/Phrasea/Form/Login/PhraseaAuthenticationForm.php b/lib/Alchemy/Phrasea/Form/Login/PhraseaAuthenticationForm.php index 0d2c7f7268..a5fcb49a37 100644 --- a/lib/Alchemy/Phrasea/Form/Login/PhraseaAuthenticationForm.php +++ b/lib/Alchemy/Phrasea/Form/Login/PhraseaAuthenticationForm.php @@ -20,7 +20,7 @@ class PhraseaAuthenticationForm extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('login', 'text', [ - 'label' => _('Login'), + 'label' => 'Login', 'required' => true, 'disabled' => $options['disabled'], 'constraints' => [ @@ -29,7 +29,7 @@ class PhraseaAuthenticationForm extends AbstractType ]); $builder->add('password', 'password', [ - 'label' => _('Password'), + 'label' => 'Password', 'required' => true, 'disabled' => $options['disabled'], 'constraints' => [ @@ -38,7 +38,7 @@ class PhraseaAuthenticationForm extends AbstractType ]); $builder->add('remember-me', 'checkbox', [ - 'label' => _('Remember me'), + 'label' => 'Remember me', 'mapped' => false, 'required' => false, 'attr' => [ diff --git a/lib/Alchemy/Phrasea/Form/Login/PhraseaForgotPasswordForm.php b/lib/Alchemy/Phrasea/Form/Login/PhraseaForgotPasswordForm.php index 4612548bc3..41d6601d2b 100644 --- a/lib/Alchemy/Phrasea/Form/Login/PhraseaForgotPasswordForm.php +++ b/lib/Alchemy/Phrasea/Form/Login/PhraseaForgotPasswordForm.php @@ -20,7 +20,7 @@ class PhraseaForgotPasswordForm extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('email', 'email', [ - 'label' => _('E-mail'), + 'label' => ('E-mail'), 'required' => true, 'constraints' => [ new Assert\NotBlank(), diff --git a/lib/Alchemy/Phrasea/Form/Login/PhraseaRecoverPasswordForm.php b/lib/Alchemy/Phrasea/Form/Login/PhraseaRecoverPasswordForm.php index a3f78d258f..86f05cc822 100644 --- a/lib/Alchemy/Phrasea/Form/Login/PhraseaRecoverPasswordForm.php +++ b/lib/Alchemy/Phrasea/Form/Login/PhraseaRecoverPasswordForm.php @@ -41,11 +41,11 @@ class PhraseaRecoverPasswordForm extends AbstractType $builder->add('password', 'repeated', [ 'type' => 'password', 'required' => true, - 'invalid_message' => _('Please provide the same passwords.'), + 'invalid_message' => 'Please provide the same passwords.', 'first_name' => 'password', 'second_name' => 'confirm', - 'first_options' => ['label' => _('New password')], - 'second_options' => ['label' => _('New password (confirmation)')], + 'first_options' => ['label' => ('New password')], + 'second_options' => ['label' => ('New password (confirmation)')], 'constraints' => [ new Assert\NotBlank(), new Assert\Length(['min' => 5]), diff --git a/lib/Alchemy/Phrasea/Form/Login/PhraseaRegisterForm.php b/lib/Alchemy/Phrasea/Form/Login/PhraseaRegisterForm.php index 3e7d49972c..5f7d2d9d13 100644 --- a/lib/Alchemy/Phrasea/Form/Login/PhraseaRegisterForm.php +++ b/lib/Alchemy/Phrasea/Form/Login/PhraseaRegisterForm.php @@ -35,7 +35,7 @@ class PhraseaRegisterForm extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('email', 'email', [ - 'label' => _('E-mail'), + 'label' => ('E-mail'), 'required' => true, 'constraints' => [ new Assert\NotBlank(), @@ -47,11 +47,11 @@ class PhraseaRegisterForm extends AbstractType $builder->add('password', 'repeated', [ 'type' => 'password', 'required' => true, - 'invalid_message' => _('Please provide the same passwords.'), + 'invalid_message' => 'Please provide the same passwords.', 'first_name' => 'password', 'second_name' => 'confirm', - 'first_options' => ['label' => _('Password')], - 'second_options' => ['label' => _('Password (confirmation)')], + 'first_options' => ['label' => 'Password'], + 'second_options' => ['label' => 'Password (confirmation)'], 'constraints' => [ new Assert\NotBlank(), new Assert\Length(['min' => 5]), @@ -60,11 +60,11 @@ class PhraseaRegisterForm extends AbstractType if ($this->app->hasTermsOfUse()) { $builder->add('accept-tou', 'checkbox', [ - 'label' => _('Terms of Use'), + 'label' => ('Terms of Use'), 'mapped' => false, "constraints" => [ new Assert\True([ - "message" => _("Please accept the Terms and conditions in order to register.") + "message" => ("Please accept the Terms and conditions in order to register.") ])], ]); } @@ -115,7 +115,7 @@ class PhraseaRegisterForm extends AbstractType 'constraints' => [ new Assert\Choice([ 'choices' => $baseIds, - 'minMessage' => _('You must select at least %s collection.'), + 'minMessage' => ('You must select at least %s collection.'), 'multiple' => true, 'min' => 1, ]), diff --git a/lib/Alchemy/Phrasea/Form/Login/PhraseaRenewPasswordForm.php b/lib/Alchemy/Phrasea/Form/Login/PhraseaRenewPasswordForm.php index 15c287fb4d..49176060c2 100644 --- a/lib/Alchemy/Phrasea/Form/Login/PhraseaRenewPasswordForm.php +++ b/lib/Alchemy/Phrasea/Form/Login/PhraseaRenewPasswordForm.php @@ -23,7 +23,7 @@ class PhraseaRenewPasswordForm extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('oldPassword', 'password', [ - 'label' => _('Current password'), + 'label' => 'Current password', 'required' => true, 'constraints' => [ new Assert\NotBlank() @@ -33,11 +33,11 @@ class PhraseaRenewPasswordForm extends AbstractType $builder->add('password', 'repeated', [ 'type' => 'password', 'required' => true, - 'invalid_message' => _('Please provide the same passwords.'), + 'invalid_message' => 'Please provide the same passwords.', 'first_name' => 'password', 'second_name' => 'confirm', - 'first_options' => ['label' => _('New password')], - 'second_options' => ['label' => _('New password (confirmation)')], + 'first_options' => ['label' => 'New password'], + 'second_options' => ['label' => 'New password (confirmation)'], 'constraints' => [ new Assert\NotBlank(), new Assert\Length(['min' => 5]), diff --git a/lib/Alchemy/Phrasea/Form/TaskForm.php b/lib/Alchemy/Phrasea/Form/TaskForm.php index 546d424e7d..c210bbf0ea 100644 --- a/lib/Alchemy/Phrasea/Form/TaskForm.php +++ b/lib/Alchemy/Phrasea/Form/TaskForm.php @@ -22,14 +22,14 @@ class TaskForm extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('name', 'text', [ - 'label' => _('Task name'), + 'label' => 'Task name', 'required' => true, 'constraints' => [ new Assert\NotBlank(), ], ]); $builder->add('period', 'integer', [ - 'label' => _('Task period (in seconds)'), + 'label' => 'Task period (in seconds)', 'required' => true, 'constraints' => [ new Assert\NotBlank(), @@ -37,7 +37,7 @@ class TaskForm extends AbstractType ], ]); $builder->add('status', 'choice', [ - 'label' => _('The task status'), + 'label' => 'The task status', 'choices' => [ Task::STATUS_STARTED => 'Started', Task::STATUS_STOPPED => 'Stopped', diff --git a/lib/Alchemy/Phrasea/Helper/User/Edit.php b/lib/Alchemy/Phrasea/Helper/User/Edit.php index 04ff4d517c..5c2d6d5b30 100644 --- a/lib/Alchemy/Phrasea/Helper/User/Edit.php +++ b/lib/Alchemy/Phrasea/Helper/User/Edit.php @@ -589,7 +589,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper $parm = $this->unserializedRequestData($this->app['request'], $infos, 'user_infos'); if ($parm['email'] && !\Swift_Validate::email($parm['email'])) { - throw new \Exception_InvalidArgument(_('Email addess is not valid')); + throw new \Exception_InvalidArgument('Email addess is not valid'); } $old_email = $user->get_email(); @@ -617,7 +617,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper } if ($oldReceiver) { - $mailOldAddress = MailSuccessEmailUpdate::create($this->app, $oldReceiver, null, sprintf(_('You will now receive notifications at %s'), $new_email)); + $mailOldAddress = MailSuccessEmailUpdate::create($this->app, $oldReceiver, null, $this->app->trans('You will now receive notifications at %new_email%', array('%new_email%' => $new_email))); $this->app['notification.deliverer']->deliver($mailOldAddress); } @@ -628,7 +628,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper } if ($newReceiver) { - $mailNewAddress = MailSuccessEmailUpdate::create($this->app, $newReceiver, null, sprintf(_('You will no longer receive notifications at %s'), $old_email)); + $mailNewAddress = MailSuccessEmailUpdate::create($this->app, $newReceiver, null, $this->app->trans('You will no longer receive notifications at %old_email%', array('%old_email%' => $old_email))); $this->app['notification.deliverer']->deliver($mailNewAddress); } } diff --git a/lib/Alchemy/Phrasea/Helper/User/Manage.php b/lib/Alchemy/Phrasea/Helper/User/Manage.php index 801269aade..dd3fe6f07f 100644 --- a/lib/Alchemy/Phrasea/Helper/User/Manage.php +++ b/lib/Alchemy/Phrasea/Helper/User/Manage.php @@ -148,7 +148,7 @@ class Manage extends Helper $email = $this->request->get('value'); if ( ! \Swift_Validate::email($email)) { - throw new \Exception_InvalidArgument(_('Invalid mail address')); + throw new \Exception_InvalidArgument('Invalid mail address'); } $conn = $this->app['phraseanet.appbox']->get_connection(); @@ -210,7 +210,7 @@ class Manage extends Helper $name = $this->request->get('value'); if (trim($name) === '') { - throw new \Exception_InvalidArgument(_('Invalid template name')); + throw new \Exception_InvalidArgument('Invalid template name'); } $created_user = \User_Adapter::create($this->app, $name, \random::generatePassword(16), null, false, false); diff --git a/lib/Alchemy/Phrasea/Helper/WorkZone.php b/lib/Alchemy/Phrasea/Helper/WorkZone.php index 29d3b3b5ee..4dc3494b9c 100644 --- a/lib/Alchemy/Phrasea/Helper/WorkZone.php +++ b/lib/Alchemy/Phrasea/Helper/WorkZone.php @@ -45,7 +45,7 @@ class WorkZone extends Helper if (0 === count($baskets)) { $basket = new BasketEntity(); - $basket->setName(_('Default basket')); + $basket->setName($this->app->trans('Default basket')); $basket->setOwner($this->app['authentication']->getUser()); $this->app['EM']->persist($basket); diff --git a/lib/Alchemy/Phrasea/Media/Subdef/Audio.php b/lib/Alchemy/Phrasea/Media/Subdef/Audio.php index 4e53c136c2..b0961d0f29 100644 --- a/lib/Alchemy/Phrasea/Media/Subdef/Audio.php +++ b/lib/Alchemy/Phrasea/Media/Subdef/Audio.php @@ -11,6 +11,8 @@ namespace Alchemy\Phrasea\Media\Subdef; +use Symfony\Component\Translation\TranslatorInterface; + class Audio extends Provider { const OPTION_AUDIOBITRATE = 'audiobitrate'; @@ -18,16 +20,18 @@ class Audio extends Provider const OPTION_ACODEC = 'acodec'; const OPTION_AUDIOSAMPLERATE = 'audiosamplerate'; - public function __construct() + public function __construct(TranslatorInterface $translator) { + $this->translator = $translator; + $AVaudiosamplerate = [ 8000, 11025, 16000, 22050, 32000, 44056, 44100, 47250, 48000, 50000, 50400, 88200, 96000 ]; - $this->registerOption(new OptionType\Range(_('Audio Birate'), self::OPTION_AUDIOBITRATE, 32, 320, 128, 32)); - $this->registerOption(new OptionType\Enum(_('AudioSamplerate'), self::OPTION_AUDIOSAMPLERATE, $AVaudiosamplerate)); - $this->registerOption(new OptionType\Enum(_('Audio Codec'), self::OPTION_ACODEC, ['libmp3lame', 'flac'], 'libmp3lame')); + $this->registerOption(new OptionType\Range($this->translator->trans('Audio Birate'), self::OPTION_AUDIOBITRATE, 32, 320, 128, 32)); + $this->registerOption(new OptionType\Enum($this->translator->trans('AudioSamplerate'), self::OPTION_AUDIOSAMPLERATE, $AVaudiosamplerate)); + $this->registerOption(new OptionType\Enum($this->translator->trans('Audio Codec'), self::OPTION_ACODEC, ['libmp3lame', 'flac'], 'libmp3lame')); } public function getType() @@ -37,7 +41,7 @@ class Audio extends Provider public function getDescription() { - return _('Generates an audio file'); + return $this->translator->trans('Generates an audio file'); } public function getMediaAlchemystSpec() diff --git a/lib/Alchemy/Phrasea/Media/Subdef/FlexPaper.php b/lib/Alchemy/Phrasea/Media/Subdef/FlexPaper.php index 30d8830057..4aa2b82fbe 100644 --- a/lib/Alchemy/Phrasea/Media/Subdef/FlexPaper.php +++ b/lib/Alchemy/Phrasea/Media/Subdef/FlexPaper.php @@ -11,13 +11,15 @@ namespace Alchemy\Phrasea\Media\Subdef; +use Symfony\Component\Translation\TranslatorInterface; + class FlexPaper extends Provider { protected $options = []; - public function __construct() + public function __construct(TranslatorInterface $translator) { - + $this->translator = $translator; } public function getType() @@ -27,7 +29,7 @@ class FlexPaper extends Provider public function getDescription() { - return _('Generates a flexpaper flash file'); + return $this->translator->trans('Generates a flexpaper flash file'); } public function getMediaAlchemystSpec() diff --git a/lib/Alchemy/Phrasea/Media/Subdef/Gif.php b/lib/Alchemy/Phrasea/Media/Subdef/Gif.php index 1c04c0ff13..29c43e897d 100644 --- a/lib/Alchemy/Phrasea/Media/Subdef/Gif.php +++ b/lib/Alchemy/Phrasea/Media/Subdef/Gif.php @@ -11,15 +11,17 @@ namespace Alchemy\Phrasea\Media\Subdef; +use Symfony\Component\Translation\TranslatorInterface; + class Gif extends Image { const OPTION_DELAY = 'delay'; - public function __construct() + public function __construct(TranslatorInterface $translator) { - parent::__construct(); + parent::__construct($translator); - $this->registerOption(new OptionType\Range(_('Delay'), self::OPTION_DELAY, 50, 500, 100)); + $this->registerOption(new OptionType\Range($this->translator->trans('Delay'), self::OPTION_DELAY, 50, 500, 100)); } public function getType() @@ -29,7 +31,7 @@ class Gif extends Image public function getDescription() { - return _('Generates an animated Gif file'); + return $this->translator->trans('Generates an animated Gif file'); } public function getMediaAlchemystSpec() diff --git a/lib/Alchemy/Phrasea/Media/Subdef/Image.php b/lib/Alchemy/Phrasea/Media/Subdef/Image.php index 395f9069a5..929554d5b6 100644 --- a/lib/Alchemy/Phrasea/Media/Subdef/Image.php +++ b/lib/Alchemy/Phrasea/Media/Subdef/Image.php @@ -12,6 +12,7 @@ namespace Alchemy\Phrasea\Media\Subdef; use MediaAlchemyst\Specification\Image as ImageSpecification; +use Symfony\Component\Translation\TranslatorInterface; class Image extends Provider { @@ -22,12 +23,14 @@ class Image extends Provider protected $options = []; - public function __construct() + public function __construct(TranslatorInterface $translator) { - $this->registerOption(new OptionType\Range(_('Dimension'), self::OPTION_SIZE, 20, 3000, 800)); - $this->registerOption(new OptionType\Range(_('Resolution'), self::OPTION_RESOLUTION, 50, 300, 72)); - $this->registerOption(new OptionType\Boolean(_('Remove ICC Profile'), self::OPTION_STRIP, false)); - $this->registerOption(new OptionType\Range(_('Quality'), self::OPTION_QUALITY, 0, 100, 75)); + $this->translator = $translator; + + $this->registerOption(new OptionType\Range($this->translator->trans('Dimension'), self::OPTION_SIZE, 20, 3000, 800)); + $this->registerOption(new OptionType\Range($this->translator->trans('Resolution'), self::OPTION_RESOLUTION, 50, 300, 72)); + $this->registerOption(new OptionType\Boolean($this->translator->trans('Remove ICC Profile'), self::OPTION_STRIP, false)); + $this->registerOption(new OptionType\Range($this->translator->trans('Quality'), self::OPTION_QUALITY, 0, 100, 75)); } public function getType() @@ -37,7 +40,7 @@ class Image extends Provider public function getDescription() { - return _('Generates a Jpeg image'); + return $this->translator->trans('Generates a Jpeg image'); } public function getMediaAlchemystSpec() diff --git a/lib/Alchemy/Phrasea/Media/Subdef/Provider.php b/lib/Alchemy/Phrasea/Media/Subdef/Provider.php index 7051d154aa..291afefaa8 100644 --- a/lib/Alchemy/Phrasea/Media/Subdef/Provider.php +++ b/lib/Alchemy/Phrasea/Media/Subdef/Provider.php @@ -15,6 +15,7 @@ abstract class Provider implements Subdef { protected $options = []; protected $spec; + protected $translator; public function registerOption(OptionType\OptionType $option) { diff --git a/lib/Alchemy/Phrasea/Media/Subdef/Video.php b/lib/Alchemy/Phrasea/Media/Subdef/Video.php index 61ead613cd..73b183c57a 100644 --- a/lib/Alchemy/Phrasea/Media/Subdef/Video.php +++ b/lib/Alchemy/Phrasea/Media/Subdef/Video.php @@ -11,6 +11,8 @@ namespace Alchemy\Phrasea\Media\Subdef; +use Symfony\Component\Translation\TranslatorInterface; + class Video extends Audio { const OPTION_SIZE = 'size'; @@ -21,17 +23,17 @@ class Video extends Audio protected $options = []; - public function __construct() + public function __construct(TranslatorInterface $translator) { - parent::__construct(); + parent::__construct($translator); - $this->registerOption(new OptionType\Range(_('Bitrate'), self::OPTION_BITRATE, 100, 12000, 800)); - $this->registerOption(new OptionType\Range(_('GOP size'), self::OPTION_GOPSIZE, 1, 300, 10)); - $this->registerOption(new OptionType\Range(_('Dimension'), self::OPTION_SIZE, 64, 2000, 600, 16)); - $this->registerOption(new OptionType\Range(_('Frame Rate'), self::OPTION_FRAMERATE, 1, 200, 20)); - $this->registerOption(new OptionType\Enum(_('Video Codec'), self::OPTION_VCODEC, ['libx264', 'libvpx', 'libtheora'], 'libx264')); + $this->registerOption(new OptionType\Range($this->translator->trans('Bitrate'), self::OPTION_BITRATE, 100, 12000, 800)); + $this->registerOption(new OptionType\Range($this->translator->trans('GOP size'), self::OPTION_GOPSIZE, 1, 300, 10)); + $this->registerOption(new OptionType\Range($this->translator->trans('Dimension'), self::OPTION_SIZE, 64, 2000, 600, 16)); + $this->registerOption(new OptionType\Range($this->translator->trans('Frame Rate'), self::OPTION_FRAMERATE, 1, 200, 20)); + $this->registerOption(new OptionType\Enum($this->translator->trans('Video Codec'), self::OPTION_VCODEC, ['libx264', 'libvpx', 'libtheora'], 'libx264')); $this->unregisterOption(self::OPTION_ACODEC); - $this->registerOption(new OptionType\Enum(_('Audio Codec'), self::OPTION_ACODEC, ['libfaac', 'libvo_aacenc', 'libmp3lame', 'libvorbis'], 'libfaac')); + $this->registerOption(new OptionType\Enum($this->translator->trans('Audio Codec'), self::OPTION_ACODEC, ['libfaac', 'libvo_aacenc', 'libmp3lame', 'libvorbis'], 'libfaac')); } public function getType() @@ -41,7 +43,7 @@ class Video extends Audio public function getDescription() { - return _('Generates a video file'); + return $this->translator->trans('Generates a video file'); } public function getMediaAlchemystSpec() diff --git a/lib/Alchemy/Phrasea/Model/Entities/LazaretCheck.php b/lib/Alchemy/Phrasea/Model/Entities/LazaretCheck.php index 2eae1193c6..1274f3c039 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/LazaretCheck.php +++ b/lib/Alchemy/Phrasea/Model/Entities/LazaretCheck.php @@ -12,6 +12,7 @@ namespace Alchemy\Phrasea\Model\Entities; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Translation\TranslatorInterface; /** * @ORM\Table(name="LazaretChecks") @@ -98,14 +99,14 @@ class LazaretCheck * * @return string */ - public function getMessage() + public function getMessage(TranslatorInterface $translator) { $className = $this->getCheckClassname(); if (method_exists($className, "getMessage")) { - return $className::getMessage(); - } else { - return ''; + return $className::getMessage($translator); } + + return ''; } } diff --git a/lib/Alchemy/Phrasea/Model/Entities/User.php b/lib/Alchemy/Phrasea/Model/Entities/User.php index 80329de081..0590b04a0c 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/User.php +++ b/lib/Alchemy/Phrasea/Model/Entities/User.php @@ -16,6 +16,7 @@ use Alchemy\Phrasea\Exception\InvalidArgumentException; use Doctrine\ORM\Mapping as ORM; use Doctrine\Common\Collections\ArrayCollection; use Gedmo\Mapping\Annotation as Gedmo; +use Symfony\Component\Translation\TranslatorInterface; /** * @ORM\Table(name="Users", @@ -961,10 +962,10 @@ class User /** * @return string */ - public function getDisplayName() + public function getDisplayName(TranslatorInterface $translator) { if ($this->isTemplate()) { - return sprintf(_('modele %s'), $this->getLogin()); + return $translator->trans('modele %name%', array('%name%' => $this->getLogin())); } if (trim($this->lastName) !== '' || trim($this->firstName) !== '') { @@ -975,6 +976,6 @@ class User return $this->email; } - return _('Unnamed user'); + return $translator->trans('Unnamed user'); } } diff --git a/lib/Alchemy/Phrasea/Model/Entities/ValidationSession.php b/lib/Alchemy/Phrasea/Model/Entities/ValidationSession.php index 031c1b3689..73a90c7534 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/ValidationSession.php +++ b/lib/Alchemy/Phrasea/Model/Entities/ValidationSession.php @@ -12,6 +12,7 @@ namespace Alchemy\Phrasea\Model\Entities; use Alchemy\Phrasea\Application; +use Alchemy\Phrasea\Model\Entities\ValidationParticipant; use Doctrine\ORM\Mapping as ORM; use Gedmo\Mapping\Annotation as Gedmo; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @@ -263,27 +264,15 @@ class ValidationSession if ($this->isInitiator($user)) { if ($this->isFinished()) { - return sprintf( - _('Vous aviez envoye cette demande a %d utilisateurs') - , (count($this->getParticipants()) - 1) - ); + return $app->trans('Vous aviez envoye cette demande a %n% utilisateurs', array('%n%' => count($this->getParticipants()) - 1)); } else { - return sprintf( - _('Vous avez envoye cette demande a %d utilisateurs') - , (count($this->getParticipants()) - 1) - ); + return $app->trans('Vous avez envoye cette demande a %n% utilisateurs', array('%n%' => count($this->getParticipants()) - 1)); } } else { if ($this->getParticipant($user, $app)->getCanSeeOthers()) { - return sprintf( - _('Processus de validation recu de %s et concernant %d utilisateurs') - , $this->getInitiator($app)->get_display_name() - , (count($this->getParticipants()) - 1)); + return $app->trans('Processus de validation recu de %user% et concernant %n% utilisateurs', array('%user%' => $this->getInitiator($app)->get_display_name(), '%n%' => count($this->getParticipants()) - 1)); } else { - return sprintf( - _('Processus de validation recu de %s') - , $this->getInitiator($app)->get_display_name() - ); + return $app->trans('Processus de validation recu de %user%', array('%user%' => $this->getInitiator($app)->get_display_name())); } } } @@ -291,7 +280,7 @@ class ValidationSession /** * Get a participant * - * @return Alchemy\Phrasea\Model\Entities\ValidationParticipant + * @return ValidationParticipant */ public function getParticipant(\User_Adapter $user, Application $app) { diff --git a/lib/Alchemy/Phrasea/Model/Manipulator/TaskManipulator.php b/lib/Alchemy/Phrasea/Model/Manipulator/TaskManipulator.php index 6e89184348..f05fa80185 100644 --- a/lib/Alchemy/Phrasea/Model/Manipulator/TaskManipulator.php +++ b/lib/Alchemy/Phrasea/Model/Manipulator/TaskManipulator.php @@ -11,10 +11,11 @@ namespace Alchemy\Phrasea\Model\Manipulator; +use Alchemy\Phrasea\Model\Entities\Task; use Alchemy\Phrasea\TaskManager\Job\EmptyCollectionJob; use Alchemy\Phrasea\TaskManager\Notifier; use Doctrine\Common\Persistence\ObjectManager; -use Alchemy\Phrasea\Model\Entities\Task; +use Symfony\Component\Translation\TranslatorInterface; class TaskManipulator implements ManipulatorInterface { @@ -22,11 +23,14 @@ class TaskManipulator implements ManipulatorInterface private $notifier; /** @var Objectmanager */ private $om; + /** @var TranslatorInterface */ + private $translator; - public function __construct(ObjectManager $om, Notifier $notifier) + public function __construct(ObjectManager $om, Notifier $notifier, TranslatorInterface $translator) { $this->om = $om; $this->notifier = $notifier; + $this->translator = $translator; } /** @@ -64,7 +68,7 @@ class TaskManipulator implements ManipulatorInterface */ public function createEmptyCollectionJob(\collection $collection) { - $job = new EmptyCollectionJob(); + $job = new EmptyCollectionJob(null, null, $this->translator); $settings = simplexml_load_string($job->getEditor()->getDefaultSettings()); $settings->bas_id = $collection->get_base_id(); diff --git a/lib/Alchemy/Phrasea/Model/Proxies/__CG__AlchemyPhraseaModelEntitiesLazaretCheck.php b/lib/Alchemy/Phrasea/Model/Proxies/__CG__AlchemyPhraseaModelEntitiesLazaretCheck.php index 1c57fdc723..60ba904937 100644 --- a/lib/Alchemy/Phrasea/Model/Proxies/__CG__AlchemyPhraseaModelEntitiesLazaretCheck.php +++ b/lib/Alchemy/Phrasea/Model/Proxies/__CG__AlchemyPhraseaModelEntitiesLazaretCheck.php @@ -235,12 +235,12 @@ class LazaretCheck extends \Alchemy\Phrasea\Model\Entities\LazaretCheck implemen /** * {@inheritDoc} */ - public function getMessage() + public function getMessage(\Symfony\Component\Translation\TranslatorInterface $translator) { - $this->__initializer__ && $this->__initializer__->__invoke($this, 'getMessage', array()); + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getMessage', array($translator)); - return parent::getMessage(); + return parent::getMessage($translator); } } diff --git a/lib/Alchemy/Phrasea/Model/Proxies/__CG__AlchemyPhraseaModelEntitiesUser.php b/lib/Alchemy/Phrasea/Model/Proxies/__CG__AlchemyPhraseaModelEntitiesUser.php index ce96616d4b..2eaf3a924b 100644 --- a/lib/Alchemy/Phrasea/Model/Proxies/__CG__AlchemyPhraseaModelEntitiesUser.php +++ b/lib/Alchemy/Phrasea/Model/Proxies/__CG__AlchemyPhraseaModelEntitiesUser.php @@ -1082,12 +1082,12 @@ class User extends \Alchemy\Phrasea\Model\Entities\User implements \Doctrine\ORM /** * {@inheritDoc} */ - public function getDisplayName() + public function getDisplayName(\Symfony\Component\Translation\TranslatorInterface $translator) { - $this->__initializer__ && $this->__initializer__->__invoke($this, 'getDisplayName', array()); + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getDisplayName', array($translator)); - return parent::getDisplayName(); + return parent::getDisplayName($translator); } } diff --git a/lib/Alchemy/Phrasea/Model/Repositories/BasketElementRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/BasketElementRepository.php index e5f334e067..75ca5bf017 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/BasketElementRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/BasketElementRepository.php @@ -48,7 +48,7 @@ class BasketElementRepository extends EntityRepository /* @var $element BasketElement */ if (null === $element) { - throw new NotFoundHttpException(_('Element is not found')); + throw new NotFoundHttpException('Element is not found'); } return $element; diff --git a/lib/Alchemy/Phrasea/Model/Repositories/UsrListOwnerRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/UsrListOwnerRepository.php index a62ee92638..6fa4e4047b 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/UsrListOwnerRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/UsrListOwnerRepository.php @@ -39,11 +39,11 @@ class UsrListOwnerRepository extends EntityRepository /* @var $owner UsrListOwner */ if (null === $owner) { - throw new NotFoundHttpException(_('Owner is not found')); + throw new NotFoundHttpException('Owner is not found'); } if ( ! $owner->getList()->getid() != $list->getId()) { - throw new AccessDeniedHttpException(_('Owner and list mismatch')); + throw new AccessDeniedHttpException('Owner and list mismatch'); } return $owner; @@ -74,7 +74,7 @@ class UsrListOwnerRepository extends EntityRepository /* @var $owner UsrListOwner */ if (null === $owner) { - throw new NotFoundHttpException(_('Owner is not found')); + throw new NotFoundHttpException('Owner is not found'); } return $owner; diff --git a/lib/Alchemy/Phrasea/Model/Repositories/UsrListRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/UsrListRepository.php index 7a09f5e365..af65d1ad8f 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/UsrListRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/UsrListRepository.php @@ -60,11 +60,11 @@ class UsrListRepository extends EntityRepository /* @var $list UsrList */ if (null === $list) { - throw new NotFoundHttpException(_('List is not found')); + throw new NotFoundHttpException('List is not found.'); } if ( ! $list->hasAccess($user, $app)) { - throw new AccessDeniedHttpException(_('You have not access to this list')); + throw new AccessDeniedHttpException('You have not access to this list.'); } return $list; diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoBridgeUploadFailed.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoBridgeUploadFailed.php index 56bf52fb67..f3fe932ef2 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoBridgeUploadFailed.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoBridgeUploadFailed.php @@ -45,10 +45,7 @@ class MailInfoBridgeUploadFailed extends AbstractMailWithLink */ public function getSubject() { - return sprintf( - _('Upload failed on %s'), - $this->getPhraseanetTitle() - ); + return $this->app->trans('Upload failed on %application%', array('%application%' => $this->getPhraseanetTitle())); } /** @@ -63,11 +60,7 @@ class MailInfoBridgeUploadFailed extends AbstractMailWithLink throw new LogicException('You must set a reason before calling getMessage'); } - return sprintf( - _('An upload on %s failed, the resaon is : %s'), - $this->adapter, - $this->reason - ); + return $this->app->trans('An upload on %bridge_adapter% failed, the resaon is : %reason%', array('%bridge_adapter%' => $this->adapter, '%reason%' => $this->reason)); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoNewOrder.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoNewOrder.php index cba9c3ca38..07b67a6181 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoNewOrder.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoNewOrder.php @@ -33,10 +33,7 @@ class MailInfoNewOrder extends AbstractMail */ public function getSubject() { - return sprintf( - _('admin::register: Nouvelle commande sur %s'), - $this->getPhraseanetTitle() - ); + return $this->app->trans('admin::register: Nouvelle commande sur %s', array('%application%' => $this->getPhraseanetTitle())); } /** @@ -48,7 +45,7 @@ class MailInfoNewOrder extends AbstractMail throw new LogicException('You must set a user before calling getMessage()'); } - return sprintf(_('%s has ordered documents'),$this->user->get_display_name()); + return $this->app->trans('%user% has ordered documents', array('%user%' => $this->user->get_display_name())); } /** @@ -56,7 +53,7 @@ class MailInfoNewOrder extends AbstractMail */ public function getButtonText() { - return sprintf(_('See order on %s'), $this->getPhraseanetTitle()); + return $this->app->trans('Review order on %website%', array('%website%' => $this->getPhraseanetTitle())); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoNewPublication.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoNewPublication.php index 91c9ebb1e9..74521ccbdf 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoNewPublication.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoNewPublication.php @@ -49,7 +49,7 @@ class MailInfoNewPublication extends AbstractMailWithLink throw new LogicException('You must set an title before calling getMessage'); } - return sprintf(_('Nouvelle publication : %s'), $this->title); + return $this->app->trans('Nouvelle publication : %title%', array('%title%' => $this->title)); } /** @@ -64,7 +64,7 @@ class MailInfoNewPublication extends AbstractMailWithLink throw new LogicException('You must set an title before calling getMessage'); } - return sprintf('%s vient de publier %s', $this->author, $this->title); + return $this->app->trans('%user% vient de publier %title%', array('%user%' => $this->author, '%title%' => $this->title)); } /** @@ -72,7 +72,7 @@ class MailInfoNewPublication extends AbstractMailWithLink */ public function getButtonText() { - return sprintf(_('View on %s'), $this->getPhraseanetTitle()); + return $this->app->trans('View on %title%', array('%title%' => $this->getPhraseanetTitle())); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderCancelled.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderCancelled.php index 8bed0f4aa2..13abc3ee93 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderCancelled.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderCancelled.php @@ -45,7 +45,7 @@ class MailInfoOrderCancelled extends AbstractMail */ public function getSubject() { - return _('push::mail:: Refus d\'elements de votre commande'); + return $this->app->trans('push::mail:: Refus d\'elements de votre commande'); } /** @@ -60,11 +60,10 @@ class MailInfoOrderCancelled extends AbstractMail throw new LogicException('You must set a deliverer before calling getMessage()'); } - return sprintf( - _('%s a refuse %d elements de votre commande'), - $this->deliverer->get_display_name(), - $this->quantity - ); + return $this->app->trans('%user% a refuse %quantity% elements de votre commande', array( + '%user%' => $this->deliverer->get_display_name(), + '%quantity%' => $this->quantity, + )); } /** @@ -72,7 +71,7 @@ class MailInfoOrderCancelled extends AbstractMail */ public function getButtonText() { - return _('See my order'); + return $this->app->trans('See my order'); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderDelivered.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderDelivered.php index c08d758d65..757db48a2e 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderDelivered.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderDelivered.php @@ -50,9 +50,7 @@ class MailInfoOrderDelivered extends AbstractMail throw new LogicException('You must set a basket before calling getSubject'); } - return sprintf( - _('push::mail:: Reception de votre commande %s'), $this->basket->getName() - ); + return $this->app->trans('push::mail:: Reception de votre commande %title%', array('%title%' => $this->basket->getName())); } /** @@ -64,10 +62,7 @@ class MailInfoOrderDelivered extends AbstractMail throw new LogicException('You must set a deliverer before calling getMessage'); } - return sprintf( - _('%s vous a delivre votre commande, consultez la en ligne a l\'adresse suivante'), - $this->deliverer->get_display_name() - ); + return $this->app->trans('%user% vous a delivre votre commande, consultez la en ligne a l\'adresse suivante', array('%user%' => $this->deliverer->get_display_name())); } /** @@ -75,7 +70,7 @@ class MailInfoOrderDelivered extends AbstractMail */ public function getButtonText() { - return _('See my order'); + return $this->app->trans('See my order'); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoPushReceived.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoPushReceived.php index d7e7954062..a77c5a76c0 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoPushReceived.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoPushReceived.php @@ -45,7 +45,7 @@ class MailInfoPushReceived extends AbstractMailWithLink throw new LogicException('You must set a basket before calling getSubject'); } - return sprintf(_('Reception of %s'), $this->basket->getName()); + return $this->app->trans('Reception of %basket_name%', array('%basket_name%' => $this->basket->getName())); } /** @@ -61,7 +61,7 @@ class MailInfoPushReceived extends AbstractMailWithLink } return - sprintf(_('You just received a push containing %s documents from %s'), count($this->basket->getElements()), $this->pusher->get_display_name()) + $this->app->trans('You just received a push containing %quantity% documents from %user%', array('%quantity%' => count($this->basket->getElements()), '%user%' => $this->pusher->get_display_name())) . "\n" . $this->message; } @@ -70,7 +70,7 @@ class MailInfoPushReceived extends AbstractMailWithLink */ public function getButtonText() { - return _('Watch it online'); + return $this->app->trans('Watch it online'); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoRecordQuarantined.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoRecordQuarantined.php index 3f84919f2b..bf3ce63400 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoRecordQuarantined.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoRecordQuarantined.php @@ -18,7 +18,7 @@ class MailInfoRecordQuarantined extends AbstractMail */ public function getSubject() { - return _('A document has been quarantined'); + return $this->app->trans('A document has been quarantined'); } /** @@ -26,7 +26,7 @@ class MailInfoRecordQuarantined extends AbstractMail */ public function getMessage() { - return _('A file has been thrown to the quarantine.'); + return $this->app->trans('A file has been thrown to the quarantine.'); } /** @@ -34,7 +34,7 @@ class MailInfoRecordQuarantined extends AbstractMail */ public function getButtonText() { - return _('Access quarantine'); + return $this->app->trans('Access quarantine'); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoSomebodyAutoregistered.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoSomebodyAutoregistered.php index 2776425cf8..685487460c 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoSomebodyAutoregistered.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoSomebodyAutoregistered.php @@ -18,10 +18,7 @@ class MailInfoSomebodyAutoregistered extends AbstractMailWithLink */ public function getSubject() { - return sprintf( - _('admin::register: Inscription automatique sur %s'), - $this->getPhraseanetTitle() - ); + return $this->app->trans('admin::register: Inscription automatique sur %application%', array('%application%' => $this->getPhraseanetTitle())); } /** @@ -29,7 +26,7 @@ class MailInfoSomebodyAutoregistered extends AbstractMailWithLink */ public function getMessage() { - return _('admin::register: un utilisateur s\'est inscrit')."\n\n".$this->message; + return $this->app->trans('admin::register: un utilisateur s\'est inscrit')."\n\n".$this->message; } /** @@ -37,7 +34,7 @@ class MailInfoSomebodyAutoregistered extends AbstractMailWithLink */ public function getButtonText() { - return _('Update the account'); + return $this->app->trans('Update the account'); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoUserRegistered.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoUserRegistered.php index 0516af5e60..705cc04e46 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoUserRegistered.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoUserRegistered.php @@ -33,9 +33,7 @@ class MailInfoUserRegistered extends AbstractMail */ public function getSubject() { - return sprintf( - _('admin::register: demande d\'inscription sur %s'), $this->getPhraseanetTitle() - ); + return $this->app->trans('admin::register: demande d\'inscription sur %application%', array('%application%' => $this->getPhraseanetTitle())); } /** @@ -47,7 +45,7 @@ class MailInfoUserRegistered extends AbstractMail throw new LogicException('You must set a user before calling getMessage'); } - return _('admin::register: un utilisateur a fait une demande d\'inscription') + return $this->app->trans('admin::register: un utilisateur a fait une demande d\'inscription') . "\n\n" . sprintf('%s %s',$this->registeredUser->get_firstname(), $this->registeredUser->get_lastname()) . "\n\n" . sprintf('%s %s',$this->registeredUser->get_job(), $this->registeredUser->get_company()); } @@ -57,7 +55,7 @@ class MailInfoUserRegistered extends AbstractMail */ public function getButtonText() { - return _('Process the registration'); + return $this->app->trans('Process the registration'); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationDone.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationDone.php index cb84c8bfcc..99236989f9 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationDone.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationDone.php @@ -52,11 +52,10 @@ class MailInfoValidationDone extends AbstractMailWithLink throw new LogicException('You must set an title before calling getSubject'); } - return sprintf( - _('push::mail:: Rapport de validation de %1$s pour %2$s'), - $this->user->get_display_name(), - $this->title - ); + return $this->app->trans('push::mail:: Rapport de validation de %user% pour %title%', array( + '%user%' => $this->user->get_display_name(), + '%title%' => $this->title, + )); } /** @@ -68,10 +67,9 @@ class MailInfoValidationDone extends AbstractMailWithLink throw new LogicException('You must set an user before calling getMessage'); } - return sprintf( - _('%s has just sent its validation report, you can now see it'), - $this->user->get_display_name() - ); + return $this->app->trans('%user% has just sent its validation report, you can now see it', array( + '%user%' => $this->user->get_display_name(), + )); } /** @@ -79,7 +77,7 @@ class MailInfoValidationDone extends AbstractMailWithLink */ public function getButtonText() { - return _('See validation results'); + return $this->app->trans('See validation results'); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationReminder.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationReminder.php index 52a6a7f0ee..e6b7e755e5 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationReminder.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationReminder.php @@ -37,7 +37,7 @@ class MailInfoValidationReminder extends AbstractMailWithLink throw new LogicException('You must set an title before calling getSubject'); } - return sprintf(_("Reminder : validate '%s'"), $this->title); + return $this->app->trans("Reminder : validate '%title%'", array('%title%' => $this->title)); } /** @@ -45,10 +45,9 @@ class MailInfoValidationReminder extends AbstractMailWithLink */ public function getMessage() { - return sprintf( - _('Il ne vous reste plus que %d jours pour terminer votre validation'), - $this->app['phraseanet.registry']->get('GV_validation_reminder') - ); + return $this->app->trans('Il ne vous reste plus que %quantity% jours pour terminer votre validation', array( + '%quantity%' => $this->app['phraseanet.registry']->get('GV_validation_reminder') + )); } /** @@ -56,7 +55,7 @@ class MailInfoValidationReminder extends AbstractMailWithLink */ public function getButtonText() { - return _('Start validation'); + return $this->app->trans('Start validation'); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationRequest.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationRequest.php index 47dde62fe9..d39d204273 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationRequest.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationRequest.php @@ -59,7 +59,7 @@ class MailInfoValidationRequest extends AbstractMailWithLink throw new LogicException('You must set a title before calling getSubject'); } - return sprintf(_("Validation request from %s : '%s'"), $this->user->get_display_name(), $this->title); + return $this->app->trans("Validation request from %user% for '%title%'", array('%user%' => $this->user->get_display_name(), '%title%' => $this->title)); } /** @@ -69,9 +69,9 @@ class MailInfoValidationRequest extends AbstractMailWithLink { if (0 < $this->duration) { if (1 < $this->duration) { - return $this->message . "\n\n" . sprintf(_("You have %d days to validate the selection."), $this->duration); + return $this->message . "\n\n" . $this->app->trans("You have %d days to validate the selection.", array('%quantity%' => $this->duration)); } else { - return $this->message . "\n\n" . _("You have 1 day to validate the selection."); + return $this->message . "\n\n" . $this->app->trans("You have 1 day to validate the selection."); } } @@ -83,7 +83,7 @@ class MailInfoValidationRequest extends AbstractMailWithLink */ public function getButtonText() { - return _('Start validation'); + return $this->app->trans('Start validation'); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailRecordsExport.php b/lib/Alchemy/Phrasea/Notification/Mail/MailRecordsExport.php index 555e39bd13..ecb71527a1 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailRecordsExport.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailRecordsExport.php @@ -18,7 +18,7 @@ class MailRecordsExport extends AbstractMailWithLink */ public function getSubject() { - return _('Vous avez recu des documents'); + return $this->app->trans('Vous avez recu des documents'); } /** @@ -34,7 +34,7 @@ class MailRecordsExport extends AbstractMailWithLink */ public function getButtonText() { - return _('Download'); + return $this->app->trans('Download'); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailRequestEmailConfirmation.php b/lib/Alchemy/Phrasea/Notification/Mail/MailRequestEmailConfirmation.php index af8502037e..c750cc1fb5 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailRequestEmailConfirmation.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailRequestEmailConfirmation.php @@ -18,7 +18,7 @@ class MailRequestEmailConfirmation extends AbstractMailWithLink */ public function getSubject() { - return _('login::register: sujet email : confirmation de votre adresse email'); + return $this->app->trans('login::register: sujet email : confirmation de votre adresse email'); } /** @@ -26,7 +26,7 @@ class MailRequestEmailConfirmation extends AbstractMailWithLink */ public function getMessage() { - return _('login::register: email confirmation email Pour valider votre inscription a la base de donnees, merci de confirmer votre e-mail en suivant le lien ci-dessous.'); + return $this->app->trans('login::register: email confirmation email Pour valider votre inscription a la base de donnees, merci de confirmer votre e-mail en suivant le lien ci-dessous.'); } /** @@ -34,7 +34,7 @@ class MailRequestEmailConfirmation extends AbstractMailWithLink */ public function getButtonText() { - return _('Validate e-mail address'); + return $this->app->trans('Validate e-mail address'); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailRequestEmailUpdate.php b/lib/Alchemy/Phrasea/Notification/Mail/MailRequestEmailUpdate.php index 58a8688878..fb29d15112 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailRequestEmailUpdate.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailRequestEmailUpdate.php @@ -18,7 +18,7 @@ class MailRequestEmailUpdate extends AbstractMailWithLink */ public function getSubject() { - return _('login::register: sujet email : confirmation de votre adresse email'); + return $this->app->trans('login::register: sujet email : confirmation de votre adresse email'); } /** @@ -26,7 +26,7 @@ class MailRequestEmailUpdate extends AbstractMailWithLink */ public function getMessage() { - return _('admin::compte-utilisateur: email changement de mot d\'email Bonjour, nous avons bien recu votre demande de changement d\'adresse e-mail. Pour la confirmer, veuillez suivre le lien qui suit. SI vous recevez ce mail sans l\'avoir sollicite, merci de le detruire et de l\'ignorer.'); + return $this->app->trans('admin::compte-utilisateur: email changement de mot d\'email Bonjour, nous avons bien recu votre demande de changement d\'adresse e-mail. Pour la confirmer, veuillez suivre le lien qui suit. SI vous recevez ce mail sans l\'avoir sollicite, merci de le detruire et de l\'ignorer.'); } /** @@ -34,7 +34,7 @@ class MailRequestEmailUpdate extends AbstractMailWithLink */ public function getButtonText() { - return _('Confirm new email address'); + return $this->app->trans('Confirm new email address'); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailRequestPasswordSetup.php b/lib/Alchemy/Phrasea/Notification/Mail/MailRequestPasswordSetup.php index 96fb212150..61330e6fb0 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailRequestPasswordSetup.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailRequestPasswordSetup.php @@ -33,7 +33,7 @@ class MailRequestPasswordSetup extends AbstractMailWithLink */ public function getSubject() { - return sprintf(_('Your account on %s'), $this->getPhraseanetTitle()); + return $this->app->trans('Your account on %application%', array('%application%' => $this->getPhraseanetTitle())); } /** @@ -45,9 +45,9 @@ class MailRequestPasswordSetup extends AbstractMailWithLink throw new LogicException('You must set a login before calling getMessage'); } - return sprintf(_('Your account with the login %s as been created'), $this->login) + return $this->app->trans('Your account with the login %login% as been created', array('%login%' => $this->login)) . "\n" - . _('You now have to set up your pasword'); + . $this->app->trans('You now have to set up your pasword'); } /** @@ -55,7 +55,7 @@ class MailRequestPasswordSetup extends AbstractMailWithLink */ public function getButtonText() { - return _('Setup my password'); + return $this->app->trans('Setup my password'); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailRequestPasswordUpdate.php b/lib/Alchemy/Phrasea/Notification/Mail/MailRequestPasswordUpdate.php index 38507ff139..39da70438b 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailRequestPasswordUpdate.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailRequestPasswordUpdate.php @@ -33,7 +33,7 @@ class MailRequestPasswordUpdate extends AbstractMailWithLink */ public function getSubject() { - return _('login:: Forgot your password'); + return $this->app->trans('login:: Forgot your password'); } /** @@ -45,9 +45,9 @@ class MailRequestPasswordUpdate extends AbstractMailWithLink throw new LogicException('You must set a login before calling getMessage'); } - return sprintf(_('Password renewal for login "%s" has been requested'), $this->login) + return $this->app->trans('Password renewal for login "%login%" has been requested', array('%login%' => $this->login)) . "\n" - . _('login:: Visitez le lien suivant et suivez les instructions pour continuer, sinon ignorez cet email et il ne se passera rien'); + . $this->app->trans('login:: Visitez le lien suivant et suivez les instructions pour continuer, sinon ignorez cet email et il ne se passera rien'); } /** @@ -55,7 +55,7 @@ class MailRequestPasswordUpdate extends AbstractMailWithLink */ public function getButtonText() { - return _('Renew password'); + return $this->app->trans('Renew password'); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessAccessRequest.php b/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessAccessRequest.php index f6e05e05ef..df7d1c5251 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessAccessRequest.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessAccessRequest.php @@ -18,7 +18,7 @@ class MailSuccessAccessRequest extends AbstractMailWithLink */ public function getSubject() { - return sprintf(_('login::register:email: Votre compte %s'), $this->getPhraseanetTitle()); + return $this->app->trans('login::register:email: Votre compte %application%', array('%application%' => $this->getPhraseanetTitle())); } /** @@ -26,7 +26,7 @@ class MailSuccessAccessRequest extends AbstractMailWithLink */ public function getMessage() { - return _('login::register:email: Voici un compte rendu du traitement de vos demandes d\'acces :') + return $this->app->trans('login::register:email: Voici un compte rendu du traitement de vos demandes d\'acces :') . "\n" . $this->message; } @@ -36,7 +36,7 @@ class MailSuccessAccessRequest extends AbstractMailWithLink */ public function getButtonText() { - return _('Watch my access requests status'); + return $this->app->trans('Watch my access requests status'); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessEmailConfirmationRegistered.php b/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessEmailConfirmationRegistered.php index 2aaf0f4cbf..3185c2c1a3 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessEmailConfirmationRegistered.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessEmailConfirmationRegistered.php @@ -18,7 +18,7 @@ class MailSuccessEmailConfirmationRegistered extends AbstractMailWithLink */ public function getSubject() { - return _('Email successfully confirmed'); + return $this->app->trans('Email successfully confirmed'); } /** @@ -26,7 +26,7 @@ class MailSuccessEmailConfirmationRegistered extends AbstractMailWithLink */ public function getMessage() { - return _('login::register: merci d\'avoir confirme votre adresse email'); + return $this->app->trans('login::register: merci d\'avoir confirme votre adresse email'); } /** @@ -34,7 +34,7 @@ class MailSuccessEmailConfirmationRegistered extends AbstractMailWithLink */ public function getButtonText() { - return sprintf(_('Your access on %s'), $this->app['phraseanet.registry']->get('GV_homeTile')); + return $this->app->trans('Your access on %application%', array('%application%' => $this->app['phraseanet.registry']->get('GV_homeTile'))); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessEmailConfirmationUnregistered.php b/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessEmailConfirmationUnregistered.php index 907aa73595..10fbbffefa 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessEmailConfirmationUnregistered.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessEmailConfirmationUnregistered.php @@ -18,7 +18,7 @@ class MailSuccessEmailConfirmationUnregistered extends AbstractMailWithLink */ public function getSubject() { - return _('Email successfully confirmed'); + return $this->app->trans('Email successfully confirmed'); } /** @@ -26,9 +26,9 @@ class MailSuccessEmailConfirmationUnregistered extends AbstractMailWithLink */ public function getMessage() { - return _('login::register: merci d\'avoir confirme votre adresse email') + return $this->app->trans('login::register: merci d\'avoir confirme votre adresse email') . "\n" - . _("You have to wait for an administrator approval for your access request"); + . $this->app->trans("You have to wait for an administrator approval for your access request"); } /** @@ -36,7 +36,7 @@ class MailSuccessEmailConfirmationUnregistered extends AbstractMailWithLink */ public function getButtonText() { - return _('Watch my access requests status'); + return $this->app->trans('Watch my access requests status'); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessEmailUpdate.php b/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessEmailUpdate.php index f5909b904b..f2602ce2cb 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessEmailUpdate.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessEmailUpdate.php @@ -18,7 +18,7 @@ class MailSuccessEmailUpdate extends AbstractMail */ public function getSubject() { - return sprintf(_('Update of your email address on %s'), $this->getPhraseanetTitle()); + return $this->app->trans('Update of your email address on %application%', array('%application%' => $this->getPhraseanetTitle())); } /** @@ -27,8 +27,8 @@ class MailSuccessEmailUpdate extends AbstractMail public function getMessage() { return sprintf("%s\n%s\n%s", - sprintf(_('Dear %s,'), $this->receiver->getName()), - _('Your contact email address has been updated'), + $this->app->trans('Dear %user%,', array('%user%' => $this->receiver->getName())), + $this->app->trans('Your contact email address has been updated'), $this->message ); } diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessFTPSender.php b/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessFTPSender.php index c50d3d7216..cdb5573df6 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessFTPSender.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessFTPSender.php @@ -37,10 +37,10 @@ class MailSuccessFTPSender extends AbstractMail throw new LogicException('You must set server before calling getSubject'); } - return sprintf( - _('task::ftp:Status about your FTP transfert from %1$s to %2$s'), - $this->getPhraseanetTitle(), $this->server - ); + return $this->app->trans('task::ftp:Status about your FTP transfert from %application% to %server%', array( + '%application%' => $this->getPhraseanetTitle(), + '%server%' => $this->server, + )); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailTest.php b/lib/Alchemy/Phrasea/Notification/Mail/MailTest.php index f7586c7bb8..18b6961e1e 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailTest.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailTest.php @@ -18,7 +18,7 @@ class MailTest extends AbstractMail */ public function getSubject() { - return _('mail:: test d\'envoi d\'email'); + return $this->app->trans('mail:: test d\'envoi d\'email'); } /** @@ -26,10 +26,7 @@ class MailTest extends AbstractMail */ public function getMessage() { - return sprintf("%s\n%s", sprintf( - _('Ce mail est un test d\'envoi de mail depuis %s'), - $this->getPhraseanetTitle() - ), $this->message); + return sprintf("%s\n%s", $this->app->trans('Ce mail est un test d\'envoi de mail depuis %application%', array('%application%' => $this->getPhraseanetTitle())), $this->message); } /** diff --git a/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngine.php b/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngine.php index 48258e3e6d..c1370504ac 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngine.php +++ b/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngine.php @@ -12,13 +12,14 @@ namespace Alchemy\Phrasea\SearchEngine\Phrasea; use Alchemy\Phrasea\Application; +use Alchemy\Phrasea\Model\Entities\FeedEntry; use Alchemy\Phrasea\SearchEngine\SearchEngineInterface; use Alchemy\Phrasea\SearchEngine\SearchEngineOptions; use Alchemy\Phrasea\SearchEngine\SearchEngineResult; use Alchemy\Phrasea\SearchEngine\SearchEngineSuggestion; use Alchemy\Phrasea\Exception\RuntimeException; use Doctrine\Common\Collections\ArrayCollection; -use Alchemy\Phrasea\Model\Entities\FeedEntry; +use Symfony\Component\Translation\TranslatorInterface; class PhraseaEngine implements SearchEngineInterface { @@ -109,7 +110,7 @@ class PhraseaEngine implements SearchEngineInterface { $date_fields = $this->getAvailableDateFields(); - $sort = ['' => _('No sort')]; + $sort = ['' => $this->app->trans('No sort')]; foreach ($date_fields as $field) { $sort[$field] = $field; @@ -134,8 +135,8 @@ class PhraseaEngine implements SearchEngineInterface public function getAvailableOrder() { return [ - 'desc' => _('descendant'), - 'asc' => _('ascendant'), + 'desc' => $this->app->trans('descendant'), + 'asc' => $this->app->trans('ascendant'), ]; } @@ -413,7 +414,7 @@ class PhraseaEngine implements SearchEngineInterface ); $rs = []; - $error = _('Unable to execute query'); + $error = $this->app->trans('Unable to execute query'); if (isset($res['results']) && is_array($res['results'])) { $rs = $res['results']; @@ -469,7 +470,7 @@ class PhraseaEngine implements SearchEngineInterface private function getPropositions() { if ($this->qp && isset($this->qp['main'])) { - $proposals = self::proposalsToHTML($this->qp['main']->proposals); + $proposals = self::proposalsToHTML($this->app['translator'], $this->qp['main']->proposals); if (trim($proposals) !== '') { return "
" . $this->qp['main']->proposals["QRY"] . "
" . $proposals . "
"; @@ -485,7 +486,7 @@ class PhraseaEngine implements SearchEngineInterface * @param array $proposals * @return string */ - private static function proposalsToHTML($proposals) + private static function proposalsToHTML(TranslatorInterface $translator, $proposals) { $html = ''; $b = true; @@ -493,13 +494,13 @@ class PhraseaEngine implements SearchEngineInterface if ((int) (count($proposals["BASES"]) > 1) && count($zbase["TERMS"]) > 0) { $style = $b ? 'style="margin-top:0px;"' : ''; $b = false; - $html .= "

" . sprintf(_('reponses::propositions pour la base %s'), $zbase["NAME"]) . "

"; + $html .= "

" . $translator->trans('reponses::propositions pour la base %name', array('%name%' => $zbase["NAME"])) . "

"; } $t = true; foreach ($zbase["TERMS"] as $path => $props) { $style = $t ? 'style="margin-top:0px;"' : ''; $t = false; - $html .= "

" . sprintf(_('reponses::propositions pour le terme %s'), $props["TERM"]) . "

"; + $html .= "

" . $translator->trans('reponses::propositions pour le terme %terme%', array('%terme%' => $props["TERM"])) . "

"; $html .= $props["HTML"]; } } diff --git a/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngineQueryParser.php b/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngineQueryParser.php index 2be8018fa8..ef703c6183 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngineQueryParser.php +++ b/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngineQueryParser.php @@ -123,7 +123,7 @@ class PhraseaEngineQueryParser $this->errmsg .= sprintf("\\n"); } - $this->errmsg .= _('qparser::la question est vide'); + $this->errmsg .= $this->app->trans('qparser::la question est vide'); return(null); } @@ -895,7 +895,7 @@ class PhraseaEngineQueryParser // un op. arith. doit étre précédé d'un seul nom de champ if ($this->errmsg != "") $this->errmsg .= sprintf("\\n"); - $this->errmsg .= sprintf(_('qparser::Formulation incorrecte, un nom de champs est attendu avant l operateur %s'), $tree["VALUE"]); + $this->errmsg .= $this->app->trans('qparser::Formulation incorrecte, un nom de champs est attendu avant l operateur %token%', array('%token%' => $tree["VALUE"])); return(false); } @@ -903,7 +903,7 @@ class PhraseaEngineQueryParser // un op. arith. doit étre suivi d'une valeur if ($this->errmsg != "") $this->errmsg .= sprintf("\\n"); - $this->errmsg .= sprintf(_('qparser::Formulation incorrecte, une valeur est attendue apres l operateur %s'), $tree["VALUE"]); + $this->errmsg .= $this->app->trans('qparser::Formulation incorrecte, une valeur est attendue apres l operateur %token%', array('%token%' => $tree["VALUE"])); return(false); } @@ -1359,7 +1359,7 @@ class PhraseaEngineQueryParser if ($depth <= 0) { // ')' : retour de récursivité if ($this->errmsg != "") $this->errmsg .= sprintf("\\n"); - $this->errmsg .= _('qparser:: erreur : trop de parentheses fermantes'); + $this->errmsg .= $this->app->trans('qparser:: erreur : trop de parentheses fermantes'); return(null); } @@ -1456,7 +1456,7 @@ class PhraseaEngineQueryParser if (($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK") && $tree["RB"] == null) { if ($this->errmsg != "") $this->errmsg .= sprintf("\\n"); - $this->errmsg .= sprintf(_('qparser::Formulation incorrecte, une valeur est attendu apres %s'), $tree["VALUE"]); + $this->errmsg .= $this->app->trans('qparser::Formulation incorrecte, une valeur est attendu apres %token%', array('%token%' => $tree["VALUE"])); $tree = $tree["LB"]; } @@ -1505,14 +1505,14 @@ class PhraseaEngineQueryParser if (!$tree) { if ($this->errmsg != "") $this->errmsg .= "\\n"; - $this->errmsg .= sprintf(_('qparser::erreur : une question ne peut commencer par %s'), $t["VALUE"]); + $this->errmsg .= $this->app->trans('qparser::erreur : une question ne peut commencer par %token%', array('%token%' => $tree["VALUE"])); return(null); } if (($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK") && $tree["RB"] == null) { if ($this->errmsg != "") $this->errmsg .= "\\n"; - $this->errmsg .= sprintf(_('qparser::Formulation incorrecte, ne peut suivre un operateur : %s'), $t["VALUE"]); + $this->errmsg .= $this->app->trans('qparser::Formulation incorrecte, ne peut suivre un operateur : %token%', array('%token%' => $tree["VALUE"])); return(null); } @@ -1525,7 +1525,7 @@ class PhraseaEngineQueryParser if (!$tree) { if ($this->errmsg != "") $this->errmsg .= "\\n"; - $this->errmsg .= sprintf(_('qparser::erreur : une question ne peut commencer par %s'), $t["VALUE"]); + $this->errmsg .= $this->app->trans('qparser::erreur : une question ne peut commencer par %token%', array('%token%' => $tree["VALUE"])); return(null); } @@ -1533,7 +1533,7 @@ class PhraseaEngineQueryParser if ($this->errmsg != "") $this->errmsg .= "\\n"; - $this->errmsg .= sprintf(_('qparser::Formulation incorrecte, %s ne peut suivre un operateur'), $t["VALUE"]); + $this->errmsg .= $this->app->trans('qparser::Formulation incorrecte, %token% ne peut suivre un operateur', array('%token%' => $t["VALUE"])); return(null); } @@ -1589,7 +1589,7 @@ class PhraseaEngineQueryParser if ($nok < $this->app['phraseanet.registry']->get('GV_min_letters_truncation')) { if ($this->errmsg != "") $this->errmsg .= sprintf("\\n"); - $this->errmsg .= _('qparser:: Formulation incorrecte, necessite plus de caractere : ') . "
" . $this->app['phraseanet.registry']->get('GV_min_letters_truncation'); + $this->errmsg .= $this->app->trans('qparser:: Formulation incorrecte, necessite plus de caractere :') . "
" . $this->app['phraseanet.registry']->get('GV_min_letters_truncation'); return(null); } diff --git a/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/SphinxSearchEngine.php b/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/SphinxSearchEngine.php index e99d80780d..ef694eaefd 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/SphinxSearchEngine.php +++ b/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/SphinxSearchEngine.php @@ -124,9 +124,9 @@ class SphinxSearchEngine implements SearchEngineInterface public function getAvailableSort() { return [ - 'relevance' => _('pertinence'), - 'created_on' => _('date dajout'), - 'random' => _('aleatoire'), + 'relevance' => $this->app->trans('pertinence'), + 'created_on' => $this->app->trans('date dajout'), + 'random' => $this->app->trans('aleatoire'), ]; } @@ -136,8 +136,8 @@ class SphinxSearchEngine implements SearchEngineInterface public function getAvailableOrder() { return [ - 'desc' => _('descendant'), - 'asc' => _('ascendant'), + 'desc' => $this->app->trans('descendant'), + 'asc' => $this->app->trans('ascendant'), ]; } @@ -155,11 +155,11 @@ class SphinxSearchEngine implements SearchEngineInterface public function getStatus() { if (false === $this->sphinx->Status()) { - throw new RuntimeException(_('Sphinx server is offline')); + throw new RuntimeException($this->app->trans('Sphinx server is offline')); } if (false === $this->suggestionClient->Status()) { - throw new RuntimeException(_('Sphinx server is offline')); + throw new RuntimeException($this->app->trans('Sphinx server is offline')); } if (null === $this->rt_conn) { @@ -475,7 +475,7 @@ class SphinxSearchEngine implements SearchEngineInterface if ($res === false) { if ($this->sphinx->IsConnectError() === true) { - $error = _('Sphinx server is offline'); + $error = $this->app->trans('Sphinx server is offline'); } else { $error = $this->sphinx->GetLastError(); } diff --git a/lib/Alchemy/Phrasea/TaskManager/Editor/AbstractEditor.php b/lib/Alchemy/Phrasea/TaskManager/Editor/AbstractEditor.php index 44154c1d50..ffd797e060 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Editor/AbstractEditor.php +++ b/lib/Alchemy/Phrasea/TaskManager/Editor/AbstractEditor.php @@ -16,9 +16,18 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use Symfony\Component\Translation\TranslatorInterface; abstract class AbstractEditor implements EditorInterface { + /** @var TranslatorInterface */ + protected $translator; + + public function __construct(TranslatorInterface $translator) + { + $this->translator = $translator; + } + /** * {@inheritdoc} */ diff --git a/lib/Alchemy/Phrasea/TaskManager/Editor/RecordMoverEditor.php b/lib/Alchemy/Phrasea/TaskManager/Editor/RecordMoverEditor.php index 31cc7443c2..040abd0a3d 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Editor/RecordMoverEditor.php +++ b/lib/Alchemy/Phrasea/TaskManager/Editor/RecordMoverEditor.php @@ -38,7 +38,7 @@ class RecordMoverEditor extends AbstractEditor public function facility(Application $app, Request $request) { $ret = ['tasks' => []]; - $job = new RecordMoverJob(); + $job = new RecordMoverJob(null, null, $this->translator); switch ($request->get('ACT')) { case 'CALCTEST': $sxml = simplexml_load_string($request->get('xml')); diff --git a/lib/Alchemy/Phrasea/TaskManager/Job/AbstractJob.php b/lib/Alchemy/Phrasea/TaskManager/Job/AbstractJob.php index ce9c82289f..d412013b43 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Job/AbstractJob.php +++ b/lib/Alchemy/Phrasea/TaskManager/Job/AbstractJob.php @@ -14,11 +14,21 @@ namespace Alchemy\Phrasea\TaskManager\Job; use Alchemy\TaskManager\AbstractJob as AbstractTMJob; use Alchemy\TaskManager\JobDataInterface; use Alchemy\Phrasea\Exception\InvalidArgumentException; +use Psr\Log\LoggerInterface; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\Translation\TranslatorInterface; abstract class AbstractJob extends AbstractTMJob implements JobInterface { /** @var float */ protected $period = 0.05; + protected $translator; + + public function __construct(EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null, TranslatorInterface $translator) + { + parent::__construct($dispatcher, $logger); + $this->translator = $translator; + } /** * {@inheritdoc} diff --git a/lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php b/lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php index 69f4dc4c8f..cb0d4e4168 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php +++ b/lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php @@ -35,7 +35,7 @@ class ArchiveJob extends AbstractJob */ public function getName() { - return _('task::archive:Archivage'); + return $this->translator->trans('task::archive:Archivage'); } /** @@ -51,7 +51,7 @@ class ArchiveJob extends AbstractJob */ public function getDescription() { - return _("task::archive:Archiving files found into a 'hotfolder'"); + return $this->translator->trans("task::archive:Archiving files found into a 'hotfolder'"); } /** @@ -59,7 +59,7 @@ class ArchiveJob extends AbstractJob */ public function getEditor() { - return new ArchiveEditor(); + return new ArchiveEditor($this->translator); } /** @@ -1356,7 +1356,7 @@ class ArchiveJob extends AbstractJob /** * Return a LazaretSession * - * @return \Entities\LazaretSession + * @return LazaretSession */ protected function getLazaretSession(Application $app) { diff --git a/lib/Alchemy/Phrasea/TaskManager/Job/BridgeJob.php b/lib/Alchemy/Phrasea/TaskManager/Job/BridgeJob.php index 27b3422449..3c2a289a48 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Job/BridgeJob.php +++ b/lib/Alchemy/Phrasea/TaskManager/Job/BridgeJob.php @@ -21,7 +21,7 @@ class BridgeJob extends AbstractJob */ public function getName() { - return _('Bridge uploader'); + return $this->translator->trans('Bridge uploader'); } /** @@ -37,7 +37,7 @@ class BridgeJob extends AbstractJob */ public function getDescription() { - return _('Keep synchronization between bridge and client APIs.'); + return $this->translator->trans('Keep synchronization between bridge and client APIs.'); } /** @@ -45,7 +45,7 @@ class BridgeJob extends AbstractJob */ public function getEditor() { - return new DefaultEditor(); + return new DefaultEditor($this->translator); } /** diff --git a/lib/Alchemy/Phrasea/TaskManager/Job/EmptyCollectionJob.php b/lib/Alchemy/Phrasea/TaskManager/Job/EmptyCollectionJob.php index 0b5b8a387e..ebb8b92723 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Job/EmptyCollectionJob.php +++ b/lib/Alchemy/Phrasea/TaskManager/Job/EmptyCollectionJob.php @@ -22,7 +22,7 @@ class EmptyCollectionJob extends AbstractJob */ public function getName() { - return _("Vidage de collection"); + return $this->translator->trans("Vidage de collection"); } /** @@ -38,7 +38,7 @@ class EmptyCollectionJob extends AbstractJob */ public function getDescription() { - return _("Empty a collection"); + return $this->translator->trans("Empty a collection"); } /** @@ -46,7 +46,7 @@ class EmptyCollectionJob extends AbstractJob */ public function getEditor() { - return new DefaultEditor(); + return new DefaultEditor($this->translator); } /** diff --git a/lib/Alchemy/Phrasea/TaskManager/Job/Factory.php b/lib/Alchemy/Phrasea/TaskManager/Job/Factory.php index 9a3ddc173e..6e597bf1c4 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Job/Factory.php +++ b/lib/Alchemy/Phrasea/TaskManager/Job/Factory.php @@ -14,16 +14,19 @@ namespace Alchemy\Phrasea\TaskManager\Job; use Alchemy\Phrasea\Exception\InvalidArgumentException; use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\Translation\TranslatorInterface; class Factory { private $dispatcher; private $logger; + private $translator; - public function __construct(EventDispatcherInterface $dispatcher, LoggerInterface $logger) + public function __construct(EventDispatcherInterface $dispatcher, LoggerInterface $logger, TranslatorInterface $translator) { $this->dispatcher = $dispatcher; $this->logger = $logger; + $this->translator = $translator; } public function create($fqn) @@ -40,6 +43,6 @@ class Factory throw new InvalidArgumentException(sprintf('Class `%s` does not implement JobInterface.', $fqn)); } - return new $fqn($this->dispatcher, $this->logger); + return new $fqn($this->dispatcher, $this->logger, $this->translator); } } diff --git a/lib/Alchemy/Phrasea/TaskManager/Job/FtpJob.php b/lib/Alchemy/Phrasea/TaskManager/Job/FtpJob.php index 55b029d240..1c3a251570 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Job/FtpJob.php +++ b/lib/Alchemy/Phrasea/TaskManager/Job/FtpJob.php @@ -43,7 +43,7 @@ class FtpJob extends AbstractJob */ public function getDescription() { - return _('Periodically push data to FTP servers.'); + return $this->translator->trans('Periodically push data to FTP servers.'); } /** @@ -51,7 +51,7 @@ class FtpJob extends AbstractJob */ public function getEditor() { - return new FtpEditor(); + return new FtpEditor($this->translator); } /** @@ -101,22 +101,19 @@ class FtpJob extends AbstractJob $ftpLog = $ftp_user_name . "@" . \p4string::addEndSlash($ftp_server) . $export->getDestfolder(); if ($export->getCrash() == 0) { - $line = sprintf( - _('task::ftp:Etat d\'envoi FTP vers le serveur' . - ' "%1$s" avec le compte "%2$s" et pour destination le dossier : "%3$s"') . PHP_EOL - , $ftp_server - , $ftp_user_name - , $export->getDestfolder() - ); + $line = $this->translator->trans('task::ftp:Etat d\'envoi FTP vers le serveur "%server%" avec le compte "%username%" et pour destination le dossier : "%directory%"', array( + '%server%' => $ftp_server, + '%username%' => $ftp_user_name, + '%directory%' => $export->getDestfolder(), + )) . PHP_EOL; $state .= $line; $this->log('debug', $line); } - $state .= $line = sprintf( - _("task::ftp:TENTATIVE no %s, %s") - , $export->getCrash() + 1 - , " (" . date('r') . ")" - ) . PHP_EOL; + $state .= $line = $this->translator->trans("task::ftp:TENTATIVE no %number%, %date%", array( + '%number%' => $export->getCrash() + 1, + '%date%' => " (" . date('r') . ")" + )) . PHP_EOL; $this->log('debug', $line); @@ -245,10 +242,7 @@ class FtpJob extends AbstractJob $app['EM']->flush(); $this->logexport($app, $record, $obj, $ftpLog); } catch (\Exception $e) { - $state .= $line = sprintf(_('task::ftp:File "%1$s" (record %2$s) de la base "%3$s"' . - ' (Export du Document) : Transfert cancelled (le document n\'existe plus)') - , basename($localfile), $record_id - , \phrasea::sbas_labels(\phrasea::sbasFromBas($app, $base_id), $app)) . "\n
"; + $state .= $line = $this->translator->trans('task::ftp:File "%file%" (record %record_id%) de la base "%basename%" (Export du Document) : Transfert cancelled (le document n\'existe plus)', array('%file%' => basename($localfile), '%record_id%' => $record_id, '%basename%' => \phrasea::sbas_labels(\phrasea::sbasFromBas($app, $base_id), $app))) . "\n
"; $this->log('debug', $line); @@ -341,29 +335,35 @@ class FtpJob extends AbstractJob private function send_mails(Application $app, FtpExport $export) { $transferts = []; - $transfert_status = _('task::ftp:Tous les documents ont ete transferes avec succes'); + $transfert_status = $this->translator->trans('task::ftp:Tous les documents ont ete transferes avec succes'); foreach ($export->getElements() as $element) { if (!$element->isError() && $element->isDone()) { $transferts[] = - '
  • ' . sprintf(_('task::ftp:Record %1$s - %2$s de la base (%3$s - %4$s) - %5$s') - , $element->getRecordId(), $element->getFilename() - , \phrasea::sbas_labels(\phrasea::sbasFromBas($app, $element->getBaseId()), $app) - , \phrasea::bas_labels($element->getBaseId(), $app), $element->getSubdef()) . ' : ' . _('Transfert OK') . '
  • '; + '
  • ' . $this->translator->trans('task::ftp:Record %recordid% - %filename% de la base (%databoxname% - %collectionname%) - %subdefname%', array( + '%recordid%' => $element->getRecordId(), + '%filename%' => $element->getFilename(), + '%databoxname%' => \phrasea::sbas_labels(\phrasea::sbasFromBas($app, $element->getBaseId()), $app), + '%collectionname%' => \phrasea::bas_labels($element->getBaseId(), $app), $element->getSubdef(), + '%subdefname%' => $element->getSubdef(), + )) . ' : ' . $this->translator->trans('Transfert OK') . '
  • '; } else { $transferts[] = - '
  • ' . sprintf(_('task::ftp:Record %1$s - %2$s de la base (%3$s - %4$s) - %5$s') - , $element->getRecordId(), $element->getFilename() - , \phrasea::sbas_labels(\phrasea::sbasFromBas($app, $element->getBaseId()), $app), \phrasea::bas_labels($element->getBaseId(), $app) - , $element->getSubdef()) . ' : ' . _('Transfert Annule') . '
  • '; - $transfert_status = _('task::ftp:Certains documents n\'ont pas pu etre tranferes'); + '
  • ' . $this->translator->trans('task::ftp:Record %recordid% - %filename% de la base (%databoxname% - %collectionname%) - %subdefname%', array( + '%recordid%' => $element->getRecordId(), + '%filename%' => $element->getFilename(), + '%databoxname%' => \phrasea::sbas_labels(\phrasea::sbasFromBas($app, $element->getBaseId()), $app), + '%collectionname%' => \phrasea::bas_labels($element->getBaseId(), $app), $element->getSubdef(), + '%subdefname%' => $element->getSubdef(), + )) . ' : ' . $this->translator->trans('Transfert Annule') . '
  • '; + $transfert_status = $this->translator->trans('task::ftp:Certains documents n\'ont pas pu etre tranferes'); } } if ($export->getCrash() >= $export->getNbretry()) { - $connection_status = _('Des difficultes ont ete rencontres a la connection au serveur distant'); + $connection_status = $this->translator->trans('Des difficultes ont ete rencontres a la connection au serveur distant'); } else { - $connection_status = _('La connection vers le serveur distant est OK'); + $connection_status = $this->translator->trans('La connection vers le serveur distant est OK'); } $text_mail_sender = $export->getTextMailSender(); @@ -374,7 +374,7 @@ class FtpJob extends AbstractJob $message = "\n\n----------------------------------------\n\n"; $message = $connection_status . "\n"; $message .= $transfert_status . "\n"; - $message .= _("task::ftp:Details des fichiers") . "\n\n"; + $message .= $this->translator->trans("task::ftp:Details des fichiers") . "\n\n"; $message .= implode("\n", $transferts); diff --git a/lib/Alchemy/Phrasea/TaskManager/Job/FtpPullJob.php b/lib/Alchemy/Phrasea/TaskManager/Job/FtpPullJob.php index 44842edf87..3aba967b30 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Job/FtpPullJob.php +++ b/lib/Alchemy/Phrasea/TaskManager/Job/FtpPullJob.php @@ -21,7 +21,7 @@ class FtpPullJob extends AbstractJob */ public function getName() { - return _("task::ftp:FTP Pull"); + return $this->translator->trans("task::ftp:FTP Pull"); } /** @@ -37,7 +37,7 @@ class FtpPullJob extends AbstractJob */ public function getDescription() { - return _('Periodically fetches an FTP repository content locally'); + return $this->translator->trans('Periodically fetches an FTP repository content locally'); } /** @@ -45,7 +45,7 @@ class FtpPullJob extends AbstractJob */ public function getEditor() { - return new FtpPullEditor(); + return new FtpPullEditor($this->translator); } /** diff --git a/lib/Alchemy/Phrasea/TaskManager/Job/NullJob.php b/lib/Alchemy/Phrasea/TaskManager/Job/NullJob.php index 23a5231b06..294918c7dc 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Job/NullJob.php +++ b/lib/Alchemy/Phrasea/TaskManager/Job/NullJob.php @@ -44,7 +44,7 @@ class NullJob extends AbstractJob */ public function getEditor() { - return new DefaultEditor(); + return new DefaultEditor($this->translator); } /** diff --git a/lib/Alchemy/Phrasea/TaskManager/Job/PhraseanetIndexerJob.php b/lib/Alchemy/Phrasea/TaskManager/Job/PhraseanetIndexerJob.php index 105bab9da2..b252ad4148 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Job/PhraseanetIndexerJob.php +++ b/lib/Alchemy/Phrasea/TaskManager/Job/PhraseanetIndexerJob.php @@ -25,7 +25,7 @@ class PhraseanetIndexerJob extends AbstractJob */ public function getName() { - return _("Phrasea indexation task"); + return $this->translator->trans("Phrasea indexation task"); } /** @@ -41,7 +41,7 @@ class PhraseanetIndexerJob extends AbstractJob */ public function getDescription() { - return _("This task is used to index records for Phrasea engine."); + return $this->translator->trans("This task is used to index records for Phrasea engine."); } /** @@ -49,7 +49,7 @@ class PhraseanetIndexerJob extends AbstractJob */ public function getEditor() { - return new PhraseanetIndexerEditor(); + return new PhraseanetIndexerEditor($this->translator); } /** diff --git a/lib/Alchemy/Phrasea/TaskManager/Job/RecordMoverJob.php b/lib/Alchemy/Phrasea/TaskManager/Job/RecordMoverJob.php index d8b280b638..72bea0ea7b 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Job/RecordMoverJob.php +++ b/lib/Alchemy/Phrasea/TaskManager/Job/RecordMoverJob.php @@ -21,7 +21,7 @@ class RecordMoverJob extends AbstractJob */ public function getName() { - return _("Record Mover"); + return $this->translator->trans("Record Mover"); } /** @@ -37,7 +37,7 @@ class RecordMoverJob extends AbstractJob */ public function getDescription() { - return _("Moves records"); + return $this->translator->trans("Moves records"); } /** @@ -45,7 +45,7 @@ class RecordMoverJob extends AbstractJob */ public function getEditor() { - return new RecordMoverEditor(); + return new RecordMoverEditor($this->translator); } /** diff --git a/lib/Alchemy/Phrasea/TaskManager/Job/SubdefsJob.php b/lib/Alchemy/Phrasea/TaskManager/Job/SubdefsJob.php index 5ae298d45a..02a751e9c8 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Job/SubdefsJob.php +++ b/lib/Alchemy/Phrasea/TaskManager/Job/SubdefsJob.php @@ -21,7 +21,7 @@ class SubdefsJob extends AbstractJob */ public function getName() { - return _('task::subdef:creation des sous definitions'); + return $this->translator->trans('task::subdef:creation des sous definitions'); } /** @@ -37,7 +37,7 @@ class SubdefsJob extends AbstractJob */ public function getDescription() { - return _("task::subdef:creation des sous definitions des documents d'origine"); + return $this->translator->trans("task::subdef:creation des sous definitions des documents d'origine"); } /** @@ -45,7 +45,7 @@ class SubdefsJob extends AbstractJob */ public function getEditor() { - return new SubdefsEditor(); + return new SubdefsEditor($this->translator); } /** diff --git a/lib/Alchemy/Phrasea/TaskManager/Job/WriteMetadataJob.php b/lib/Alchemy/Phrasea/TaskManager/Job/WriteMetadataJob.php index 3eb1a1b153..b321d576a1 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Job/WriteMetadataJob.php +++ b/lib/Alchemy/Phrasea/TaskManager/Job/WriteMetadataJob.php @@ -25,7 +25,7 @@ class WriteMetadataJob extends AbstractJob */ public function getName() { - return _('task::writemeta:ecriture des metadatas'); + return $this->translator->trans('task::writemeta:ecriture des metadatas'); } /** @@ -41,7 +41,7 @@ class WriteMetadataJob extends AbstractJob */ public function getDescription() { - return _("task::writemeta:(re)ecriture des metadatas dans les documents (et subdefs concernees)"); + return $this->translator->trans("task::writemeta:(re)ecriture des metadatas dans les documents (et subdefs concernees)"); } /** @@ -49,7 +49,7 @@ class WriteMetadataJob extends AbstractJob */ public function getEditor() { - return new WriteMetadataEditor(); + return new WriteMetadataEditor($this->translator); } /** diff --git a/lib/Alchemy/Phrasea/Vocabulary/ControlProvider/ControlProviderInterface.php b/lib/Alchemy/Phrasea/Vocabulary/ControlProvider/ControlProviderInterface.php index 9a013324c7..0b4afa48be 100644 --- a/lib/Alchemy/Phrasea/Vocabulary/ControlProvider/ControlProviderInterface.php +++ b/lib/Alchemy/Phrasea/Vocabulary/ControlProvider/ControlProviderInterface.php @@ -25,7 +25,7 @@ interface ControlProviderInterface /** * @return stringa simple i18n word to reprsent this vocabullary */ - public static function getName(); + public function getName(); /** * @return boolean validate an $id in the vocabulary diff --git a/lib/Alchemy/Phrasea/Vocabulary/ControlProvider/UserProvider.php b/lib/Alchemy/Phrasea/Vocabulary/ControlProvider/UserProvider.php index dbe7bc23a8..cc81c0fc00 100644 --- a/lib/Alchemy/Phrasea/Vocabulary/ControlProvider/UserProvider.php +++ b/lib/Alchemy/Phrasea/Vocabulary/ControlProvider/UserProvider.php @@ -37,9 +37,9 @@ class UserProvider implements ControlProviderInterface * * @return type */ - public static function getName() + public function getName() { - return _('Users'); + return $this->app['translator']->trans('Users'); } /** diff --git a/lib/classes/API/OAuth2/Form/DevAppDesktop.php b/lib/classes/API/OAuth2/Form/DevAppDesktop.php index 7c72391da9..e8b6214667 100644 --- a/lib/classes/API/OAuth2/Form/DevAppDesktop.php +++ b/lib/classes/API/OAuth2/Form/DevAppDesktop.php @@ -133,13 +133,12 @@ class API_OAuth2_Form_DevAppDesktop */ public static function loadValidatorMetadata(ClassMetadata $metadata) { - $blank = ['message' => _('Cette valeur ne peut être vide')]; - $url = ['message' => _('Url non valide')]; + // supprimer avant merge : verifier que les contraintes URL et NotBlank sont bien analysées dans le dump - $metadata->addPropertyConstraint('name', new Constraints\NotBlank($blank)); - $metadata->addPropertyConstraint('description', new Constraints\NotBlank($blank)); - $metadata->addPropertyConstraint('urlwebsite', new Constraints\NotBlank($blank)); - $metadata->addPropertyConstraint('urlwebsite', new Constraints\Url($url)); + $metadata->addPropertyConstraint('name', new Constraints\NotBlank()); + $metadata->addPropertyConstraint('description', new Constraints\NotBlank()); + $metadata->addPropertyConstraint('urlwebsite', new Constraints\NotBlank()); + $metadata->addPropertyConstraint('urlwebsite', new Constraints\Url()); return; } diff --git a/lib/classes/API/OAuth2/Form/DevAppInternet.php b/lib/classes/API/OAuth2/Form/DevAppInternet.php index b16fe9aa0c..850eabe5ef 100644 --- a/lib/classes/API/OAuth2/Form/DevAppInternet.php +++ b/lib/classes/API/OAuth2/Form/DevAppInternet.php @@ -136,15 +136,12 @@ class API_OAuth2_Form_DevAppInternet */ public static function loadValidatorMetadata(ClassMetadata $metadata) { - $blank = ['message' => _('Cette valeur ne peut être vide')]; - $url = ['message' => _('Url non valide')]; - - $metadata->addPropertyConstraint('name', new Constraints\NotBlank($blank)); - $metadata->addPropertyConstraint('description', new Constraints\NotBlank($blank)); - $metadata->addPropertyConstraint('urlwebsite', new Constraints\NotBlank($blank)); - $metadata->addPropertyConstraint('urlwebsite', new Constraints\Url($url)); - $metadata->addPropertyConstraint('urlcallback', new Constraints\NotBlank($blank)); - $metadata->addPropertyConstraint('urlcallback', new Constraints\Url($url)); + $metadata->addPropertyConstraint('name', new Constraints\NotBlank()); + $metadata->addPropertyConstraint('description', new Constraints\NotBlank()); + $metadata->addPropertyConstraint('urlwebsite', new Constraints\NotBlank()); + $metadata->addPropertyConstraint('urlwebsite', new Constraints\Url()); + $metadata->addPropertyConstraint('urlcallback', new Constraints\NotBlank()); + $metadata->addPropertyConstraint('urlcallback', new Constraints\Url()); return; } diff --git a/lib/classes/API/V1/adapter.php b/lib/classes/API/V1/adapter.php index 8ba05567cc..09825d148d 100644 --- a/lib/classes/API/V1/adapter.php +++ b/lib/classes/API/V1/adapter.php @@ -675,12 +675,12 @@ class API_V1_adapter extends API_V1_Abstract $reasons = $output = null; - $callback = function ($element, $visa, $code) use (&$reasons, &$output) { + $callback = function ($element, $visa, $code) use ($app, &$reasons, &$output) { if (!$visa->isValid()) { $reasons = []; foreach ($visa->getResponses() as $response) { - $reasons[] = $response->getMessage(); + $reasons[] = $response->getMessage($app['translator']); } } @@ -788,7 +788,7 @@ class API_V1_adapter extends API_V1_Abstract if ($file->getChecks()) { foreach ($file->getChecks() as $checker) { - $checks[] = $checker->getMessage(); + $checks[] = $checker->getMessage($this->app['translator']); } } @@ -1096,7 +1096,7 @@ class API_V1_adapter extends API_V1_Abstract $record->set_metadatas($metadatas); $result->set_datas(["record_metadatas" => $this->list_record_caption($record->get_caption())]); } catch (Exception $e) { - $result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, _('An error occured')); + $result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, $this->app->trans('An error occured')); } return $result; @@ -1142,7 +1142,7 @@ class API_V1_adapter extends API_V1_Abstract ] ); } catch (Exception $e) { - $result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, _('An error occured')); + $result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, $this->app->trans('An error occured')); } return $result; @@ -1190,9 +1190,9 @@ class API_V1_adapter extends API_V1_Abstract $record = $databox->get_record($record_id); $result->set_datas(['record' => $this->list_record($record)]); } catch (NotFoundHttpException $e) { - $result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, _('Record Not Found')); + $result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, $this->app->trans('Record Not Found')); } catch (Exception $e) { - $result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, _('An error occured')); + $result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, $this->app->trans('An error occured')); } return $result; @@ -1214,9 +1214,9 @@ class API_V1_adapter extends API_V1_Abstract $story = $databox->get_record($story_id); $result->set_datas(['story' => $this->list_story($story)]); } catch (NotFoundHttpException $e) { - $result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, _('Story Not Found')); + $result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, $this->app->trans('Story Not Found')); } catch (Exception $e) { - $result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, _('An error occured')); + $result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, $this->app->trans('An error occured')); } return $result; @@ -1703,6 +1703,7 @@ class API_V1_adapter extends API_V1_Abstract 'created_on' => $permalink->get_created_on()->format(DATE_ATOM), 'id' => $permalink->get_id(), 'is_activated' => $permalink->get_is_activated(), + /** @Ignore */ 'label' => $permalink->get_label(), 'updated_on' => $permalink->get_last_modified()->format(DATE_ATOM), 'page_url' => $permalink->get_page(), diff --git a/lib/classes/Bridge/Api.php b/lib/classes/Bridge/Api.php index 3856492ddc..ee9a8f14fa 100644 --- a/lib/classes/Bridge/Api.php +++ b/lib/classes/Bridge/Api.php @@ -489,7 +489,7 @@ class Bridge_Api $auth_classname = 'Bridge_Api_Auth_' . $classname::AUTH_TYPE; $auth = new $auth_classname; - return new $classname($app['url_generator'], $app['phraseanet.registry'], $auth); + return new $classname($app['url_generator'], $app['phraseanet.registry'], $auth, $app['translator']); } public static function get_by_api_name(Application $app, $name) diff --git a/lib/classes/Bridge/Api/Abstract.php b/lib/classes/Bridge/Api/Abstract.php index 19436985a6..8771e2c272 100644 --- a/lib/classes/Bridge/Api/Abstract.php +++ b/lib/classes/Bridge/Api/Abstract.php @@ -10,6 +10,7 @@ */ use Symfony\Component\Routing\Generator\UrlGenerator; +use Symfony\Component\Translation\TranslatorInterface; abstract class Bridge_Api_Abstract { @@ -25,6 +26,7 @@ abstract class Bridge_Api_Abstract */ protected $locale = 'en_US'; protected $generator; + protected $translator; /** * @@ -32,8 +34,9 @@ abstract class Bridge_Api_Abstract * @param Bridge_Api_Auth_Interface $auth * @return Bridge_Api_Abstract */ - public function __construct(UrlGenerator $generator, registryInterface $registry, Bridge_Api_Auth_Interface $auth) + public function __construct(UrlGenerator $generator, registryInterface $registry, Bridge_Api_Auth_Interface $auth, TranslatorInterface $translator) { + $this->translator = $translator; $this->generator = $generator; $this->registry = $registry; $this->_auth = $auth; diff --git a/lib/classes/Bridge/Api/Dailymotion.php b/lib/classes/Bridge/Api/Dailymotion.php index fa30d989e8..679480144c 100644 --- a/lib/classes/Bridge/Api/Dailymotion.php +++ b/lib/classes/Bridge/Api/Dailymotion.php @@ -177,7 +177,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I */ public function get_element_types() { - return [self::ELEMENT_TYPE_VIDEO => _('Videos')]; + return [self::ELEMENT_TYPE_VIDEO => $this->translator->trans('Videos')]; } /** @@ -186,7 +186,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I */ public function get_container_types() { - return [self::CONTAINER_TYPE_PLAYLIST => _('Playlists')]; + return [self::CONTAINER_TYPE_PLAYLIST => $this->translator->trans('Playlists')]; } public function get_oauth_token() @@ -528,22 +528,22 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I { switch ($connector_status) { case self::UPLOAD_STATE_DELETED: - return _('La video a ete supprimee'); + return $this->translator->trans('La video a ete supprimee'); break; case self::UPLOAD_STATE_REJECTED: - return _('La video a ete rejetee'); + return $this->translator->trans('La video a ete rejetee'); break; case self::UPLOAD_STATE_ENCODING_ERROR: - return _('Erreur d\'encodage'); + return $this->translator->trans('Erreur d\'encodage'); break; case self::UPLOAD_STATE_PROCESSING: - return _('En cours d\'encodage'); + return $this->translator->trans('En cours d\'encodage'); break; default: return ''; break; case self::UPLOAD_STATE_DONE: - return _('OK'); + return $this->translator->trans('OK'); break; } } @@ -807,12 +807,12 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I if ( ! isset($datas[$name]) || trim($datas[$name]) === '') { if ($required) - $errors[$name . '_' . $key] = _("Ce champ est obligatoire"); + $errors[$name . '_' . $key] = $this->translator->trans("Ce champ est obligatoire"); } else { if ($length != 0 && mb_strlen($datas[$name]) > $length) - $errors[$name . '_' . $key] = sprintf(_("Ce champ est trop long %s caracteres max"), $length); + $errors[$name . '_' . $key] = $this->translator->trans("Ce champ est trop long %length% caracteres max", array('%length%' => $length)); if ($length_min != 0 && mb_strlen($datas[$name]) < $length_min) - $errors[$name . '_' . $key] = sprintf(_("Ce champ est trop court %s caracteres min"), $length_min); + $errors[$name . '_' . $key] = $this->translator->trans("Ce champ est trop court %length% caracteres min", array('%length%' => $length_min)); } }; @@ -832,12 +832,12 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I if ( ! isset($datas[$name]) || trim($datas[$name]) === '') { if ($required) - $errors[$name] = _("Ce champ est obligatoire"); + $errors[$name] = $this->translator->trans("Ce champ est obligatoire"); } else { if ($length != 0 && mb_strlen($datas[$name]) > $length) - $errors[$name] = sprintf(_("Ce champ est trop long %s caracteres max"), $length); + $errors[$name] = $this->translator->trans("Ce champ est trop long %length% caracteres max", array('%length%' => $length)); if ($length_min != 0 && mb_strlen($datas[$name]) < $length_min) - $errors[$name] = sprintf(_("Ce champ est trop court %s caracteres min"), $length_min); + $errors[$name] = $this->translator->trans("Ce champ est trop court %length% caracteres min", array('%length%' => $length_min)); } }; @@ -904,13 +904,13 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I { $errors = []; if ( ! $record->get_hd_file() instanceof \SplFileInfo) - $errors["file_size"] = _("Le record n'a pas de fichier physique"); //Record must rely on real file + $errors["file_size"] = $this->translator->trans("Le record n'a pas de fichier physique"); //Record must rely on real file if ($record->get_duration() > self::AUTH_VIDEO_DURATION) - $errors["duration"] = sprintf(_("La taille maximale d'une video est de %d minutes."), self::AUTH_VIDEO_DURATION / 60); + $errors["duration"] = $this->translator->trans("La taille maximale d'une video est de %duration% minutes.", array('%duration%' => self::AUTH_VIDEO_DURATION / 60)); if ($record->get_technical_infos('size') > self::AUTH_VIDEO_SIZE) - $errors["size"] = sprintf(_("Le poids maximum d'un fichier est de %s"), p4string::format_octets(self::AUTH_VIDEO_SIZE)); + $errors["size"] = $this->translator->trans("Le poids maximum d'un fichier est de %size%", array('%size%' => p4string::format_octets(self::AUTH_VIDEO_SIZE))); return $errors; } diff --git a/lib/classes/Bridge/Api/Flickr.php b/lib/classes/Bridge/Api/Flickr.php index 2450848581..0ac2ce1709 100644 --- a/lib/classes/Bridge/Api/Flickr.php +++ b/lib/classes/Bridge/Api/Flickr.php @@ -132,7 +132,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf */ public function get_infos() { - return _('Ce produit utilise l\'API Flickr mais n\'est ni soutenu, ni certifie par Flickr'); + return $this->translator->trans('Ce produit utilise l\'API Flickr mais n\'est ni soutenu, ni certifie par Flickr'); } /** @@ -489,7 +489,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf { switch ($connector_status) { case self::UPLOAD_STATE_FAILED: - return _('L\'upload a echoue'); + return $this->translator->trans('L\'upload a echoue'); break; default: case self::UPLOAD_STATE_DONE: @@ -595,7 +595,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf */ public function get_element_types() { - return [self::ELEMENT_TYPE_PHOTO => _('Photos')]; + return [self::ELEMENT_TYPE_PHOTO => $this->translator->trans('Photos')]; } /** @@ -604,7 +604,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf */ public function get_container_types() { - return [self::CONTAINER_TYPE_PHOTOSET => _('Photosets')]; + return [self::CONTAINER_TYPE_PHOTOSET => $this->translator->trans('Photosets')]; } /** @@ -699,10 +699,10 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf if ( ! isset($datas[$name]) || trim($datas[$name]) === '') { if ($required) - $errors[$name . '_' . $key] = _("Ce champ est obligatoire"); + $errors[$name . '_' . $key] = $this->translator->trans("Ce champ est obligatoire"); } elseif ($length !== 0) { if (mb_strlen($datas[$name]) > $length) - $errors[$name . '_' . $key] = sprintf(_("Ce champ est trop long %s caracteres max"), $length); + $errors[$name . '_' . $key] = $this->translator->trans("Ce champ est trop long %length% caracteres max", array('%length%' => $length)); } }; @@ -721,10 +721,10 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf if ( ! isset($datas[$name]) || trim($datas[$name]) === '') { if ($required) - $errors[$name] = _("Ce champ est obligatoire"); + $errors[$name] = $this->translator->trans("Ce champ est obligatoire"); } elseif ($length !== 0) { if (mb_strlen($datas[$name]) > $length) - $errors[$name] = sprintf(_("Ce champ est trop long %s caracteres max"), $length); + $errors[$name] = $this->translator->trans("Ce champ est trop long %length% caracteres max", array('%length%' => $length)); } }; @@ -815,9 +815,9 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf { $errors = []; if ( ! $record->get_hd_file() instanceof \SplFileInfo) - $errors["file_size"] = _("Le record n'a pas de fichier physique"); //Record must rely on real file + $errors["file_size"] = $this->translator->trans("Le record n'a pas de fichier physique"); //Record must rely on real file if ($record->get_technical_infos('size') > self::AUTH_PHOTO_SIZE) - $errors["size"] = sprintf(_("Le poids maximum d'un fichier est de %s"), p4string::format_octets(self::AUTH_PHOTO_SIZE)); + $errors["size"] = $this->translator->trans("Le poids maximum d'un fichier est de %size%", array('%size%' => p4string::format_octets(self::AUTH_VIDEO_SIZE))); return $errors; } diff --git a/lib/classes/Bridge/Api/Interface.php b/lib/classes/Bridge/Api/Interface.php index b8720cd463..62a3924cc0 100644 --- a/lib/classes/Bridge/Api/Interface.php +++ b/lib/classes/Bridge/Api/Interface.php @@ -10,14 +10,13 @@ */ use Symfony\Component\Routing\Generator\UrlGenerator; +use Symfony\Component\HttpFoundation\Request; interface Bridge_Api_Interface { const OBJECT_CLASS_ELEMENT = 'element'; const OBJECT_CLASS_CONTAINER = 'container'; - public function __construct(UrlGenerator $generator, registryInterface $registry, Bridge_Api_Auth_Interface $auth); - /** * * @return Array diff --git a/lib/classes/Bridge/Api/Youtube.php b/lib/classes/Bridge/Api/Youtube.php index 2567656e2f..58c80a413a 100644 --- a/lib/classes/Bridge/Api/Youtube.php +++ b/lib/classes/Bridge/Api/Youtube.php @@ -161,7 +161,7 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter */ public function get_element_types() { - return [self::ELEMENT_TYPE_VIDEO => _('Videos')]; + return [self::ELEMENT_TYPE_VIDEO => $this->translator->trans('Videos')]; } /** @@ -170,7 +170,7 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter */ public function get_container_types() { - return [self::CONTAINER_TYPE_PLAYLIST => _('Playlists')]; + return [self::CONTAINER_TYPE_PLAYLIST => $this->translator->trans('Playlists')]; } /** @@ -489,26 +489,26 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter { switch ($connector_status) { case self::UPLOAD_STATE_RESTRICTED: - return _('La video est restreinte'); + return $this->translator->trans('La video est restreinte'); break; case self::UPLOAD_STATE_DELETED: - return _('La video a ete supprimee'); + return $this->translator->trans('La video a ete supprimee'); break; case self::UPLOAD_STATE_REJECTED: - return _('La video a ete rejetee'); + return $this->translator->trans('La video a ete rejetee'); break; case self::UPLOAD_STATE_FAILED: - return _('L\'upload a echoue'); + return $this->translator->trans('L\'upload a echoue'); break; default: case self::UPLOAD_STATE_PROCESSING: - return _('En cours d\'encodage'); + return $this->translator->trans('En cours d\'encodage'); break; default: return ''; break; case self::UPLOAD_STATE_DONE: - return _('OK'); + return $this->translator->trans('OK'); break; } } @@ -535,25 +535,25 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter $message = $code = ""; switch ($response->getStatus()) { case 400: - $message = _("Erreur la requête a été mal formée ou contenait des données valides."); + $message = $this->translator->trans("Erreur la requête a été mal formée ou contenait des données valides."); break; case 401: - $message = _("Erreur lors de l'authentification au service Youtube, Veuillez vous déconnecter, puis vous reconnecter."); + $message = $this->translator->trans("Erreur lors de l'authentification au service Youtube, Veuillez vous déconnecter, puis vous reconnecter."); break; case 403: - $message = _("Erreur lors de l'envoi de la requête. Erreur d'authentification."); + $message = $this->translator->trans("Erreur lors de l'envoi de la requête. Erreur d'authentification."); break; case 404: - $message = _("Erreur la ressource que vous tentez de modifier n'existe pas."); + $message = $this->translator->trans("Erreur la ressource que vous tentez de modifier n'existe pas."); break; case 500: - $message = _("Erreur YouTube a rencontré une erreur lors du traitement de la requête."); + $message = $this->translator->trans("Erreur YouTube a rencontré une erreur lors du traitement de la requête."); break; case 501: - $message = _("Erreur vous avez essayé d'exécuter une requête non prise en charge par Youtube"); + $message = $this->translator->trans("Erreur vous avez essayé d'exécuter une requête non prise en charge par Youtube"); break; case 503: - $message = _("Erreur le service Youtube n'est pas accessible pour le moment. Veuillez réessayer plus tard."); + $message = $this->translator->trans("Erreur le service Youtube n'est pas accessible pour le moment. Veuillez réessayer plus tard."); break; } @@ -570,34 +570,34 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter $reason = ''; switch ($code) { case "required": - $reason = _("A required field is missing or has an empty value"); + $reason = $this->translator->trans("A required field is missing or has an empty value"); break; case "deprecated": - $reason = _("A value has been deprecated and is no longer valid"); + $reason = $this->translator->trans("A value has been deprecated and is no longer valid"); break; case "invalid_format": - $reason = _("A value does not match an expected format"); + $reason = $this->translator->trans("A value does not match an expected format"); break; case "invalid_character": - $reason = _("A field value contains an invalid character"); + $reason = $this->translator->trans("A field value contains an invalid character"); break; case "too_long": - $reason = _("A value exceeds the maximum allowable length"); + $reason = $this->translator->trans("A value exceeds the maximum allowable length"); break; case "too_many_recent_calls": - $reason = _("The Youtube servers have received too many calls from the same caller in a short amount of time."); + $reason = $this->translator->trans("The Youtube servers have received too many calls from the same caller in a short amount of time."); break; case "too_many_entries": - $reason = _("You are attempting to exceed the storage limit on your account and must delete existing entries before inserting new entries"); + $reason = $this->translator->trans("You are attempting to exceed the storage limit on your account and must delete existing entries before inserting new entries"); break; case "InvalidToken"; - $reason = _("The authentication token specified in the Authorization header is invalid"); + $reason = $this->translator->trans("The authentication token specified in the Authorization header is invalid"); break; case "TokenExpired"; - $reason = _("The authentication token specified in the Authorization header has expired."); + $reason = $this->translator->trans("The authentication token specified in the Authorization header has expired."); break; case "disabled_in_maintenance_mode": - $reason = _("Current operations cannot be executed because the site is temporarily in maintenance mode. Wait a few minutes and try your request again"); + $reason = $this->translator->trans("Current operations cannot be executed because the site is temporarily in maintenance mode. Wait a few minutes and try your request again"); break; } @@ -605,7 +605,7 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter } if ($error == false && $response->getStatus() == 404) { - $message = _("Service youtube introuvable."); + $message = $this->translator->trans("Service youtube introuvable."); } $e = new Exception($message); } @@ -914,13 +914,13 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter if ( ! isset($datas[$name])) { if ($required) - $errors[$name . '_' . $key] = _("Ce champ est obligatoire"); + $errors[$name . '_' . $key] = $this->translator->trans("Ce champ est obligatoire"); } elseif (trim($datas[$name]) === '') { if ( ! $empty) - $errors[$name . '_' . $key] = _("Ce champ est obligatoire"); + $errors[$name . '_' . $key] = $this->translator->trans("Ce champ est obligatoire"); } elseif ($length !== 0) { if (mb_strlen($datas[$name]) > $length) - $errors[$name . '_' . $key] = sprintf(_("Ce champ est trop long %s caracteres max"), $length); + $errors[$name . '_' . $key] = $this->translator->trans("Ce champ est trop long %length% caracteres max", array('%length%' => $length)); } }; @@ -940,13 +940,13 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter if ( ! isset($datas[$name])) { if ($required) - $errors[$name] = _("Ce champ est obligatoire"); + $errors[$name] = $this->translator->trans("Ce champ est obligatoire"); } elseif (trim($datas[$name]) === '') { if ( ! $empty) - $errors[$name] = _("Ce champ est obligatoire"); + $errors[$name] = $this->translator->trans("Ce champ est obligatoire"); } elseif ($length !== 0) { if (mb_strlen($datas[$name]) > $length) - $errors[$name] = sprintf(_("Ce champ est trop long %s caracteres max"), $length); + $errors[$name] = $this->translator->trans("Ce champ est trop long %length% caracteres max", array('%length%' => $length)); } }; @@ -1018,13 +1018,13 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter $errors = []; $key = $record->get_serialize_key(); if ( ! $record->get_hd_file() instanceof SplFileInfo) - $errors["file_size_" . $key] = _("Le record n'a pas de fichier physique"); //Record must rely on real file + $errors["file_size_" . $key] = $this->translator->trans("Le record n'a pas de fichier physique"); //Record must rely on real file if ($record->get_duration() > self::AUTH_VIDEO_DURATION) - $errors["duration_" . $key] = sprintf(_("La taille maximale d'une video est de %d minutes."), self::AUTH_VIDEO_DURATION / 60); + $errors["duration_" . $key] = $this->translator->trans("La taille maximale d'une video est de %duration% minutes.", array('%duration%' => self::AUTH_VIDEO_DURATION / 60)); if ($record->get_technical_infos('size') > self::AUTH_VIDEO_SIZE) - $errors["size_" . $key] = sprintf(_("Le poids maximum d'un fichier est de %s"), p4string::format_octets(self::AUTH_VIDEO_SIZE)); + $errors["size_" . $key] = $this->translator->trans("Le poids maximum d'un fichier est de %size%", array('%size%' => p4string::format_octets(self::AUTH_VIDEO_SIZE))); return $errors; } diff --git a/lib/classes/User/Adapter.php b/lib/classes/User/Adapter.php index 8968612157..48d253bd54 100644 --- a/lib/classes/User/Adapter.php +++ b/lib/classes/User/Adapter.php @@ -378,7 +378,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $test_user = User_Adapter::get_usr_id_from_email($this->app, $email); if ($test_user && $test_user != $this->get_id()) { - throw new Exception_InvalidArgument(sprintf(_('A user already exists with email addres %s'), $email)); + throw new Exception_InvalidArgument($this->app->trans('A user already exists with email addres %email%', array('%email%' => $email))); } $sql = 'UPDATE usr SET usr_mail = :new_email WHERE usr_id = :usr_id'; @@ -1112,13 +1112,13 @@ class User_Adapter implements User_Interface, cache_cacheableInterface public function get_display_name() { if ($this->is_template()) - $display_name = sprintf(_('modele %s'), $this->get_login()); + $display_name = $this->app->trans('modele %name%', array('%name%' => $this->get_login())); elseif (trim($this->lastname) !== '' || trim($this->firstname) !== '') $display_name = $this->firstname . ' ' . $this->lastname; elseif (trim($this->email) !== '') $display_name = $this->email; else - $display_name = _('phraseanet::utilisateur inconnu'); + $display_name = $this->app->trans('phraseanet::utilisateur inconnu'); return $display_name; } diff --git a/lib/classes/appbox.php b/lib/classes/appbox.php index b3c94e1827..693168fea1 100644 --- a/lib/classes/appbox.php +++ b/lib/classes/appbox.php @@ -293,20 +293,20 @@ class appbox extends base /** * Step 1 */ - $upgrader->set_current_message(_('Flushing cache')); + $upgrader->set_current_message($this->app->trans('Flushing cache')); $app['phraseanet.cache-service']->flushAll(); $upgrader->add_steps_complete(1); - $upgrader->set_current_message(_('Creating new tables')); + $upgrader->set_current_message($this->app->trans('Creating new tables')); $upgrader->add_steps_complete(1); /** * Step 2 */ - $upgrader->set_current_message(_('Purging directories')); + $upgrader->set_current_message($this->app->trans('Purging directories')); $finder = new Finder(); $finder->in([ @@ -329,7 +329,7 @@ class appbox extends base /** * Step 5 */ - $upgrader->set_current_message(_('Copying files')); + $upgrader->set_current_message($this->app->trans('Copying files')); foreach ([ 'config/custom_files/' => 'www/custom/', @@ -348,7 +348,7 @@ class appbox extends base /** * Step 6 */ - $upgrader->set_current_message(_('Upgrading appbox')); + $upgrader->set_current_message($this->app->trans('Upgrading appbox')); $advices = $this->upgradeDB(true, $upgrader, $app); $upgrader->add_steps_complete(1); @@ -356,7 +356,7 @@ class appbox extends base * Step 7 */ foreach ($this->get_databoxes() as $s) { - $upgrader->set_current_message(sprintf(_('Upgrading %s'), $s->get_label($this->app['locale.I18n']))); + $upgrader->set_current_message($this->app->trans('Upgrading %databox_name%', array('%databox_name%' => $s->get_label($this->app['locale.I18n'])))); $advices = array_merge($advices, $s->upgradeDB(true, $upgrader, $app)); $upgrader->add_steps_complete(1); } @@ -364,14 +364,14 @@ class appbox extends base /** * Step 8 */ - $upgrader->set_current_message(_('Post upgrade')); + $upgrader->set_current_message($this->app->trans('Post upgrade')); $this->post_upgrade($upgrader, $app); $upgrader->add_steps_complete(1); /** * Step 9 */ - $upgrader->set_current_message(_('Flushing cache')); + $upgrader->set_current_message($this->app->trans('Flushing cache')); $app['phraseanet.cache-service']->flushAll(); @@ -384,14 +384,14 @@ class appbox extends base $upgrader->add_steps_complete(1); if (version::lt($from_version, '3.1')) { - $upgrader->addRecommendation(_('Your install requires data migration, please execute the following command'), 'bin/setup system:upgrade-datas --from=3.1'); + $upgrader->addRecommendation($app->trans('Your install requires data migration, please execute the following command'), 'bin/setup system:upgrade-datas --from=3.1'); } elseif (version::lt($from_version, '3.5')) { - $upgrader->addRecommendation(_('Your install requires data migration, please execute the following command'), 'bin/setup system:upgrade-datas --from=3.5'); + $upgrader->addRecommendation($app->trans('Your install requires data migration, please execute the following command'), 'bin/setup system:upgrade-datas --from=3.5'); } if (version::lt($from_version, '3.7')) { - $upgrader->addRecommendation(_('Your install might need to re-read technical datas'), 'bin/console records:rescan-technical-datas'); - $upgrader->addRecommendation(_('Your install might need to build some sub-definitions'), 'bin/console records:build-missing-subdefs'); + $upgrader->addRecommendation($app->trans('Your install might need to re-read technical datas'), 'bin/console records:rescan-technical-datas'); + $upgrader->addRecommendation($app->trans('Your install might need to build some sub-definitions'), 'bin/console records:build-missing-subdefs'); } return $advices; diff --git a/lib/classes/base.php b/lib/classes/base.php index 629d460a48..e888d716ee 100644 --- a/lib/classes/base.php +++ b/lib/classes/base.php @@ -301,7 +301,7 @@ abstract class base implements cache_cacheableInterface foreach ($rs as $row) { $tname = $row["Name"]; if (isset($allTables[$tname])) { - $upgrader->set_current_message(sprintf(_('Updating table %s'), $tname)); + $upgrader->set_current_message($app->trans('Updating table %table_name%', array('%table_name%' => $tname))); $engine = strtolower(trim($allTables[$tname]->engine)); $ref_engine = strtolower($row['Engine']); @@ -314,7 +314,7 @@ abstract class base implements cache_cacheableInterface $stmt->closeCursor(); } catch (Exception $e) { $recommends[] = [ - 'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()), + 'message' => $app->trans('Erreur lors de la tentative ; errreur : %message%', array('%message%' => $e->getMessage())), 'sql' => $sql ]; } @@ -333,13 +333,13 @@ abstract class base implements cache_cacheableInterface } foreach ($allTables as $tname => $table) { - $upgrader->set_current_message(sprintf(_('Creating table %s'), $table)); + $upgrader->set_current_message($app->trans('Creating table %table_name%', array('%table_name%' => $table))); $this->createTable($table); $upgrader->add_steps_complete(1); } $current_version = $this->get_version(); - $upgrader->set_current_message(sprintf(_('Applying patches on %s'), $this->get_dbname())); + $upgrader->set_current_message($app->trans('Applying patches on %databox_name%', array('%databox_name%' => $this->get_dbname()))); if ($apply_patches) { $this->apply_patches($current_version, $app['phraseanet.version']->getNumber(), false, $upgrader, $app); } @@ -536,7 +536,7 @@ abstract class base implements cache_cacheableInterface $stmt->closeCursor(); } catch (Exception $e) { $recommends[] = [ - 'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()), + 'message' => $this->app->trans('Erreur lors de la tentative ; errreur : %message%', array('%message%' => $e->getMessage())), 'sql' => $def['sql'] ]; } @@ -750,7 +750,7 @@ abstract class base implements cache_cacheableInterface $stmt->closeCursor(); } catch (Exception $e) { $return[] = [ - 'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()), + 'message' => $this->app->trans('Erreur lors de la tentative ; errreur : %message%', array('%message%' => $e->getMessage())), 'sql' => $a ]; } @@ -763,7 +763,7 @@ abstract class base implements cache_cacheableInterface $stmt->closeCursor(); } catch (Exception $e) { $return[] = [ - 'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()), + 'message' => $this->app->trans('Erreur lors de la tentative ; errreur : %message%', array('%message%' => $e->getMessage())), 'sql' => $a ]; } @@ -780,7 +780,7 @@ abstract class base implements cache_cacheableInterface $list_patches = []; - $upgrader->add_steps(1)->set_current_message(_('Looking for patches')); + $upgrader->add_steps(1)->set_current_message($app->trans('Looking for patches')); $iterator = new DirectoryIterator($this->app['root.path'] . '/lib/classes/patch/'); @@ -821,7 +821,7 @@ abstract class base implements cache_cacheableInterface $upgrader->add_steps_complete(1) ->add_steps(count($list_patches)) - ->set_current_message(sprintf(_('Applying patches on %s'), $this->get_dbname())); + ->set_current_message($app->trans('Applying patches on %databox_name%', array('%databox_name%' => $this->get_dbname()))); ksort($list_patches); $success = true; diff --git a/lib/classes/caption/record.php b/lib/classes/caption/record.php index c15ab7e714..0cf6dbf170 100644 --- a/lib/classes/caption/record.php +++ b/lib/classes/caption/record.php @@ -304,12 +304,13 @@ class caption_record implements caption_interface, cache_cacheableInterface $value = preg_replace( "(([^']{1})((https?|file):((/{2,4})|(\\{2,4}))[\w:#%/;$()~_?/\-=\\\.&]*)([^']{1}))" - , '$1 $2  $7' + , '$1 $2  $7' , $highlight ? $field->highlight_thesaurus() : $field->get_serialized_values(false, false) ); $fields[$field->get_name()] = [ 'value' => $value, + /** @Ignore */ 'label' => $field->get_databox_field()->get_label($this->app['locale.I18n']), 'separator' => $field->get_databox_field()->get_separator(), ]; diff --git a/lib/classes/databox.php b/lib/classes/databox.php index afce1ba52a..43dd15914f 100644 --- a/lib/classes/databox.php +++ b/lib/classes/databox.php @@ -13,6 +13,7 @@ use Alchemy\Phrasea\Application; use Symfony\Component\Filesystem\Filesystem; use Alchemy\Phrasea\Exception\InvalidArgumentException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use Symfony\Component\Translation\TranslatorInterface; class databox extends base { @@ -675,7 +676,7 @@ class databox extends base public function get_subdef_structure() { if (! $this->subdef_struct) { - $this->subdef_struct = new databox_subdefsStructure($this); + $this->subdef_struct = new databox_subdefsStructure($this, $this->app['translator']); } return $this->subdef_struct; @@ -1304,7 +1305,7 @@ class databox extends base * @param string $structure * @return Array */ - public static function get_structure_errors($structure) + public static function get_structure_errors(TranslatorInterface $translator, $structure) { $sx_structure = simplexml_load_string($structure); @@ -1317,7 +1318,7 @@ class databox extends base $subdefgroup_name = trim((string) $subdefs->attributes()->name); if ($subdefgroup_name == '') { - $errors[] = _('ERREUR : TOUTES LES BALISES subdefgroup necessitent un attribut name'); + $errors[] = $translator->trans('ERREUR : TOUTES LES BALISES subdefgroup necessitent un attribut name'); continue; } @@ -1328,11 +1329,11 @@ class databox extends base $sd_name = trim(mb_strtolower((string) $sd->attributes()->name)); $sd_class = trim(mb_strtolower((string) $sd->attributes()->class)); if ($sd_name == '' || isset($AvSubdefs[$subdefgroup_name][$sd_name])) { - $errors[] = _('ERREUR : Les name de subdef sont uniques par groupe de subdefs et necessaire'); + $errors[] = $translator->trans('ERREUR : Les name de subdef sont uniques par groupe de subdefs et necessaire'); continue; } if ( ! in_array($sd_class, ['thumbnail', 'preview', 'document'])) { - $errors[] = _('ERREUR : La classe de subdef est necessaire et egal a "thumbnail","preview" ou "document"'); + $errors[] = $translator->trans('ERREUR : La classe de subdef est necessaire et egal a "thumbnail","preview" ou "document"'); continue; } $AvSubdefs[$subdefgroup_name][$sd_name] = $sd; diff --git a/lib/classes/databox/cgu.php b/lib/classes/databox/cgu.php index 8113336024..0b1bde198b 100644 --- a/lib/classes/databox/cgu.php +++ b/lib/classes/databox/cgu.php @@ -29,12 +29,12 @@ class databox_cgu if (trim($term['terms']) == '') { continue; } - $out .= '

    - {% trans %} {{error}} - {% endtrans %}

    @@ -66,9 +62,7 @@

    - {% trans %} - Copiez le code ci-dessous, retournez dans votre application et collez-le a l'endroit requis : - {% endtrans %} + {% trans %}Copiez le code ci-dessous, retournez dans votre application et collez-le a l'endroit requis :{% endtrans %}

    diff --git a/templates/web/account/access.html.twig b/templates/web/account/access.html.twig index fcbab25619..b2a761c0be 100644 --- a/templates/web/account/access.html.twig +++ b/templates/web/account/access.html.twig @@ -27,7 +27,7 @@ {% set base_id = sbasId |base_from_coll(collId, app) %} - {{ "login::register: acces authorise sur la collection " | trans }}{{ sbasId |sbas_labels(app) }} + {{ "login::register: acces authorise sur la collection" | trans }}{{ sbasId |sbas_labels(app) }} {% if isTrue | trim != "" %}
    {{ "login::register::CGU: lire les CGU" | trans }} {% endif %} @@ -46,7 +46,7 @@ {% set base_id = sbasId |base_from_coll(collId, app) %} - {{ "login::register: acces refuse sur la collection " | trans }}{{ sbasId |sbas_labels(app) }} + {{ "login::register: acces refuse sur la collection" | trans }}{{ sbasId |sbas_labels(app) }} {% if isTrue | trim != "" %} {{ "login::register::CGU: lire les CGU" | trans }} {% endif %} @@ -94,7 +94,7 @@ {% set base_id = sbasId |base_from_coll(collId, app) %} - {{ "login::register: acces temporaire termine sur " | trans }}{{ sbasId |sbas_labels(app) }} + {{ "login::register: acces temporaire termine sur" | trans }}{{ sbasId |sbas_labels(app) }} {% if isTrue |trim != "" %} {{ "login::register::CGU: lire les CGU" | trans }} {% endif %} diff --git a/templates/web/account/authorized_apps.html.twig b/templates/web/account/authorized_apps.html.twig index ead5e811c2..65b2393145 100644 --- a/templates/web/account/authorized_apps.html.twig +++ b/templates/web/account/authorized_apps.html.twig @@ -26,9 +26,7 @@ {% if application.get_creator() is not none %} {% set user_name = application.get_creator().get_display_name() %} - {% trans with {'%user_name%' : user_name} %} - par %user_name% - {% endtrans %} + {% trans with {'%user_name%' : user_name} %}par %user_name%{% endtrans %} {% endif%}

    diff --git a/templates/web/admin/collection/collection.html.twig b/templates/web/admin/collection/collection.html.twig index eeafd70c03..81febc6be6 100644 --- a/templates/web/admin/collection/collection.html.twig +++ b/templates/web/admin/collection/collection.html.twig @@ -215,7 +215,7 @@ {# Bandeau de présentation #}
    -
    {{ 'admin::base:collection: image de presentation : ' | trans }}
    +
    {{ 'admin::base:collection: image de presentation :' | trans }}
    {% if collection.getPresentation(bas_id) is not empty %}
    {{ collection.getPresentation(bas_id)| raw }}
    {% if app['acl'].get(app['authentication'].getUser()).has_right_on_base(bas_id, 'manage') %} diff --git a/templates/web/admin/collection/create.html.twig b/templates/web/admin/collection/create.html.twig index 89f3847987..bb72988a46 100644 --- a/templates/web/admin/collection/create.html.twig +++ b/templates/web/admin/collection/create.html.twig @@ -19,13 +19,13 @@
    - +
    - +
    diff --git a/templates/web/admin/collection/suggested_value.html.twig b/templates/web/admin/collection/suggested_value.html.twig index 306ab8e616..099342bf87 100644 --- a/templates/web/admin/collection/suggested_value.html.twig +++ b/templates/web/admin/collection/suggested_value.html.twig @@ -898,7 +898,7 @@ function view(type) break; case 'GRAPH': - if( !changeInXml || confirm("{{ 'admin::sugval: Attention, passer en mode graphique implique la perte des modifications du xml si vous n\'appliquez pas les changements avant.\nContinuer quand meme'|trans | e('js') }}")) + if( !changeInXml || confirm("{{ 'admin::sugval: Attention, passer en mode graphique implique la perte des modifications du xml si vous n\'appliquez pas les changements avant.' |trans | e('js') }}\n{{ 'Continuer quand meme' |trans | e('js') }}")) { if($('#divGraph').length > 0 ) $('#divGraph').show(); diff --git a/templates/web/admin/connected-users.html.twig b/templates/web/admin/connected-users.html.twig index d36ed7179d..3b9a2ff64a 100644 --- a/templates/web/admin/connected-users.html.twig +++ b/templates/web/admin/connected-users.html.twig @@ -22,7 +22,7 @@ {{ 'admin::compte-utilisateur email' | trans }} : {{ user.get_email() }} - {{ 'admin::monitor: bases sur lesquelles l\'utilisateur est connecte : ' | trans }} : + {{ 'admin::monitor: bases sur lesquelles l\'utilisateur est connecte :' | trans }} : {% for databox in app['acl'].get(user).get_granted_sbas() %} @@ -76,7 +76,7 @@ {% if data['applications'][0] != 0 %} - {{ 'admin::monitor: total des utilisateurs uniques : ' | trans }} + {{ 'admin::monitor: total des utilisateurs uniques :' | trans }} {{ data['applications'][0] }} {% endif %} diff --git a/templates/web/admin/databases.html.twig b/templates/web/admin/databases.html.twig index 94ff6ae3db..1d608af504 100644 --- a/templates/web/admin/databases.html.twig +++ b/templates/web/admin/databases.html.twig @@ -48,9 +48,9 @@

    {{ 'admin::base: Version' | trans }}

    {% if not app['phraseanet.configuration-tester'].isUpToDate() %} -

    {{ 'update::Votre application necessite une mise a jour vers : ' | trans }} {{ app['phraseanet.version'].getNumber() }}

    +

    {{ 'update::Votre application necessite une mise a jour vers :' | trans }} {{ app['phraseanet.version'].getNumber() }}

    {% else %} -

    {{ 'update::Votre version est a jour : ' | trans }} {{ app['phraseanet.version'].getNumber() }}

    +

    {{ 'update::Votre version est a jour :' | trans }} {{ app['phraseanet.version'].getNumber() }}

    {% endif %} {% if recommendations | length > 0%} @@ -133,4 +133,4 @@
    -{% endif %} \ No newline at end of file +{% endif %} diff --git a/templates/web/admin/databox/databox.html.twig b/templates/web/admin/databox/databox.html.twig index 4a178dd744..96e9449ed0 100644 --- a/templates/web/admin/databox/databox.html.twig +++ b/templates/web/admin/databox/databox.html.twig @@ -52,7 +52,7 @@ {% if showDetail %}
  • - {{ 'admin::base: nombre de mots uniques sur la base : ' | trans }} + {{ 'admin::base: nombre de mots uniques sur la base :' | trans }} {{ databox.get_unique_keywords() }}
  • @@ -179,7 +179,7 @@
    {{ "Monter" | trans }} {{ name }} {% if app['acl'].get(app['authentication'].getUser()).get_granted_base(["canadmin"]) | length > 0 %} - + @@ -90,9 +88,7 @@

    {% set name = value['name'] %} - {% trans with {'%name%' : name} %} - erreur avec la valeur %name% - {% endtrans %} + {% trans with {'%name%' : name} %}erreur avec la valeur %name%{% endtrans %}

    {% endif %} {% elseif value['type'] == 'integer' %} diff --git a/templates/web/admin/task-manager/list.html.twig b/templates/web/admin/task-manager/list.html.twig index 2089bfd03a..24260f39ec 100644 --- a/templates/web/admin/task-manager/list.html.twig +++ b/templates/web/admin/task-manager/list.html.twig @@ -33,9 +33,7 @@ {% set updateTime %} {% endset %} - {% trans with {'%updateTime%' : updateTime} %} - Last update on %updateTime% - {% endtrans %} + {% trans with {'%updateTime%' : updateTime} %}Last update on %updateTime%{% endtrans %}
    diff --git a/templates/web/admin/task-manager/task-editor/task.html.twig b/templates/web/admin/task-manager/task-editor/task.html.twig index b557fdff9a..b432928ef4 100644 --- a/templates/web/admin/task-manager/task-editor/task.html.twig +++ b/templates/web/admin/task-manager/task-editor/task.html.twig @@ -20,7 +20,7 @@
    - {{ 'admin::tasks: Nombre de crashes : ' | trans }} {{ task.getCrashed() }} + {{ 'admin::tasks: Nombre de crashes :' | trans }} {{ task.getCrashed() }} diff --git a/templates/web/admin/users.html.twig b/templates/web/admin/users.html.twig index ca8e15ab6e..f6b5cdec8b 100644 --- a/templates/web/admin/users.html.twig +++ b/templates/web/admin/users.html.twig @@ -8,13 +8,9 @@ {% set user_count = app['request'].get('user-updated') %} {% if user_count == 1 %} - {% trans %} - The user has been created. - {% endtrans %} + {% trans %}The user has been created.{% endtrans %} {% else %} - {% trans with {'%user_count%' : user_count} %} - %user_count% users have been created. - {% endtrans %} + {% trans with {'%user_count%' : user_count} %}%user_count% users have been created.{% endtrans %} {% endif %}
    {% endif %} @@ -203,11 +199,11 @@ {% endif %} diff --git a/templates/web/api/auth/end_user_authorization.html.twig b/templates/web/api/auth/end_user_authorization.html.twig index 4523179c8f..cb004e78da 100644 --- a/templates/web/api/auth/end_user_authorization.html.twig +++ b/templates/web/api/auth/end_user_authorization.html.twig @@ -43,9 +43,7 @@

    {{ 'Erreur de login / mot de passe' | trans }}

    {% endif %}

    - {% trans with {'%home_title%' : home_title} %} - Bonjour, veuillez vous identifier sur %home_title% : - {% endtrans %} + {% trans with {'%home_title%' : home_title} %}Bonjour, veuillez vous identifier sur %home_title% :{% endtrans %}

    @@ -60,9 +58,7 @@ {% set username = '' ~ app['authentication'].getUser().get_display_name() ~ '' %}
    {% endif %} @@ -74,9 +70,7 @@
    {% set application_name = "" ~ auth.getClient.get_name() ~ "" %}

    - {% trans with {'%application_name%' : application_name, '%home_title%' : home_title} %} - Autorisez-vous l'application %application_name% a acceder a votre contenu sur %home_title% ? - {% endtrans %} + {% trans with {'%application_name%' : application_name, '%home_title%' : home_title} %}Autorisez-vous l'application %application_name% a acceder a votre contenu sur %home_title% ?{% endtrans %}

    diff --git a/templates/web/api/auth/native_app_access_token.html.twig b/templates/web/api/auth/native_app_access_token.html.twig index ef3fef242c..4b066d4855 100644 --- a/templates/web/api/auth/native_app_access_token.html.twig +++ b/templates/web/api/auth/native_app_access_token.html.twig @@ -41,9 +41,7 @@ {% set username = '' ~ app['authentication'].getUser().get_display_name() ~ '' %}
    {% endif %} @@ -54,9 +52,7 @@

    - {% trans with {'%error%' : error} %} - %error% - {% endtrans %} + {{ error }}

    @@ -66,9 +62,7 @@

    - {% trans %} - Copiez le code ci-dessous, retournez dans votre application et collez-le a l'endroit requis : - {% endtrans %} + {% trans %}Copiez le code ci-dessous, retournez dans votre application et collez-le a l'endroit requis :{% endtrans %}

    diff --git a/templates/web/client/answers.html.twig b/templates/web/client/answers.html.twig index 09ff3ed2e9..e97146c5ec 100644 --- a/templates/web/client/answers.html.twig +++ b/templates/web/client/answers.html.twig @@ -32,9 +32,7 @@ {{ query_string[0:36] }}{% if query_string|length > 36 %}...{% endif %} - {% trans with {'%available_results%' : available_results} %} - client::answers: %available_results% reponses - {% endtrans %} + {% trans with {'%available_results%' : available_results} %}client::answers: %available_results% reponses{% endtrans %}   {% endset %} diff --git a/templates/web/client/baskets.html.twig b/templates/web/client/baskets.html.twig index 260e09391a..ed544b44b9 100644 --- a/templates/web/client/baskets.html.twig +++ b/templates/web/client/baskets.html.twig @@ -6,9 +6,7 @@ {% if selected_basket is not none %} {{ selected_basket.getName() }} : - {% trans with {'%nb_basket_elements%' : nb_basket_elements} %} - paniers:: %nb_basket_elements% documents dans le panier - {% endtrans %} + {% trans with {'%nb_basket_elements%' : nb_basket_elements} %}paniers:: %nb_basket_elements% documents dans le panier{% endtrans %} {% if app['phraseanet.registry'].get('GV_viewSizeBaket') %} ({{ selected_basket.getSize(app) }} Mo) {% endif %} @@ -64,9 +62,7 @@ {% if selected_basket is not none and selected_basket.getPusher(app) is not none %} {% set pusher_name = selected_basket.getPusher(app).get_display_name() %}
    - {% trans with {'%pusher_name%' : pusher_name} %} - paniers:: panier emis par %pusher_name% - {% endtrans %} + {% trans with {'%pusher_name%' : pusher_name} %}paniers:: panier emis par %pusher_name%{% endtrans %}
    {% endif %} @@ -135,9 +131,7 @@ {% if selected_basket is not none %} {{ selected_basket.getName() }} : - {% trans with {'%nb_basket_elements%' : nb_basket_elements} %} - paniers:: %nb_basket_elements% documents dans le panier - {% endtrans %} + {% trans with {'%nb_basket_elements%' : nb_basket_elements} %}paniers:: %nb_basket_elements% documents dans le panier{% endtrans %} {% endif %} diff --git a/templates/web/common/dialog_export.html.twig b/templates/web/common/dialog_export.html.twig index 3b04e46505..582877b040 100644 --- a/templates/web/common/dialog_export.html.twig +++ b/templates/web/common/dialog_export.html.twig @@ -151,9 +151,7 @@ {% set beginning_link = '' %} {% set end_link = '' %} - {% trans with {'%beginning_link%' : beginning_link, '%end_link%' : end_link} %} - By checking this box, you accept %beginning_link% Terms of Use %end_link% - {% endtrans %} + {% trans with {'%beginning_link%' : beginning_link, '%end_link%' : end_link} %}By checking this box, you accept %beginning_link% Terms of Use %end_link%{% endtrans %} {% endif %} @@ -234,9 +232,7 @@ {% set beginning_link = '' %} {% set end_link = '' %} - {% trans with {'%beginning_link%' : beginning_link, '%end_link%' : end_link} %} - By checking this box, you accept %beginning_link% Terms of Use %end_link% - {% endtrans %} + {% trans with {'%beginning_link%' : beginning_link, '%end_link%' : end_link} %}By checking this box, you accept %beginning_link% Terms of Use %end_link%{% endtrans %} {% endif %} @@ -389,9 +385,7 @@ {% set beginning_link = '' %} {% set end_link = '' %} - {% trans with {'%beginning_link%' : beginning_link, '%end_link%' : end_link} %} - By checking this box, you accept %beginning_link% Terms of Use %end_link% - {% endtrans %} + {% trans with {'%beginning_link%' : beginning_link, '%end_link%' : end_link} %}By checking this box, you accept %beginning_link% Terms of Use %end_link%{% endtrans %} {% endif %} @@ -472,9 +466,7 @@ {% set beginning_link = '' %} {% set end_link = '' %} - {% trans with {'%beginning_link%' : beginning_link, '%end_link%' : end_link} %} - By checking this box, you accept %beginning_link% Terms of Use %end_link% - {% endtrans %} + {% trans with {'%beginning_link%' : beginning_link, '%end_link%' : end_link} %}By checking this box, you accept %beginning_link% Terms of Use %end_link%{% endtrans %} {% endif %} @@ -649,7 +641,7 @@ {% set max_download = app['phraseanet.registry'].get('GV_download_max', 120) %} {% set alert_too_big_one %} - {% trans with {'%max_download%' : max_download} %} You can not directly download more than %max_download% Mo ; time to package all documents is too long{% endtrans %} + {% trans with {'%max_download%' : max_download} %}You can not directly download more than %max_download% Mo ; time to package all documents is too long{% endtrans %} {% endset %} {% set alert_too_big_two %} {{ 'You can alternatively receive an email when the download is ready.' | trans }} diff --git a/templates/web/email-template.html.twig b/templates/web/email-template.html.twig index c0cc94150f..f74b5dfc39 100644 --- a/templates/web/email-template.html.twig +++ b/templates/web/email-template.html.twig @@ -131,9 +131,7 @@ {{ phraseanetTitle }} {% endset %} - {% trans with {'%link%' : link} %} - Pour gérer l'envoi d'email automatique, connectez-vous à %link% - {% endtrans %} + {% trans with {'%link%' : link} %}Pour gérer l'envoi d'email automatique, connectez-vous à %link%{% endtrans %} diff --git a/templates/web/login/common/macros.html.twig b/templates/web/login/common/macros.html.twig index 40e1c77cdf..8b1dbadcfa 100644 --- a/templates/web/login/common/macros.html.twig +++ b/templates/web/login/common/macros.html.twig @@ -106,7 +106,7 @@ diff --git a/templates/web/prod/actions/Bridge/Flickr/photo_deleteelement.html.twig b/templates/web/prod/actions/Bridge/Flickr/photo_deleteelement.html.twig index 14e4031b72..e460d303cd 100644 --- a/templates/web/prod/actions/Bridge/Flickr/photo_deleteelement.html.twig +++ b/templates/web/prod/actions/Bridge/Flickr/photo_deleteelement.html.twig @@ -3,18 +3,14 @@ {% set n_element = elements|length %} {% block menu %} - {% trans with {'%n_element%' : n_element} %} - Suppression de %n_element% photos - {% endtrans %} + {% trans with {'%n_element%' : n_element} %}Suppression de %n_element% photos{% endtrans %} {% endblock %} {% block response %}

    {% set number = elements|length %} - {% trans with {'%number%' : number} %} - Etes vous sur de supprimer %number% photos ? - {% endtrans %} + {% trans with {'%number%' : number} %}Etes vous sur de supprimer %number% photos ?{% endtrans %}

    {% for id in elements %} diff --git a/templates/web/prod/actions/Bridge/Flickr/photo_moveinto_photoset.html.twig b/templates/web/prod/actions/Bridge/Flickr/photo_moveinto_photoset.html.twig index ee991f8868..3247fb28f1 100644 --- a/templates/web/prod/actions/Bridge/Flickr/photo_moveinto_photoset.html.twig +++ b/templates/web/prod/actions/Bridge/Flickr/photo_moveinto_photoset.html.twig @@ -3,18 +3,14 @@ {% set n_element = elements|length %} {% block menu %} - {% trans with {'%n_element%' : n_element} %} - Deplacement %n_element% elements - {% endtrans %} + {% trans with {'%n_element%' : n_element} %}Deplacement %n_element% elements{% endtrans %} {% endblock %} {% block response %}

    {% set number = elements|length %} - {% trans with {'%number%' : number} %} - Which photosets you want to put you %number% photos into ? - {% endtrans %} + {% trans with {'%number%' : number} %}Which photosets you want to put you %number% photos into ?{% endtrans %}

    {% for id in elements %} diff --git a/templates/web/prod/actions/Bridge/Flickr/photoset_createcontainer.html.twig b/templates/web/prod/actions/Bridge/Flickr/photoset_createcontainer.html.twig index 77f0026d53..406c8e2c60 100644 --- a/templates/web/prod/actions/Bridge/Flickr/photoset_createcontainer.html.twig +++ b/templates/web/prod/actions/Bridge/Flickr/photoset_createcontainer.html.twig @@ -1,9 +1,7 @@ {% extends "prod/actions/Bridge/wrapper.html.twig" %} {% block menu %} - {% trans %} - Creer un Photoset - {% endtrans %} + {% trans %}Creer un Photoset{% endtrans %} {% endblock %} {% block response %} diff --git a/templates/web/prod/actions/Bridge/Flickr/photoset_deleteelement.html.twig b/templates/web/prod/actions/Bridge/Flickr/photoset_deleteelement.html.twig index 884c0264ac..91f9ca6fd2 100644 --- a/templates/web/prod/actions/Bridge/Flickr/photoset_deleteelement.html.twig +++ b/templates/web/prod/actions/Bridge/Flickr/photoset_deleteelement.html.twig @@ -3,18 +3,14 @@ {% set n_element = elements|length %} {% block menu %} - {% trans with {'%n_element%' : n_element} %} - Suppression de %n_element% photosets - {% endtrans %} + {% trans with {'%n_element%' : n_element} %}Suppression de %n_element% photosets{% endtrans %} {% endblock %} {% block response %}

    {% set number = elements|length %} - {% trans with {'%number%' : number} %} - Etes vous sur de supprimer %number% photosets ? - {% endtrans %} + {% trans with {'%number%' : number} %}Etes vous sur de supprimer %number% photosets ?{% endtrans %}

    {% for id in elements %} diff --git a/templates/web/prod/actions/Bridge/Flickr/upload.html.twig b/templates/web/prod/actions/Bridge/Flickr/upload.html.twig index 47471f59f5..1abd9c5310 100644 --- a/templates/web/prod/actions/Bridge/Flickr/upload.html.twig +++ b/templates/web/prod/actions/Bridge/Flickr/upload.html.twig @@ -3,9 +3,7 @@ {% import "prod/actions/Bridge/macro_error_form.html.twig" as error_form %} {% block menu %} - {% trans %} - Upload - {% endtrans %} + {% trans %}Upload{% endtrans %} {% endblock %} {% block response %} @@ -20,15 +18,11 @@ {% else %} {% if elements_length != elements_received_length %} {% set n_elements = elements_received_length - elements_length %} - {% trans with {'%n_elements%' : n_elements} %} - %n_elements% elements ne peuvent etre uploades - {% endtrans %} + {% trans with {'%n_elements%' : n_elements} %}%n_elements% elements ne peuvent etre uploades{% endtrans %} {% endif %} - {% trans with {'%elements_length%' : elements_length} %} - Upload sur Flickr de %elements_length% elements - {% endtrans %} + {% trans with {'%elements_length%' : elements_length} %}Upload sur Flickr de %elements_length% elements{% endtrans %} {% for record in route.get_elements() %} diff --git a/templates/web/prod/actions/Bridge/Youtube/element_informations.html.twig b/templates/web/prod/actions/Bridge/Youtube/element_informations.html.twig index 97f75a3926..4bf53f1475 100644 --- a/templates/web/prod/actions/Bridge/Youtube/element_informations.html.twig +++ b/templates/web/prod/actions/Bridge/Youtube/element_informations.html.twig @@ -2,26 +2,18 @@
  • {% set nb_view = element.get_view_count|default(0) %} {% if nb_view <= 1 %} - {% trans with {'%nb_view%' : nb_view} %} - %nb_view% vue - {% endtrans %} + {% trans with {'%nb_view%' : nb_view} %}%nb_view% vue{% endtrans %} {% else %} - {% trans with {'%nb_view%' : nb_view} %} - %nb_view% vues - {% endtrans %} + {% trans with {'%nb_view%' : nb_view} %}%nb_view% vues{% endtrans %} {% endif %}
  • {% set value = element.get_rating|default(0) %} {% if value > 0 %}
  • {% if value <= 1 %} - {% trans with {'%value%' : value} %} - %value% like - {% endtrans %} + {% trans with {'%value%' : value} %}%value% like{% endtrans %} {% else %} - {% trans with {'%value%' : value} %} - %value% likes - {% endtrans %} + {% trans with {'%value%' : value} %}%value% likes{% endtrans %} {% endif %}
  • {% endif %} diff --git a/templates/web/prod/actions/Bridge/Youtube/playlist_createcontainer.html.twig b/templates/web/prod/actions/Bridge/Youtube/playlist_createcontainer.html.twig index 18a4396742..c86493f375 100644 --- a/templates/web/prod/actions/Bridge/Youtube/playlist_createcontainer.html.twig +++ b/templates/web/prod/actions/Bridge/Youtube/playlist_createcontainer.html.twig @@ -1,9 +1,7 @@ {% extends "prod/actions/Bridge/wrapper.html.twig" %} {% block menu %} - {% trans %} - Creer une playlist - {% endtrans %} + {% trans %}Creer une playlist{% endtrans %} {% endblock %} {% block response %} diff --git a/templates/web/prod/actions/Bridge/Youtube/playlist_deleteelement.html.twig b/templates/web/prod/actions/Bridge/Youtube/playlist_deleteelement.html.twig index 545070d026..9b6354b3ac 100644 --- a/templates/web/prod/actions/Bridge/Youtube/playlist_deleteelement.html.twig +++ b/templates/web/prod/actions/Bridge/Youtube/playlist_deleteelement.html.twig @@ -3,18 +3,14 @@ {% set n_element = elements|length %} {% block menu %} - {% trans with {'%n_element%' : n_element} %} - Suppression de %n_element% playlists - {% endtrans %} + {% trans with {'%n_element%' : n_element} %}Suppression de %n_element% playlists{% endtrans %} {% endblock %} {% block response %}

    {% set number = elements|length %} - {% trans with {'%number%' : number} %} - Etes vous sur de supprimer %number% playlists ? - {% endtrans %} + {% trans with {'%number%' : number} %}Etes vous sur de supprimer %number% playlists ?{% endtrans %}

    {% for id in elements %} diff --git a/templates/web/prod/actions/Bridge/Youtube/upload.html.twig b/templates/web/prod/actions/Bridge/Youtube/upload.html.twig index f51fb96350..ca6dab523f 100644 --- a/templates/web/prod/actions/Bridge/Youtube/upload.html.twig +++ b/templates/web/prod/actions/Bridge/Youtube/upload.html.twig @@ -2,9 +2,7 @@ {% import "prod/actions/Bridge/macro_error_form.html.twig" as error_form %} {% block menu %} - {% trans %} - Upload - {% endtrans %} + {% trans %}Upload{% endtrans %} {% endblock %} {% block response %} @@ -106,9 +104,7 @@

    {# see http://code.google.com/intl/en/apis/youtube/terms.html#} {% set lien_term_youtube = 'http://www.youtube.com/t/terms' %} - {% trans with {'%lien_term_youtube%' : lien_term_youtube} %} - En cliquant sur "ajouter" vous certifiez que vous possedez les droits pour le contenu ou que vous etes autorisé par le proprietaire à rendre le contenu accessible au public sur YouTube, et qu'il est autrement conforme aux Conditions d'utilisation de YouTubesitue a %lien_term_youtube% - {% endtrans %} + {% trans with {'%lien_term_youtube%' : lien_term_youtube} %}En cliquant sur "ajouter" vous certifiez que vous possedez les droits pour le contenu ou que vous etes autorisé par le proprietaire à rendre le contenu accessible au public sur YouTube, et qu'il est autrement conforme aux Conditions d'utilisation de YouTubesitue a %lien_term_youtube%{% endtrans %}

    \ No newline at end of file + diff --git a/templates/web/thesaurus/new-term.html.twig b/templates/web/thesaurus/new-term.html.twig index 0953401b56..73ee53893e 100644 --- a/templates/web/thesaurus/new-term.html.twig +++ b/templates/web/thesaurus/new-term.html.twig @@ -14,23 +14,19 @@ {% if context is not none %} {% set zterm %} - {% trans with {'%term%' : term, '%context%' : context} %} - thesaurus:: le terme %term% avec contexte %context% - {% endtrans %} + {% trans with {'%term%' : term, '%context%' : context} %}thesaurus:: le terme %term% avec contexte %context%{% endtrans %} {% endset %} {% else %} {% set zterm %} - {% trans with {'%term%' : term} %} - thesaurus:: le terme %term% sans contexte - {% endtrans %} + {% trans with {'%term%' : term} %}thesaurus:: le terme %term% sans contexte{% endtrans %} {% endset %} {% endif %} {% if nb_candidates_ok > 0 %} {% if nb_candidates_ok == 1 %} - {% set prop_label = 'thesaurus:: est deja candidat en provenance du champ acceptable : ' | trans %} + {% set prop_label = 'thesaurus:: est deja candidat en provenance du champ acceptable :' | trans %} {% else %} - {% set prop_label = 'thesaurus:: est deja candidat en provenance des champs acceptables : ' | trans %} + {% set prop_label = 'thesaurus:: est deja candidat en provenance des champs acceptables :' | trans %} {% endif %}

    diff --git a/templates/web/thesaurus/properties.html.twig b/templates/web/thesaurus/properties.html.twig index 0c053862a0..ff2d1c583a 100644 --- a/templates/web/thesaurus/properties.html.twig +++ b/templates/web/thesaurus/properties.html.twig @@ -56,9 +56,7 @@ {% if typ == "CT" %}
    {% elseif typ == "TH" %} - {% trans with {'%hits%' : hits} %} - thesaurus:: %hits% reponses retournees - {% endtrans %} + {% trans with {'%hits%' : hits} %}thesaurus:: %hits% reponses retournees{% endtrans %}

    {% endif %} diff --git a/templates/web/thesaurus/search.html.twig b/templates/web/thesaurus/search.html.twig index 10261691bc..68e38ed3e2 100644 --- a/templates/web/thesaurus/search.html.twig +++ b/templates/web/thesaurus/search.html.twig @@ -39,7 +39,7 @@ - +
    {{ 'thesaurus:: le terme' | trans }}{{ 'thesaurus:: est egal a ' | trans }}{{ 'thesaurus:: est egal a' | trans }}
    diff --git a/tests/Alchemy/Tests/Phrasea/Border/Checker/AbstractCheckerTest.php b/tests/Alchemy/Tests/Phrasea/Border/Checker/AbstractCheckerTest.php index 12220c6aa2..850af1a21a 100644 --- a/tests/Alchemy/Tests/Phrasea/Border/Checker/AbstractCheckerTest.php +++ b/tests/Alchemy/Tests/Phrasea/Border/Checker/AbstractCheckerTest.php @@ -6,6 +6,7 @@ use Alchemy\Phrasea\Border\Checker\AbstractChecker; use Alchemy\Phrasea\Border\File; use Alchemy\Phrasea\Application; use Doctrine\ORM\EntityManager; +use Symfony\Component\Translation\TranslatorInterface; class AbstractCheckerTest extends \PhraseanetPHPUnitAbstract { @@ -203,7 +204,7 @@ class AbstractCheckerTest extends \PhraseanetPHPUnitAbstract class AbstractCheckerTester extends AbstractChecker { - public static function getMessage() + public static function getMessage(TranslatorInterface $translator) { } diff --git a/tests/Alchemy/Tests/Phrasea/Border/Checker/ColorspaceTest.php b/tests/Alchemy/Tests/Phrasea/Border/Checker/ColorspaceTest.php index d6722160b7..e9750ba81f 100644 --- a/tests/Alchemy/Tests/Phrasea/Border/Checker/ColorspaceTest.php +++ b/tests/Alchemy/Tests/Phrasea/Border/Checker/ColorspaceTest.php @@ -51,7 +51,7 @@ class ColorspaceTest extends \PhraseanetPHPUnitAbstract */ public function testGetMessage() { - $this->assertInternalType('string', $this->object->getMessage()); + $this->assertInternalType('string', $this->object->getMessage($this->createTranslatorMock())); } /** diff --git a/tests/Alchemy/Tests/Phrasea/Border/Checker/DimensionTest.php b/tests/Alchemy/Tests/Phrasea/Border/Checker/DimensionTest.php index dab2bca660..0466e7dc14 100644 --- a/tests/Alchemy/Tests/Phrasea/Border/Checker/DimensionTest.php +++ b/tests/Alchemy/Tests/Phrasea/Border/Checker/DimensionTest.php @@ -111,7 +111,7 @@ class DimensionTest extends \PhraseanetPHPUnitAbstract */ public function testGetMessage() { - $this->assertInternalType('string', Dimension::getMessage()); + $this->assertInternalType('string', Dimension::getMessage($this->createTranslatorMock())); } /** diff --git a/tests/Alchemy/Tests/Phrasea/Border/Checker/ExtensionTest.php b/tests/Alchemy/Tests/Phrasea/Border/Checker/ExtensionTest.php index 5a8e9992d2..6369b30f1c 100644 --- a/tests/Alchemy/Tests/Phrasea/Border/Checker/ExtensionTest.php +++ b/tests/Alchemy/Tests/Phrasea/Border/Checker/ExtensionTest.php @@ -63,7 +63,7 @@ class ExtensionTest extends \PhraseanetPHPUnitAbstract */ public function testGetMessage() { - $this->assertInternalType('string', $this->object->getMessage()); + $this->assertInternalType('string', $this->object->getMessage($this->createTranslatorMock())); } /** diff --git a/tests/Alchemy/Tests/Phrasea/Border/Checker/FilenameTest.php b/tests/Alchemy/Tests/Phrasea/Border/Checker/FilenameTest.php index 8cf56ff7fc..70e37f90f9 100644 --- a/tests/Alchemy/Tests/Phrasea/Border/Checker/FilenameTest.php +++ b/tests/Alchemy/Tests/Phrasea/Border/Checker/FilenameTest.php @@ -105,6 +105,6 @@ class FilenameTest extends \PhraseanetPHPUnitAbstract */ public function testGetMessage() { - $this->assertInternalType('string', $this->object->getMessage()); + $this->assertInternalType('string', $this->object->getMessage($this->createTranslatorMock())); } } diff --git a/tests/Alchemy/Tests/Phrasea/Border/Checker/MediaTypeTest.php b/tests/Alchemy/Tests/Phrasea/Border/Checker/MediaTypeTest.php index 809f7effb6..5d9d0cf532 100644 --- a/tests/Alchemy/Tests/Phrasea/Border/Checker/MediaTypeTest.php +++ b/tests/Alchemy/Tests/Phrasea/Border/Checker/MediaTypeTest.php @@ -47,7 +47,7 @@ class MediaTypeTest extends \PhraseanetPHPUnitAbstract */ public function testGetMessage() { - $this->assertInternalType('string', $this->object->getMessage()); + $this->assertInternalType('string', $this->object->getMessage($this->createTranslatorMock())); } /** diff --git a/tests/Alchemy/Tests/Phrasea/Border/Checker/ResponseTest.php b/tests/Alchemy/Tests/Phrasea/Border/Checker/ResponseTest.php index 0a88ca669e..a06054faf3 100644 --- a/tests/Alchemy/Tests/Phrasea/Border/Checker/ResponseTest.php +++ b/tests/Alchemy/Tests/Phrasea/Border/Checker/ResponseTest.php @@ -3,9 +3,12 @@ namespace Alchemy\Tests\Phrasea\Border\Checker; use Alchemy\Phrasea\Border\Checker\Response; +use Alchemy\Tests\Tools\TranslatorMockTrait; class ResponseTest extends \PHPUnit_Framework_TestCase { + use TranslatorMockTrait; + protected $mock; protected $object; @@ -61,6 +64,6 @@ class ResponseTest extends \PHPUnit_Framework_TestCase $this->object = new Response(true, $this->mock); - $this->assertEquals('Hello World', $this->object->getMessage()); + $this->assertEquals('Hello World', $this->object->getMessage($this->createTranslatorMock())); } } diff --git a/tests/Alchemy/Tests/Phrasea/Border/Checker/Sha256Test.php b/tests/Alchemy/Tests/Phrasea/Border/Checker/Sha256Test.php index f77e5b91af..de4559dfb8 100644 --- a/tests/Alchemy/Tests/Phrasea/Border/Checker/Sha256Test.php +++ b/tests/Alchemy/Tests/Phrasea/Border/Checker/Sha256Test.php @@ -83,6 +83,6 @@ class Sha256Test extends \PhraseanetPHPUnitAbstract */ public function testGetMessage() { - $this->assertInternalType('string', $this->object->getMessage()); + $this->assertInternalType('string', $this->object->getMessage($this->createTranslatorMock())); } } diff --git a/tests/Alchemy/Tests/Phrasea/Border/Checker/UUIDTest.php b/tests/Alchemy/Tests/Phrasea/Border/Checker/UUIDTest.php index 95ec65168c..20a8a6290c 100644 --- a/tests/Alchemy/Tests/Phrasea/Border/Checker/UUIDTest.php +++ b/tests/Alchemy/Tests/Phrasea/Border/Checker/UUIDTest.php @@ -69,6 +69,6 @@ class UUIDTest extends \PhraseanetPHPUnitAbstract */ public function testGetMessage() { - $this->assertInternalType('string', $this->object->getMessage()); + $this->assertInternalType('string', $this->object->getMessage($this->createTranslatorMock())); } } diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Admin/ConnectedUserTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Admin/ConnectedUserTest.php index 9338175b52..3ab8d2d786 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Admin/ConnectedUserTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Admin/ConnectedUserTest.php @@ -22,10 +22,9 @@ class ConnectedUserTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testAppName() { - $appNameResult = ConnectedUsers::appName(1000); + $appNameResult = ConnectedUsers::appName(self::$DI['app']['translator'], 1000); $this->assertNull($appNameResult); - $appNameResult = ConnectedUsers::appName(0); + $appNameResult = ConnectedUsers::appName(self::$DI['app']['translator'], 0); $this->assertTrue(is_string($appNameResult)); } - } diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Admin/SubdefsTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Admin/SubdefsTest.php index b916b52e50..c56783e8b9 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Admin/SubdefsTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Admin/SubdefsTest.php @@ -41,8 +41,7 @@ class ControllerSubdefsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract ]]); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); - $subdefs = new \databox_subdefsStructure(new \databox(self::$DI['app'], $this->databox->get_sbas_id())); - $subdef = $subdefs->get_subdef("image", $name); + $subdefs = new \databox_subdefsStructure(new \databox(self::$DI['app'], $this->databox->get_sbas_id()), self::$DI['app']['translator']); $subdefs->delete_subdef('image', $name); } @@ -82,7 +81,7 @@ class ControllerSubdefsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract ); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); - $subdefs = new \databox_subdefsStructure(new \databox(self::$DI['app'], $this->databox->get_sbas_id())); + $subdefs = new \databox_subdefsStructure(new \databox(self::$DI['app'], $this->databox->get_sbas_id()), self::$DI['app']['translator']); $subdef = $subdefs->get_subdef("image", $name); /* @var $subdef \databox_subdef */ diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/BridgeTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/BridgeTest.php index 000b6bccc4..a404da3c10 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/BridgeTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/BridgeTest.php @@ -55,7 +55,7 @@ class BridgeApplication extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testLogin() { self::$DI['client']->request('GET', '/prod/bridge/login/Apitest/'); - $test = new \Bridge_Api_Apitest(self::$DI['app']['url_generator'], self::$DI['app']['phraseanet.registry'], new \Bridge_Api_Auth_None()); + $test = new \Bridge_Api_Apitest(self::$DI['app']['url_generator'], self::$DI['app']['phraseanet.registry'], new \Bridge_Api_Auth_None(), self::$DI['app']['translator']); $this->assertTrue(self::$DI['client']->getResponse()->getStatusCode() == 302); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect($test->get_auth_url())); } diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/ToolsTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/ToolsTest.php index e1ae51053e..6e97d94186 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/ToolsTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/ToolsTest.php @@ -40,7 +40,7 @@ class ControllerToolsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $response = self::$DI['client']->getResponse(); $message = trim($crawler->filterXPath('//div')->text()); $this->assertEquals(200, $response->getStatusCode()); - $this->assertEquals(_('Document has been successfully substitued'), $message); + $this->assertEquals(self::$DI['app']['translator']->trans('Document has been successfully substitued'), $message); } public function testRouteChangeThumb() @@ -59,6 +59,6 @@ class ControllerToolsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $response = self::$DI['client']->getResponse(); $message = trim($crawler->filterXPath('//div')->text()); $this->assertEquals(200, $response->getStatusCode()); - $this->assertEquals(_('Thumbnail has been successfully substitued'), $message); + $this->assertEquals(self::$DI['app']['translator']->trans('Thumbnail has been successfully substitued'), $message); } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/ApiOauth2ErrorsSubscriberTest.php b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/ApiOauth2ErrorsSubscriberTest.php index 7e20d54766..ad8ed6d348 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/ApiOauth2ErrorsSubscriberTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/ApiOauth2ErrorsSubscriberTest.php @@ -7,9 +7,11 @@ use Alchemy\Phrasea\Core\Event\Subscriber\ApiOauth2ErrorsSubscriber; use Symfony\Component\HttpKernel\Client; use Symfony\Component\HttpKernel\Exception\HttpException; use Alchemy\Phrasea\Core\PhraseaExceptionHandler; +use Alchemy\Tests\Tools\TranslatorMockTrait; class ApiOauth2ErrorsSubscriberTest extends \PHPUnit_Framework_TestCase { + use TranslatorMockTrait; /** * @dataProvider provideExceptionsAndCode */ @@ -20,7 +22,7 @@ class ApiOauth2ErrorsSubscriberTest extends \PHPUnit_Framework_TestCase return new \API_V1_adapter($app); }; $app->register(new \API_V1_Timer()); - $app['dispatcher']->addSubscriber(new ApiOauth2ErrorsSubscriber(PhraseaExceptionHandler::register())); + $app['dispatcher']->addSubscriber(new ApiOauth2ErrorsSubscriber(PhraseaExceptionHandler::register(), $this->createTranslatorMock())); $app->get('/api/oauthv2', function () use ($exception) { throw $exception; }); @@ -43,7 +45,7 @@ class ApiOauth2ErrorsSubscriberTest extends \PHPUnit_Framework_TestCase return new \API_V1_adapter($app); }; $app->register(new \API_V1_Timer()); - $app['dispatcher']->addSubscriber(new ApiOauth2ErrorsSubscriber(PhraseaExceptionHandler::register())); + $app['dispatcher']->addSubscriber(new ApiOauth2ErrorsSubscriber(PhraseaExceptionHandler::register(), $this->createTranslatorMock())); $app->get('/', function () use ($exception) { throw $exception; }); diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/TasksServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/TasksServiceProviderTest.php index d54f16c99d..db5b7e9fad 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/TasksServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/TasksServiceProviderTest.php @@ -3,10 +3,13 @@ namespace Alchemy\Tests\Phrasea\Core\Provider; use Alchemy\Phrasea\Core\Provider\TasksServiceProvider; +use Alchemy\Tests\Tools\TranslatorMockTrait; use Silex\Application; class TasksServiceProviderTest extends ServiceProviderTestCase { + use TranslatorMockTrait; + public function provideServiceDescription() { return [ @@ -41,6 +44,7 @@ class TasksServiceProviderTest extends ServiceProviderTestCase public function testGetAvailableJobs() { $app = new Application(); + $app['translator'] = $this->createTranslatorMock(); $app->register(new TasksServiceProvider()); $app->boot(); diff --git a/tests/Alchemy/Tests/Phrasea/Media/Subdef/AudioTest.php b/tests/Alchemy/Tests/Phrasea/Media/Subdef/AudioTest.php index be82cc5680..0ee38b171e 100644 --- a/tests/Alchemy/Tests/Phrasea/Media/Subdef/AudioTest.php +++ b/tests/Alchemy/Tests/Phrasea/Media/Subdef/AudioTest.php @@ -4,9 +4,12 @@ namespace Alchemy\Tests\Phrasea\Media\Subdef; use Alchemy\Phrasea\Media\Subdef\Audio; use Alchemy\Phrasea\Media\Subdef\Subdef; +use Alchemy\Tests\Tools\TranslatorMockTrait; class AudioTest extends \PHPUnit_Framework_TestCase { + use TranslatorMockTrait; + /** * @var Audio */ @@ -14,7 +17,7 @@ class AudioTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->object = new Audio(); + $this->object = new Audio($this->createTranslatorMock()); } /** diff --git a/tests/Alchemy/Tests/Phrasea/Media/Subdef/FlexPaperTest.php b/tests/Alchemy/Tests/Phrasea/Media/Subdef/FlexPaperTest.php index 903b728d7b..7e1e74df0a 100644 --- a/tests/Alchemy/Tests/Phrasea/Media/Subdef/FlexPaperTest.php +++ b/tests/Alchemy/Tests/Phrasea/Media/Subdef/FlexPaperTest.php @@ -4,9 +4,12 @@ namespace Alchemy\Tests\Phrasea\Media\Subdef; use Alchemy\Phrasea\Media\Subdef\FlexPaper; use Alchemy\Phrasea\Media\Subdef\Subdef; +use Alchemy\Tests\Tools\TranslatorMockTrait; class FlexPaperTest extends \PHPUnit_Framework_TestCase { + use TranslatorMockTrait; + /** * @var FlexPaper */ @@ -14,7 +17,7 @@ class FlexPaperTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->object = new FlexPaper; + $this->object = new FlexPaper($this->createTranslatorMock()); } /** diff --git a/tests/Alchemy/Tests/Phrasea/Media/Subdef/GifTest.php b/tests/Alchemy/Tests/Phrasea/Media/Subdef/GifTest.php index 30d7b56365..db0c90d33d 100644 --- a/tests/Alchemy/Tests/Phrasea/Media/Subdef/GifTest.php +++ b/tests/Alchemy/Tests/Phrasea/Media/Subdef/GifTest.php @@ -4,9 +4,12 @@ namespace Alchemy\Tests\Phrasea\Media\Subdef; use Alchemy\Phrasea\Media\Subdef\Gif; use Alchemy\Phrasea\Media\Subdef\Subdef; +use Alchemy\Tests\Tools\TranslatorMockTrait; class GifTest extends \PHPUnit_Framework_TestCase { + use TranslatorMockTrait; + /** * @var Gif */ @@ -14,7 +17,7 @@ class GifTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->object = new Gif; + $this->object = new Gif($this->createTranslatorMock()); } /** diff --git a/tests/Alchemy/Tests/Phrasea/Media/Subdef/ImageTest.php b/tests/Alchemy/Tests/Phrasea/Media/Subdef/ImageTest.php index c3de25c238..84ef3a669f 100644 --- a/tests/Alchemy/Tests/Phrasea/Media/Subdef/ImageTest.php +++ b/tests/Alchemy/Tests/Phrasea/Media/Subdef/ImageTest.php @@ -4,9 +4,12 @@ namespace Alchemy\Tests\Phrasea\Media\Subdef; use Alchemy\Phrasea\Media\Subdef\Image; use Alchemy\Phrasea\Media\Subdef\Subdef; +use Alchemy\Tests\Tools\TranslatorMockTrait; class ImageTest extends \PHPUnit_Framework_TestCase { + use TranslatorMockTrait; + /** * @var Image */ @@ -14,7 +17,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->object = new Image; + $this->object = new Image($this->createTranslatorMock()); } /** diff --git a/tests/Alchemy/Tests/Phrasea/Media/Subdef/ProviderTest.php b/tests/Alchemy/Tests/Phrasea/Media/Subdef/ProviderTest.php index 823d5babed..16904a4213 100644 --- a/tests/Alchemy/Tests/Phrasea/Media/Subdef/ProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Media/Subdef/ProviderTest.php @@ -4,9 +4,12 @@ namespace Alchemy\Tests\Phrasea\Media\Subdef; use Alchemy\Phrasea\Media\Subdef\Provider; use Alchemy\Phrasea\Media\Subdef\Image; +use Alchemy\Tests\Tools\TranslatorMockTrait; class ProviderTest extends \PHPUnit_Framework_TestCase { + use TranslatorMockTrait; + /** * @var Provider */ @@ -14,7 +17,7 @@ class ProviderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->object = new Image; + $this->object = new Image($this->createTranslatorMock()); } /** diff --git a/tests/Alchemy/Tests/Phrasea/Media/Subdef/VideoTest.php b/tests/Alchemy/Tests/Phrasea/Media/Subdef/VideoTest.php index bd60d0b088..d290f6ad0c 100644 --- a/tests/Alchemy/Tests/Phrasea/Media/Subdef/VideoTest.php +++ b/tests/Alchemy/Tests/Phrasea/Media/Subdef/VideoTest.php @@ -4,9 +4,12 @@ namespace Alchemy\Tests\Phrasea\Media\Subdef; use Alchemy\Phrasea\Media\Subdef\Video; use Alchemy\Phrasea\Media\Subdef\Subdef; +use Alchemy\Tests\Tools\TranslatorMockTrait; class VideoTest extends \PHPUnit_Framework_TestCase { + use TranslatorMockTrait; + /** * @var Video */ @@ -14,7 +17,7 @@ class VideoTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->object = new Video; + $this->object = new Video($this->createTranslatorMock()); } /** diff --git a/tests/Alchemy/Tests/Phrasea/Model/Entities/UserTest.php b/tests/Alchemy/Tests/Phrasea/Model/Entities/UserTest.php index 9db8335125..c2a8203b8e 100644 --- a/tests/Alchemy/Tests/Phrasea/Model/Entities/UserTest.php +++ b/tests/Alchemy/Tests/Phrasea/Model/Entities/UserTest.php @@ -84,15 +84,15 @@ class UserTest extends \PhraseanetPHPUnitAbstract $this->user->setFirstName('firstname'); $this->user->setLastName('lastname'); $this->user->setEmail('email@email.com'); - $this->assertEquals($this->user->getDisplayName(), 'firstname lastname'); + $this->assertEquals($this->user->getDisplayName(self::$DI['app']['translator']), 'firstname lastname'); $this->user->setLastName(''); - $this->assertEquals($this->user->getDisplayName(), 'firstname'); + $this->assertEquals($this->user->getDisplayName(self::$DI['app']['translator']), 'firstname'); $this->user->setFirstName(''); - $this->assertEquals($this->user->getDisplayName(), 'email@email.com'); + $this->assertEquals($this->user->getDisplayName(self::$DI['app']['translator']), 'email@email.com'); $this->user->setEmail(null); - $this->assertEquals($this->user->getDisplayName(), 'Unnamed user'); + $this->assertEquals($this->user->getDisplayName(self::$DI['app']['translator']), 'Unnamed user'); $this->user->setLastName('lastname'); - $this->assertEquals($this->user->getDisplayName(), 'lastname'); + $this->assertEquals($this->user->getDisplayName(self::$DI['app']['translator']), 'lastname'); } public function testIsTemplate() diff --git a/tests/Alchemy/Tests/Phrasea/Model/Manipulator/TaskManipulatorTest.php b/tests/Alchemy/Tests/Phrasea/Model/Manipulator/TaskManipulatorTest.php index 4d952cb19a..6860cfc726 100644 --- a/tests/Alchemy/Tests/Phrasea/Model/Manipulator/TaskManipulatorTest.php +++ b/tests/Alchemy/Tests/Phrasea/Model/Manipulator/TaskManipulatorTest.php @@ -15,7 +15,7 @@ class TaskManipulatorTest extends \PhraseanetPHPUnitAbstract ->method('notify') ->with(Notifier::MESSAGE_CREATE); - $manipulator = new TaskManipulator(self::$DI['app']['EM'], $notifier); + $manipulator = new TaskManipulator(self::$DI['app']['EM'], $notifier, self::$DI['app']['translator']); $this->assertCount(0, $this->findAllTasks()); $task = $manipulator->create('prout', 'bla bla', 'super settings', 0); $this->assertEquals('prout', $task->getName()); @@ -34,7 +34,7 @@ class TaskManipulatorTest extends \PhraseanetPHPUnitAbstract ->method('notify') ->with(Notifier::MESSAGE_UPDATE); - $manipulator = new TaskManipulator(self::$DI['app']['EM'], $notifier); + $manipulator = new TaskManipulator(self::$DI['app']['EM'], $notifier, self::$DI['app']['translator']); $task = $this->loadTask(); $task->setName('new name'); $this->assertSame($task, $manipulator->update($task)); @@ -49,7 +49,7 @@ class TaskManipulatorTest extends \PhraseanetPHPUnitAbstract ->method('notify') ->with(Notifier::MESSAGE_DELETE); - $manipulator = new TaskManipulator(self::$DI['app']['EM'], $notifier); + $manipulator = new TaskManipulator(self::$DI['app']['EM'], $notifier, self::$DI['app']['translator']); $task = $this->loadTask(); $manipulator->delete($task); $this->assertEquals([], $this->findAllTasks()); @@ -62,7 +62,7 @@ class TaskManipulatorTest extends \PhraseanetPHPUnitAbstract ->method('notify') ->with(Notifier::MESSAGE_UPDATE); - $manipulator = new TaskManipulator(self::$DI['app']['EM'], $notifier); + $manipulator = new TaskManipulator(self::$DI['app']['EM'], $notifier, self::$DI['app']['translator']); $task = $this->loadTask(); $task->setStatus(Task::STATUS_STOPPED); self::$DI['app']['EM']->persist($task); @@ -78,7 +78,7 @@ class TaskManipulatorTest extends \PhraseanetPHPUnitAbstract ->method('notify') ->with(Notifier::MESSAGE_UPDATE); - $manipulator = new TaskManipulator(self::$DI['app']['EM'], $notifier); + $manipulator = new TaskManipulator(self::$DI['app']['EM'], $notifier, self::$DI['app']['translator']); $task = $this->loadTask(); $task->setStatus(Task::STATUS_STARTED); self::$DI['app']['EM']->persist($task); @@ -94,7 +94,7 @@ class TaskManipulatorTest extends \PhraseanetPHPUnitAbstract ->method('notify') ->with(Notifier::MESSAGE_UPDATE); - $manipulator = new TaskManipulator(self::$DI['app']['EM'], $notifier); + $manipulator = new TaskManipulator(self::$DI['app']['EM'], $notifier, self::$DI['app']['translator']); $task = $this->loadTask(); $task->setCrashed(42); $manipulator->resetCrashes($task); @@ -103,7 +103,7 @@ class TaskManipulatorTest extends \PhraseanetPHPUnitAbstract public function testGetRepository() { - $manipulator = new TaskManipulator(self::$DI['app']['EM'], $this->createNotifierMock()); + $manipulator = new TaskManipulator(self::$DI['app']['EM'], $this->createNotifierMock(), self::$DI['app']['translator']); $this->assertSame(self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Task'), $manipulator->getRepository()); } @@ -116,7 +116,7 @@ class TaskManipulatorTest extends \PhraseanetPHPUnitAbstract ->method('get_base_id') ->will($this->returnValue(42)); - $manipulator = new TaskManipulator(self::$DI['app']['EM'], $this->createNotifierMock()); + $manipulator = new TaskManipulator(self::$DI['app']['EM'], $this->createNotifierMock(), self::$DI['app']['translator']); $task = $manipulator->createEmptyCollectionJob($collection); $tasks = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Task')->findAll(); diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/ArchiveEditorTest.php b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/ArchiveEditorTest.php index 53e0d3d512..43ea6ca51b 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/ArchiveEditorTest.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/ArchiveEditorTest.php @@ -66,6 +66,6 @@ class ArchiveEditorTest extends EditorTestCase protected function getEditor() { - return new ArchiveEditor(); + return new ArchiveEditor($this->createTranslatorMock()); } } diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/DefaultEditorTest.php b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/DefaultEditorTest.php index e899302a2e..8bca23a2ef 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/DefaultEditorTest.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/DefaultEditorTest.php @@ -30,6 +30,6 @@ class DefaultEditorTest extends EditorTestCase protected function getEditor() { - return new DefaultEditor(); + return new DefaultEditor($this->createTranslatorMock()); } } diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/FtpEditorTest.php b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/FtpEditorTest.php index 3b9fb7e7b0..b3a07df858 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/FtpEditorTest.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/FtpEditorTest.php @@ -41,6 +41,6 @@ class FtpEditorTest extends EditorTestCase protected function getEditor() { - return new FtpEditor(); + return new FtpEditor($this->createTranslatorMock()); } } diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/FtpPullEditorTest.php b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/FtpPullEditorTest.php index 850c702850..35a094ba95 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/FtpPullEditorTest.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/FtpPullEditorTest.php @@ -57,6 +57,6 @@ class FtpPullEditorTest extends EditorTestCase protected function getEditor() { - return new FtpPullEditor(); + return new FtpPullEditor($this->createTranslatorMock()); } } diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/PhraseanetIndexerEditorTest.php b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/PhraseanetIndexerEditorTest.php index 0ac1a866c3..55265be5c1 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/PhraseanetIndexerEditorTest.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/PhraseanetIndexerEditorTest.php @@ -77,6 +77,6 @@ class PhraseanetIndexerEditorTest extends EditorTestCase protected function getEditor() { - return new PhraseanetIndexerEditor(); + return new PhraseanetIndexerEditor($this->createTranslatorMock()); } } diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/RecordMoverEditorTest.php b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/RecordMoverEditorTest.php index 1e3ca58d1f..c78e5628b2 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/RecordMoverEditorTest.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/RecordMoverEditorTest.php @@ -40,7 +40,7 @@ class RecordMoverEditorTest extends EditorTestCase protected function getEditor() { - return new RecordMoverEditor(); + return new RecordMoverEditor($this->createTranslatorMock()); } /** diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/SubdefsEditorTest.php b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/SubdefsEditorTest.php index d29ae2a3e1..c4d4539d39 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/SubdefsEditorTest.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/SubdefsEditorTest.php @@ -40,6 +40,6 @@ class SubdefsEditorTest extends EditorTestCase protected function getEditor() { - return new SubdefsEditor(); + return new SubdefsEditor($this->createTranslatorMock()); } } diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/WriteMetadataEditorTest.php b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/WriteMetadataEditorTest.php index 5cd16f97f4..666b0493bb 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/WriteMetadataEditorTest.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/WriteMetadataEditorTest.php @@ -40,6 +40,6 @@ class WriteMetadataEditorTest extends EditorTestCase protected function getEditor() { - return new WriteMetadataEditor(); + return new WriteMetadataEditor($this->createTranslatorMock()); } } diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/Job/ArchiveJobTest.php b/tests/Alchemy/Tests/Phrasea/TaskManager/Job/ArchiveJobTest.php index b79e5c5b4a..f314bc1c38 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/Job/ArchiveJobTest.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/Job/ArchiveJobTest.php @@ -8,6 +8,6 @@ class ArchiveJobTest extends JobTestCase { protected function getJob() { - return new ArchiveJob(); + return new ArchiveJob(null, null, $this->createTranslatorMock()); } } diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/Job/BridgeJobTest.php b/tests/Alchemy/Tests/Phrasea/TaskManager/Job/BridgeJobTest.php index 410ed3db55..f453c48436 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/Job/BridgeJobTest.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/Job/BridgeJobTest.php @@ -8,6 +8,6 @@ class BridgeJobTest extends JobTestCase { protected function getJob() { - return new BridgeJob(); + return new BridgeJob(null, null, $this->createTranslatorMock()); } } diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/Job/EmptyCollectionJobTest.php b/tests/Alchemy/Tests/Phrasea/TaskManager/Job/EmptyCollectionJobTest.php index f860ce752a..4656e0c041 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/Job/EmptyCollectionJobTest.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/Job/EmptyCollectionJobTest.php @@ -8,6 +8,6 @@ class EmptyCollectionJobTest extends JobTestCase { protected function getJob() { - return new EmptyCollectionJob(); + return new EmptyCollectionJob(null, null, $this->createTranslatorMock()); } } diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/Job/FactoryTest.php b/tests/Alchemy/Tests/Phrasea/TaskManager/Job/FactoryTest.php index dc6a737798..0462dce599 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/Job/FactoryTest.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/Job/FactoryTest.php @@ -11,7 +11,7 @@ class FactoryTest extends \PHPUnit_Framework_TestCase */ public function testWithValidClass($fqn) { - $factory = new Factory($this->createDispatcherMock(), $this->createLoggerMock()); + $factory = new Factory($this->createDispatcherMock(), $this->createLoggerMock(), $this->createTranslatorMock()); $this->assertInstanceOf($fqn, $factory->create($fqn)); } @@ -20,7 +20,7 @@ class FactoryTest extends \PHPUnit_Framework_TestCase */ public function testWithValidId($id, $fqn) { - $factory = new Factory($this->createDispatcherMock(), $this->createLoggerMock()); + $factory = new Factory($this->createDispatcherMock(), $this->createLoggerMock(), $this->createTranslatorMock()); $this->assertInstanceOf($fqn, $factory->create($id)); } @@ -43,22 +43,22 @@ class FactoryTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException Alchemy\Phrasea\Exception\InvalidArgumentException + * @expectedException \Alchemy\Phrasea\Exception\InvalidArgumentException * @expectedExceptionMessage Class `Alchemy\Phrasea\Application` does not implement JobInterface. */ public function testWithInvalidClass() { - $factory = new Factory($this->createDispatcherMock(), $this->createLoggerMock()); + $factory = new Factory($this->createDispatcherMock(), $this->createLoggerMock(), $this->createTranslatorMock()); $factory->create('Alchemy\Phrasea\Application'); } /** - * @expectedException Alchemy\Phrasea\Exception\InvalidArgumentException + * @expectedException \Alchemy\Phrasea\Exception\InvalidArgumentException * @expectedExceptionMessage Job `I\Dont\Know\This\Class` not found. */ public function testWithNonExistentClass() { - $factory = new Factory($this->createDispatcherMock(), $this->createLoggerMock()); + $factory = new Factory($this->createDispatcherMock(), $this->createLoggerMock(), $this->createTranslatorMock()); $factory->create('I\Dont\Know\This\Class'); } @@ -71,4 +71,9 @@ class FactoryTest extends \PHPUnit_Framework_TestCase { return $this->getMock('Psr\Log\LoggerInterface'); } + + private function createTranslatorMock() + { + return $this->getMock('Symfony\Component\Translation\TranslatorInterface'); + } } diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/Job/FtpJobTest.php b/tests/Alchemy/Tests/Phrasea/TaskManager/Job/FtpJobTest.php index 8b5589ae3e..9daf14576e 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/Job/FtpJobTest.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/Job/FtpJobTest.php @@ -8,6 +8,6 @@ class FtpJobTest extends JobTestCase { protected function getJob() { - return new FtpJob(); + return new FtpJob(null, null, $this->createTranslatorMock()); } } diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/Job/FtpPullJobTest.php b/tests/Alchemy/Tests/Phrasea/TaskManager/Job/FtpPullJobTest.php index 8eff75af1e..739a60a05b 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/Job/FtpPullJobTest.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/Job/FtpPullJobTest.php @@ -8,6 +8,6 @@ class FtpPullJobTest extends JobTestCase { protected function getJob() { - return new FtpPullJob(); + return new FtpPullJob(null, null, $this->createTranslatorMock()); } } diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/Job/JobTestCase.php b/tests/Alchemy/Tests/Phrasea/TaskManager/Job/JobTestCase.php index 561c39794a..d56edf4b81 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/Job/JobTestCase.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/Job/JobTestCase.php @@ -13,7 +13,7 @@ abstract class JobTestCase extends \PhraseanetPHPUnitAbstract $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); $logger = $this->getMock('Psr\Log\LoggerInterface'); - $factory = new Factory($dispatcher, $logger); + $factory = new Factory($dispatcher, $logger, $this->createTranslatorMock()); $job = $this->getJob(); $this->assertEquals(get_class($job), get_class($factory->create($job->getJobId()))); } @@ -45,7 +45,7 @@ abstract class JobTestCase extends \PhraseanetPHPUnitAbstract } /** - * @expectedException Alchemy\Phrasea\Exception\InvalidArgumentException + * @expectedException \Alchemy\Phrasea\Exception\InvalidArgumentException * @expectedExceptionMessage JobData must be passed to a JobInterface::Run command. */ public function testRunningTheJobWithWrongValueThrowsAnException() diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/Job/NullJobTest.php b/tests/Alchemy/Tests/Phrasea/TaskManager/Job/NullJobTest.php index ce7ca780f2..32e0e251b7 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/Job/NullJobTest.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/Job/NullJobTest.php @@ -8,6 +8,6 @@ class NullJobTest extends JobTestCase { protected function getJob() { - return new NullJob(); + return new NullJob(null, null, $this->createTranslatorMock()); } } diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/Job/PhraseanetIndexerJobTest.php b/tests/Alchemy/Tests/Phrasea/TaskManager/Job/PhraseanetIndexerJobTest.php index 666d809b5b..d7814bdc6f 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/Job/PhraseanetIndexerJobTest.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/Job/PhraseanetIndexerJobTest.php @@ -8,6 +8,6 @@ class PhraseanetIndexerJobTest extends JobTestCase { protected function getJob() { - return new PhraseanetIndexerJob(); + return new PhraseanetIndexerJob(null, null, $this->createTranslatorMock()); } } diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/Job/RecordMoverJobTest.php b/tests/Alchemy/Tests/Phrasea/TaskManager/Job/RecordMoverJobTest.php index cad019612e..2b692c007b 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/Job/RecordMoverJobTest.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/Job/RecordMoverJobTest.php @@ -8,6 +8,6 @@ class RecordMoverJobTest extends JobTestCase { protected function getJob() { - return new RecordMoverJob(); + return new RecordMoverJob(null, null, $this->createTranslatorMock()); } } diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/Job/SubdefsJobTest.php b/tests/Alchemy/Tests/Phrasea/TaskManager/Job/SubdefsJobTest.php index fd46263c66..734bf5df54 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/Job/SubdefsJobTest.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/Job/SubdefsJobTest.php @@ -10,7 +10,7 @@ class SubdefsJobTest extends JobTestCase { protected function getJob() { - return new SubdefsJob(); + return new SubdefsJob(null, null, $this->createTranslatorMock()); } public function doTestRun() diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/Job/WriteMetadataJobTest.php b/tests/Alchemy/Tests/Phrasea/TaskManager/Job/WriteMetadataJobTest.php index 89e59c6a6f..2d7f622daa 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/Job/WriteMetadataJobTest.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/Job/WriteMetadataJobTest.php @@ -10,7 +10,7 @@ class WriteMetadataJobTest extends JobTestCase { protected function getJob() { - return new WriteMetadataJob(); + return new WriteMetadataJob(null, null, $this->createTranslatorMock()); } public function doTestRun() diff --git a/tests/Alchemy/Tests/Tools/TranslatorMockTrait.php b/tests/Alchemy/Tests/Tools/TranslatorMockTrait.php new file mode 100644 index 0000000000..64d6498eca --- /dev/null +++ b/tests/Alchemy/Tests/Tools/TranslatorMockTrait.php @@ -0,0 +1,16 @@ +getMock('Symfony\Component\Translation\TranslatorInterface', ['addResource', 'trans', 'transChoice', 'setLocale', 'getLocale', 'setFallbackLocales', 'addLoader']); + $translator->expects($this->any()) + ->method('trans') + ->will($this->returnCallback(function ($id) { return $id;})); + + return $translator; + } +} diff --git a/tests/classes/Bridge/Api/Bridge_Api_AbstractTest.php b/tests/classes/Bridge/Api/Bridge_Api_AbstractTest.php index 21a3280407..7893943a8b 100644 --- a/tests/classes/Bridge/Api/Bridge_Api_AbstractTest.php +++ b/tests/classes/Bridge/Api/Bridge_Api_AbstractTest.php @@ -19,7 +19,7 @@ class Bridge_Api_AbstractTest extends PhraseanetWebTestCaseAbstract { parent::setUp(); $this->auth = $this->getMock("Bridge_Api_Auth_Interface"); - $this->bridgeApi = $this->getMock('Bridge_Api_Abstract', ["is_configured", "initialize_transport", "set_auth_params", "set_transport_authentication_params"], [self::$DI['app']['url_generator'], self::$DI['app']['phraseanet.registry'], $this->auth, "Mock_Bridge_Api_Abstract"]); + $this->bridgeApi = $this->getMock('Bridge_Api_Abstract', ["is_configured", "initialize_transport", "set_auth_params", "set_transport_authentication_params"], [self::$DI['app']['url_generator'], self::$DI['app']['phraseanet.registry'], $this->auth, self::$DI['app']['translator']]); } public static function setUpBeforeClass() diff --git a/tests/classes/Bridge/Bridge_datas.inc b/tests/classes/Bridge/Bridge_datas.inc index 594ae3fbf8..a3881c1d09 100644 --- a/tests/classes/Bridge/Bridge_datas.inc +++ b/tests/classes/Bridge/Bridge_datas.inc @@ -1,6 +1,7 @@ createTranslatorMock(); $app['debug'] = true; diff --git a/tests/classes/databox/databox_subdefTest.php b/tests/classes/databox/databox_subdefTest.php index 1977331285..55f384ceab 100644 --- a/tests/classes/databox/databox_subdefTest.php +++ b/tests/classes/databox/databox_subdefTest.php @@ -34,7 +34,7 @@ class databox_subdefTest extends PHPUnit_Framework_TestCase '; $type = new \Alchemy\Phrasea\Media\Type\Image(); - $object = new databox_subdef($type, simplexml_load_string($xml)); + $object = new databox_subdef($type, simplexml_load_string($xml), $this->getMock('Symfony\Component\Translation\TranslatorInterface')); $this->assertEquals(databox_subdef::CLASS_PREVIEW, $object->get_class()); $this->assertEquals('/home/datas/noweb/db_alch_phrasea/subdefs/', $object->get_path()); @@ -103,7 +103,7 @@ class databox_subdefTest extends PHPUnit_Framework_TestCase '; $type = new \Alchemy\Phrasea\Media\Type\Video(); - $object = new databox_subdef($type, simplexml_load_string($xml)); + $object = new databox_subdef($type, simplexml_load_string($xml), $this->getMock('Symfony\Component\Translation\TranslatorInterface')); $this->assertEquals(databox_subdef::CLASS_THUMBNAIL, $object->get_class()); $this->assertEquals('/home/datas/noweb/db_alch_phrasea/video/', $object->get_path()); @@ -154,7 +154,7 @@ class databox_subdefTest extends PHPUnit_Framework_TestCase '; $type = new \Alchemy\Phrasea\Media\Type\Video(); - $object = new databox_subdef($type, simplexml_load_string($xml)); + $object = new databox_subdef($type, simplexml_load_string($xml), $this->getMock('Symfony\Component\Translation\TranslatorInterface')); $this->assertInstanceOf('\\MediaAlchemyst\\Specification\\Animation', $object->getSpecs()); @@ -181,7 +181,7 @@ class databox_subdefTest extends PHPUnit_Framework_TestCase '; $type = new \Alchemy\Phrasea\Media\Type\Audio(); - $object = new databox_subdef($type, simplexml_load_string($xml)); + $object = new databox_subdef($type, simplexml_load_string($xml), $this->getMock('Symfony\Component\Translation\TranslatorInterface')); $this->assertInstanceOf('\\MediaAlchemyst\\Specification\\Audio', $object->getSpecs()); @@ -208,7 +208,7 @@ class databox_subdefTest extends PHPUnit_Framework_TestCase '; $type = new \Alchemy\Phrasea\Media\Type\Flash(); - $object = new databox_subdef($type, simplexml_load_string($xml)); + $object = new databox_subdef($type, simplexml_load_string($xml), $this->getMock('Symfony\Component\Translation\TranslatorInterface')); $this->assertInstanceOf('\\MediaAlchemyst\\Specification\\Flash', $object->getSpecs()); @@ -246,9 +246,9 @@ class databox_subdefTest extends PHPUnit_Framework_TestCase $typeVideo = new \Alchemy\Phrasea\Media\Type\Video(); return [ - [new databox_subdef($typeAudio, simplexml_load_string($xmlImage))], - [new databox_subdef($typeDocument, simplexml_load_string($xmlImage))], - [new databox_subdef($typeVideo, simplexml_load_string($xmlImage))], + [new databox_subdef($typeAudio, simplexml_load_string($xmlImage), $this->getMock('Symfony\Component\Translation\TranslatorInterface'))], + [new databox_subdef($typeDocument, simplexml_load_string($xmlImage), $this->getMock('Symfony\Component\Translation\TranslatorInterface'))], + [new databox_subdef($typeVideo, simplexml_load_string($xmlImage), $this->getMock('Symfony\Component\Translation\TranslatorInterface'))], ]; } } diff --git a/tests/classes/report/connexionReportTest.php b/tests/classes/report/connexionReportTest.php index e2f106e2ec..18883947cc 100644 --- a/tests/classes/report/connexionReportTest.php +++ b/tests/classes/report/connexionReportTest.php @@ -43,14 +43,14 @@ class connexionReportTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testBuildReport() { $conf = [ - 'user' => [_('phraseanet::utilisateurs'), 1, 1, 1, 1], - 'ddate' => [_('report:: date'), 1, 0, 1, 1], - 'ip' => [_('report:: IP'), 1, 0, 0, 0], - 'appli' => [_('report:: modules'), 1, 0, 0, 0], - 'fonction' => [_('report::fonction'), 1, 1, 1, 1], - 'activite' => [_('report::activite'), 1, 1, 1, 1], - 'pays' => [_('report::pays'), 1, 1, 1, 1], - 'societe' => [_('report::societe'), 1, 1, 1, 1] + 'user' => [self::$DI['app']['translator']->trans('phraseanet::utilisateurs'), 1, 1, 1, 1], + 'ddate' => [self::$DI['app']['translator']->trans('report:: date'), 1, 0, 1, 1], + 'ip' => [self::$DI['app']['translator']->trans('report:: IP'), 1, 0, 0, 0], + 'appli' => [self::$DI['app']['translator']->trans('report:: modules'), 1, 0, 0, 0], + 'fonction' => [self::$DI['app']['translator']->trans('report::fonction'), 1, 1, 1, 1], + 'activite' => [self::$DI['app']['translator']->trans('report::activite'), 1, 1, 1, 1], + 'pays' => [self::$DI['app']['translator']->trans('report::pays'), 1, 1, 1, 1], + 'societe' => [self::$DI['app']['translator']->trans('report::societe'), 1, 1, 1, 1] ]; $nbResult = 0; diff --git a/tests/classes/report/downloadReportTest.php b/tests/classes/report/downloadReportTest.php index 1d30a3e1de..7091e691e6 100644 --- a/tests/classes/report/downloadReportTest.php +++ b/tests/classes/report/downloadReportTest.php @@ -48,16 +48,16 @@ class downloadReportTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testBuildReport() { $conf = [ - 'user' => [_('report:: utilisateurs'), 1, 1, 1, 1], - 'ddate' => [_('report:: date'), 1, 0, 1, 1], - 'record_id' => [_('report:: record id'), 1, 1, 1, 1], - 'final' => [_('phrseanet:: sous definition'), 1, 0, 1, 1], - 'coll_id' => [_('report:: collections'), 1, 0, 1, 1], - 'comment' => [_('report:: commentaire'), 1, 0, 0, 0], - 'fonction' => [_('report:: fonction'), 1, 1, 1, 1], - 'activite' => [_('report:: activite'), 1, 1, 1, 1], - 'pays' => [_('report:: pays'), 1, 1, 1, 1], - 'societe' => [_('report:: societe'), 1, 1, 1, 1] + 'user' => [self::$DI['app']['translator']->trans('report:: utilisateurs'), 1, 1, 1, 1], + 'ddate' => [self::$DI['app']['translator']->trans('report:: date'), 1, 0, 1, 1], + 'record_id' => [self::$DI['app']['translator']->trans('report:: record id'), 1, 1, 1, 1], + 'final' => [self::$DI['app']['translator']->trans('phrseanet:: sous definition'), 1, 0, 1, 1], + 'coll_id' => [self::$DI['app']['translator']->trans('report:: collections'), 1, 0, 1, 1], + 'comment' => [self::$DI['app']['translator']->trans('report:: commentaire'), 1, 0, 0, 0], + 'fonction' => [self::$DI['app']['translator']->trans('report:: fonction'), 1, 1, 1, 1], + 'activite' => [self::$DI['app']['translator']->trans('report:: activite'), 1, 1, 1, 1], + 'pays' => [self::$DI['app']['translator']->trans('report:: pays'), 1, 1, 1, 1], + 'societe' => [self::$DI['app']['translator']->trans('report:: societe'), 1, 1, 1, 1] ]; foreach ($this->ret as $sbasid => $collections) { diff --git a/tests/classes/report/filterTest.php b/tests/classes/report/filterTest.php index 42cc811106..63f5840ab4 100644 --- a/tests/classes/report/filterTest.php +++ b/tests/classes/report/filterTest.php @@ -30,14 +30,14 @@ class filterTest extends PhraseanetPHPUnitAuthenticatedAbstract public function initFilter() { $conf = [ - 'user' => [_('phraseanet::utilisateurs'), 1, 1, 1, 1], - 'ddate' => [_('report:: date'), 1, 0, 1, 1], - 'ip' => [_('report:: IP'), 1, 0, 0, 0], - 'appli' => [_('report:: modules'), 1, 0, 0, 0], - 'fonction' => [_('report::fonction'), 1, 1, 1, 1], - 'activite' => [_('report::activite'), 1, 1, 1, 1], - 'pays' => [_('report::pays'), 1, 1, 1, 1], - 'societe' => [_('report::societe'), 1, 1, 1, 1] + 'user' => [self::$DI['app']['translator']->trans('phraseanet::utilisateurs'), 1, 1, 1, 1], + 'ddate' => [self::$DI['app']['translator']->trans('report:: date'), 1, 0, 1, 1], + 'ip' => [self::$DI['app']['translator']->trans('report:: IP'), 1, 0, 0, 0], + 'appli' => [self::$DI['app']['translator']->trans('report:: modules'), 1, 0, 0, 0], + 'fonction' => [self::$DI['app']['translator']->trans('report::fonction'), 1, 1, 1, 1], + 'activite' => [self::$DI['app']['translator']->trans('report::activite'), 1, 1, 1, 1], + 'pays' => [self::$DI['app']['translator']->trans('report::pays'), 1, 1, 1, 1], + 'societe' => [self::$DI['app']['translator']->trans('report::societe'), 1, 1, 1, 1] ]; foreach ($this->ret as $sbasid => $collections) { diff --git a/tests/classes/report/questionReportTest.php b/tests/classes/report/questionReportTest.php index 87a5062a46..e06d7b6f92 100644 --- a/tests/classes/report/questionReportTest.php +++ b/tests/classes/report/questionReportTest.php @@ -46,13 +46,13 @@ class questionReportTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testBuildReport() { $conf = [ - 'user' => [_('report:: utilisateur'), 1, 1, 1, 1], - 'search' => [_('report:: question'), 1, 0, 1, 1], - 'ddate' => [_('report:: date'), 1, 0, 1, 1], - 'fonction' => [_('report:: fonction'), 1, 1, 1, 1], - 'activite' => [_('report:: activite'), 1, 1, 1, 1], - 'pays' => [_('report:: pays'), 1, 1, 1, 1], - 'societe' => [_('report:: societe'), 1, 1, 1, 1] + 'user' => [self::$DI['app']['translator']->trans('report:: utilisateur'), 1, 1, 1, 1], + 'search' => [self::$DI['app']['translator']->trans('report:: question'), 1, 0, 1, 1], + 'ddate' => [self::$DI['app']['translator']->trans('report:: date'), 1, 0, 1, 1], + 'fonction' => [self::$DI['app']['translator']->trans('report:: fonction'), 1, 1, 1, 1], + 'activite' => [self::$DI['app']['translator']->trans('report:: activite'), 1, 1, 1, 1], + 'pays' => [self::$DI['app']['translator']->trans('report:: pays'), 1, 1, 1, 1], + 'societe' => [self::$DI['app']['translator']->trans('report:: societe'), 1, 1, 1, 1] ]; foreach ($this->ret as $sbasid => $collections) {