From d7f4895248d91e365db1ea0c6cdd72cf1bc3177c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 14 Mar 2024 15:46:32 +0100 Subject: [PATCH 1/2] Fix the command which load language The command load the languages in the configured languages in chill's configuration. --- .changes/unreleased/Fixed-20240314-154343.yaml | 6 ++++++ .../Command/LoadAndUpdateLanguagesCommand.php | 9 +++++---- src/Bundle/ChillMainBundle/config/services/command.yaml | 3 --- .../ChillPersonBundle/translations/messages.fr.yml | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) create mode 100644 .changes/unreleased/Fixed-20240314-154343.yaml diff --git a/.changes/unreleased/Fixed-20240314-154343.yaml b/.changes/unreleased/Fixed-20240314-154343.yaml new file mode 100644 index 000000000..47fe9d598 --- /dev/null +++ b/.changes/unreleased/Fixed-20240314-154343.yaml @@ -0,0 +1,6 @@ +kind: Fixed +body: 'Fix languages: load the languages in all availables languages configured for + Chill' +time: 2024-03-14T15:43:43.396044369+01:00 +custom: + Issue: "264" diff --git a/src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php b/src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php index 860f8c82e..4c8cc4eeb 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php @@ -12,11 +12,12 @@ declare(strict_types=1); namespace Chill\MainBundle\Command; use Chill\MainBundle\Entity\Language; -use Doctrine\ORM\EntityManager; +use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Intl\Languages; /* @@ -39,7 +40,7 @@ class LoadAndUpdateLanguagesCommand extends Command /** * LoadCountriesCommand constructor. */ - public function __construct(private readonly EntityManager $entityManager, private $availableLanguages) + public function __construct(private readonly EntityManagerInterface $entityManager, private ParameterBagInterface $parameterBag) { parent::__construct(); } @@ -79,7 +80,7 @@ class LoadAndUpdateLanguagesCommand extends Command protected function execute(InputInterface $input, OutputInterface $output): int { $em = $this->entityManager; - $chillAvailableLanguages = $this->availableLanguages; + $chillAvailableLanguages = $this->parameterBag->get('chill_main.available_languages'); $languages = []; foreach ($chillAvailableLanguages as $avLang) { @@ -113,7 +114,7 @@ class LoadAndUpdateLanguagesCommand extends Command $avLangNames = []; foreach ($chillAvailableLanguages as $avLang) { - $avLangNames[$avLang] = Languages::getName($code, $avLang); + $avLangNames[$avLang] = ucfirst(Languages::getName($code, $avLang)); } $languageDB->setName($avLangNames); diff --git a/src/Bundle/ChillMainBundle/config/services/command.yaml b/src/Bundle/ChillMainBundle/config/services/command.yaml index 29d6d4bf1..8a2327c0b 100644 --- a/src/Bundle/ChillMainBundle/config/services/command.yaml +++ b/src/Bundle/ChillMainBundle/config/services/command.yaml @@ -17,9 +17,6 @@ services: - { name: console.command } Chill\MainBundle\Command\LoadAndUpdateLanguagesCommand: - arguments: - $entityManager: '@doctrine.orm.entity_manager' - $availableLanguages: '%chill_main.available_languages%' tags: - { name: console.command } diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 50c6a87d5..364218ef2 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -57,7 +57,7 @@ Add new phone: Ajouter un numéro de téléphone Remove phone: Supprimer 'Notes on contact information': 'Remarques sur les informations de contact' 'Remarks': 'Remarques' -Spoken languages': 'Langues parlées' +Spoken languages: 'Langues parlées' 'Unknown spoken languages': 'Langues parlées inconnues' Male: Homme Female: Femme From 0ff51b0a5cc2db13277995beee90d366feef8ded Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 14 Mar 2024 15:05:30 +0000 Subject: [PATCH 2/2] Force new parameter to be readonly in LoadAndUpdateLanguagesCommand constructor --- .../ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php b/src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php index 4c8cc4eeb..e4b3ae673 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php @@ -40,7 +40,7 @@ class LoadAndUpdateLanguagesCommand extends Command /** * LoadCountriesCommand constructor. */ - public function __construct(private readonly EntityManagerInterface $entityManager, private ParameterBagInterface $parameterBag) + public function __construct(private readonly EntityManagerInterface $entityManager, private readonly ParameterBagInterface $parameterBag) { parent::__construct(); }