Show plural translation for entity type labels in synonym settings

This commit is contained in:
Jan Böhmer 2025-11-30 14:16:54 +01:00
parent 819a8cc56d
commit 3459731ca8
2 changed files with 54 additions and 1 deletions

View file

@ -32,6 +32,7 @@ use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Intl\Locales;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* A single translation row: data source + language + translations (singular/plural).
@ -50,6 +51,7 @@ class TypeSynonymRowType extends AbstractType
public function __construct(
private readonly LocalizationSettings $localizationSettings,
private readonly TranslatorInterface $translator,
#[Autowire(param: 'partdb.locale_menu')] private readonly array $preferredLanguagesParam,
) {
}
@ -64,6 +66,9 @@ class TypeSynonymRowType extends AbstractType
'constraints' => [
new Assert\NotBlank(),
],
'choice_label' => function (ElementTypes $choice) {
return $this->translator->trans($choice->getDefaultLabelKey()) . ' (' . $this->translator->trans($choice->getDefaultPluralLabelKey()) . ')';
},
'row_attr' => ['class' => 'mb-0'],
'attr' => ['class' => 'form-select-sm'],
'preferred_choices' => self::PREFERRED_TYPES