mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-12-15 07:29:30 +00:00
Show plural translation for entity type labels in synonym settings
This commit is contained in:
parent
819a8cc56d
commit
3459731ca8
2 changed files with 54 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue