From b3b11a01bb8af93798a06b0afa60b6dee770351a Mon Sep 17 00:00:00 2001 From: mikolaj Date: Thu, 3 Aug 2023 09:37:58 +0200 Subject: [PATCH] Removed Acholi dialect from the list of available translations --- .../Loader/AvailableLocaleChoiceLoader.php | 7 ++++++- .../Loader/AvailableLocaleChoiceLoaderTest.php | 12 +++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/lib/Form/ChoiceList/Loader/AvailableLocaleChoiceLoader.php b/src/lib/Form/ChoiceList/Loader/AvailableLocaleChoiceLoader.php index 40d59fa..ed8f52d 100644 --- a/src/lib/Form/ChoiceList/Loader/AvailableLocaleChoiceLoader.php +++ b/src/lib/Form/ChoiceList/Loader/AvailableLocaleChoiceLoader.php @@ -17,6 +17,10 @@ class AvailableLocaleChoiceLoader implements ChoiceLoaderInterface { + // Acholi dialect is used by In-Context translation + // and should not be present on the list of available translations. + private const EXCLUDED_TRANSLATIONS = ['ach']; + /** @var \Symfony\Component\Validator\Validator\ValidatorInterface */ private $validator; @@ -47,8 +51,9 @@ public function getChoiceList(): array $additionalTranslations = $this->configResolver->getParameter('user_preferences.additional_translations'); $availableLocales = array_unique(array_merge($this->availableTranslations, $additionalTranslations)); + $locales = array_diff($availableLocales, self::EXCLUDED_TRANSLATIONS); - foreach ($availableLocales as $locale) { + foreach ($locales as $locale) { if (0 === $this->validator->validate($locale, new Locale())->count()) { $choices[Locales::getName($locale)] = $locale; } diff --git a/tests/lib/Form/Type/ChoiceList/Loader/AvailableLocaleChoiceLoaderTest.php b/tests/lib/Form/Type/ChoiceList/Loader/AvailableLocaleChoiceLoaderTest.php index 7ce363e..d8fe746 100644 --- a/tests/lib/Form/Type/ChoiceList/Loader/AvailableLocaleChoiceLoaderTest.php +++ b/tests/lib/Form/Type/ChoiceList/Loader/AvailableLocaleChoiceLoaderTest.php @@ -11,7 +11,6 @@ use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface; use Ibexa\User\Form\ChoiceList\Loader\AvailableLocaleChoiceLoader; use PHPUnit\Framework\TestCase; -use Symfony\Component\Validator\Constraints\Locale; use Symfony\Component\Validator\ConstraintViolationInterface; use Symfony\Component\Validator\ConstraintViolationList; use Symfony\Component\Validator\Validator\ValidatorInterface; @@ -21,9 +20,6 @@ class AvailableLocaleChoiceLoaderTest extends TestCase /** @var \Symfony\Component\Validator\Validator\ValidatorInterface|\PHPUnit\Framework\MockObject\MockObject */ private $validator; - /** @var \Symfony\Component\Validator\Constraints\Locale|\PHPUnit\Framework\MockObject\MockObject */ - private $localeConstraint; - /** @var \Symfony\Component\Validator\ConstraintViolationInterface|\PHPUnit\Framework\MockObject\MockObject */ private $constraintViolation; @@ -34,7 +30,6 @@ protected function setUp(): void { parent::setUp(); - $this->localeConstraint = $this->createMock(Locale::class); $this->validator = $this->createMock(ValidatorInterface::class); $this->constraintViolation = $this->createMock(ConstraintViolationInterface::class); $this->configResolver = $this->createMock(ConfigResolverInterface::class); @@ -101,6 +96,13 @@ public function providerForGetChoiceList(): array 'German (Germany)' => 'de_DE', ], ], + 'acholi_exlusion' => [ + ['en', 'ach'], + [], + [ + 'English' => 'en', + ], + ], ]; } }