Skip to content

Commit

Permalink
Removed Acholi dialect from the list of available translations
Browse files Browse the repository at this point in the history
  • Loading branch information
mikadamczyk committed Sep 5, 2023
1 parent f0ec083 commit f9a8958
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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);
Expand Down Expand Up @@ -101,6 +96,13 @@ public function providerForGetChoiceList(): array
'German (Germany)' => 'de_DE',
],
],
'acholi_exlusion' => [
['en', 'ach'],
[],
[
'English' => 'en',
],
],
];
}
}
Expand Down

0 comments on commit f9a8958

Please sign in to comment.