From b120e47786e5b671e0e10b96acefba55b21a587a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 6 Dec 2021 16:17:30 +0100 Subject: [PATCH] add translations --- .../AdminDocGeneratorTemplateController.php | 17 ++++---- .../Menu/AdminMenuBuilder.php | 42 +++++++++++++++++++ .../DocGeneratorTemplate/index.html.twig | 2 + .../pick-context.html.twig | 2 +- .../config/services.yaml | 5 +++ .../translations/messages.fr.yml | 16 +++++++ .../AccompanyingPeriodContext.php | 8 ++-- .../AccompanyingPeriodWorkContext.php | 2 +- ...ccompanyingPeriodWorkEvaluationContext.php | 2 +- .../translations/messages.fr.yml | 9 +++- 10 files changed, 89 insertions(+), 16 deletions(-) create mode 100644 src/Bundle/ChillDocGeneratorBundle/Menu/AdminMenuBuilder.php diff --git a/src/Bundle/ChillDocGeneratorBundle/Controller/AdminDocGeneratorTemplateController.php b/src/Bundle/ChillDocGeneratorBundle/Controller/AdminDocGeneratorTemplateController.php index 57d4cd487..d6ec9c19c 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Controller/AdminDocGeneratorTemplateController.php +++ b/src/Bundle/ChillDocGeneratorBundle/Controller/AdminDocGeneratorTemplateController.php @@ -32,22 +32,23 @@ class AdminDocGeneratorTemplateController extends CRUDController switch ($action) { case 'new': $context = $this->contextManager->getContextByKey($request->get('context')); - - break; - case 'edit': $context = $this->contextManager->getContextByDocGeneratorTemplate($entity); - break; + return array_merge( + $defaultTemplateParameters, + ['context' => $context] + ); + case 'index': + return array_merge( + $defaultTemplateParameters, + ['contextManager' => $this->contextManager] + ); default: return parent::generateTemplateParameter($action, $entity, $request, $defaultTemplateParameters); // TODO: Change the autogenerated stub } - return array_merge( - $defaultTemplateParameters, - ['context' => $context] - ); } public function new(Request $request): Response diff --git a/src/Bundle/ChillDocGeneratorBundle/Menu/AdminMenuBuilder.php b/src/Bundle/ChillDocGeneratorBundle/Menu/AdminMenuBuilder.php new file mode 100644 index 000000000..f59389352 --- /dev/null +++ b/src/Bundle/ChillDocGeneratorBundle/Menu/AdminMenuBuilder.php @@ -0,0 +1,42 @@ +translator = $translator; + $this->security = $security; + } + + public function buildMenu($menuId, MenuItem $menu, array $parameters) + { + if ($this->security->isGranted('ROLE_ADMIN')) { + if (in_array($menuId, ['admin_index', 'admin_section'])) { + $menu->addChild($this->translator->trans('docgen.Document generation'), [ + 'route' => 'chill_crud_docgen_template_index' + ])->setExtras([ + 'order' => 350, + 'explain' => 'docgen.Manage templates and document generation' + ]); + } + } + } + + public static function getMenuIds(): array + { + return ['admin_index', 'admin_section', ['docgen_admin']]; + } + + +} diff --git a/src/Bundle/ChillDocGeneratorBundle/Resources/views/Admin/DocGeneratorTemplate/index.html.twig b/src/Bundle/ChillDocGeneratorBundle/Resources/views/Admin/DocGeneratorTemplate/index.html.twig index d98bd4811..1cdad36ff 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Resources/views/Admin/DocGeneratorTemplate/index.html.twig +++ b/src/Bundle/ChillDocGeneratorBundle/Resources/views/Admin/DocGeneratorTemplate/index.html.twig @@ -5,6 +5,7 @@ {% block table_entities_thead_tr %} {{ 'Title'|trans }} + {{ 'docgen.Context'|trans }} {{ 'Edit'|trans }} {% endblock %} @@ -13,6 +14,7 @@ {{ entity.id }} {{ entity.name | localize_translatable_string }} + {{ contextManager.getContextByKey(entity.context).name|trans }} {{ 'Edit'|trans }} diff --git a/src/Bundle/ChillDocGeneratorBundle/Resources/views/Admin/DocGeneratorTemplate/pick-context.html.twig b/src/Bundle/ChillDocGeneratorBundle/Resources/views/Admin/DocGeneratorTemplate/pick-context.html.twig index d43e88f8d..5e3ff2049 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Resources/views/Admin/DocGeneratorTemplate/pick-context.html.twig +++ b/src/Bundle/ChillDocGeneratorBundle/Resources/views/Admin/DocGeneratorTemplate/pick-context.html.twig @@ -1,6 +1,6 @@ {% extends '@ChillDocGenerator/Admin/layout.html.twig' %} -{% block title 'Pick template context'|trans %} +{% block title 'docgen.Pick template context'|trans %} {% block layout_wvm_content %}
diff --git a/src/Bundle/ChillDocGeneratorBundle/config/services.yaml b/src/Bundle/ChillDocGeneratorBundle/config/services.yaml index 011317959..10ab6d172 100644 --- a/src/Bundle/ChillDocGeneratorBundle/config/services.yaml +++ b/src/Bundle/ChillDocGeneratorBundle/config/services.yaml @@ -9,6 +9,11 @@ services: autoconfigure: true resource: '../Repository/' + Chill\DocGeneratorBundle\Menu\: + autoconfigure: true + autowire: true + resource: '../Menu/' + Chill\DocGeneratorBundle\Serializer\Normalizer\: autowire: true autoconfigure: true diff --git a/src/Bundle/ChillDocGeneratorBundle/translations/messages.fr.yml b/src/Bundle/ChillDocGeneratorBundle/translations/messages.fr.yml index ebfe5320f..af08cf1c8 100644 --- a/src/Bundle/ChillDocGeneratorBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillDocGeneratorBundle/translations/messages.fr.yml @@ -1,3 +1,19 @@ docgen: Generate a document: Génerer un document Generate: Génerer + Document generation: Génération de documents + Manage templates and document generation: Gestion des documents générés et de leurs gabarits + Pick template context: Choisir un contexte + Context: Contexte + New template: Nouveau gabarit + Edit template: Modifier gabarit + With context: 'Avec le contexte :' + + +crud: + docgen_template: + index: + title: Génération de documents + add_new: Créer + + diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php index 5bc218ce9..10431d7aa 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php @@ -102,7 +102,7 @@ class AccompanyingPeriodContext implements $builder ->add('mainPerson', CheckboxType::class, [ 'required' => false, - 'label' => 'Ask for main person', + 'label' => 'docgen.Ask for main person', ]) ->add('mainPersonLabel', TextType::class, [ 'label' => 'main person label', @@ -110,7 +110,7 @@ class AccompanyingPeriodContext implements ]) ->add('person1', CheckboxType::class, [ 'required' => false, - 'label' => 'Ask for person 1', + 'label' => 'docgen.Ask for person 1', ]) ->add('person1Label', TextType::class, [ 'label' => 'person 1 label', @@ -118,7 +118,7 @@ class AccompanyingPeriodContext implements ]) ->add('person2', CheckboxType::class, [ 'required' => false, - 'label' => 'Ask for person 2', + 'label' => 'docgen.Ask for person 2', ]) ->add('person2Label', TextType::class, [ 'label' => 'person 2 label', @@ -182,7 +182,7 @@ class AccompanyingPeriodContext implements public function getDescription(): string { - return 'A basic context for accompanying period'; + return 'docgen.A basic context for accompanying period'; } public function getEntityClass(): string diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkContext.php index 5041d9180..09d154900 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkContext.php @@ -79,7 +79,7 @@ class AccompanyingPeriodWorkContext implements public function getDescription(): string { - return 'A context for work'; + return 'docgen.A context for accompanying period work'; } public function getEntityClass(): string diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php index 2ffcaf818..9c8d6172a 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php @@ -127,7 +127,7 @@ class AccompanyingPeriodWorkEvaluationContext implements public function getDescription(): string { - return 'Context for accompanying period work'; + return 'docgen.A context for accompanying period work evaluation'; } public function getEntityClass(): string diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index af2009f3a..0ca5ce19d 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -457,4 +457,11 @@ see persons associated: Voir les usagers concernés docgen: Main person: Personne principale person 1: Première personne - person 2: Deuxième personne + person 2: Seconde personne + Ask for main person: Demander à l'utilisateur de préciser la personne principale + Ask for person 1: Demander à l'utilisateur de préciser la première personne + Ask for person 2: Demander à l'utilisateur de préciser la seconde personne + Accompanying period work: Actions + A basic context for accompanying period: Contexte pour les parcours + A context for accompanying period work: Contexte pour les actions d'accompagnement + A context for accompanying period work evaluation: Contexte pour les évaluations dans les actions d'accompagnement