add translations

This commit is contained in:
Julien Fastré 2021-12-06 16:17:30 +01:00
parent 5a61f05faa
commit b120e47786
10 changed files with 89 additions and 16 deletions

View File

@ -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

View File

@ -0,0 +1,42 @@
<?php
namespace Chill\DocGeneratorBundle\Menu;
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
use Knp\Menu\MenuItem;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;
class AdminMenuBuilder implements LocalMenuBuilderInterface
{
private TranslatorInterface $translator;
private Security $security;
public function __construct(TranslatorInterface $translator, Security $security)
{
$this->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']];
}
}

View File

@ -5,6 +5,7 @@
{% block table_entities_thead_tr %}
<th></th>
<th>{{ 'Title'|trans }}</th>
<th>{{ 'docgen.Context'|trans }}</th>
<th>{{ 'Edit'|trans }}</th>
{% endblock %}
@ -13,6 +14,7 @@
<tr>
<td>{{ entity.id }}</td>
<td>{{ entity.name | localize_translatable_string }}</td>
<td>{{ contextManager.getContextByKey(entity.context).name|trans }}</td>
<td>
<a href="{{ chill_path_add_return_path('chill_crud_docgen_template_edit', { 'id': entity.id }) }}" class="btn btn-edit">
{{ 'Edit'|trans }}

View File

@ -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 %}
<div class="col-md-10 col-xxl">

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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