Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed Acholi dialect from the list of available translations #58

Merged
merged 1 commit into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading