From 3459731ca825b5ba92f64c2957ab22dbabe473ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 30 Nov 2025 14:16:54 +0100 Subject: [PATCH] Show plural translation for entity type labels in synonym settings --- src/Form/Settings/TypeSynonymRowType.php | 5 +++ translations/messages.en.xlf | 50 +++++++++++++++++++++++- 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/src/Form/Settings/TypeSynonymRowType.php b/src/Form/Settings/TypeSynonymRowType.php index 332db907..234a7691 100644 --- a/src/Form/Settings/TypeSynonymRowType.php +++ b/src/Form/Settings/TypeSynonymRowType.php @@ -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 diff --git a/translations/messages.en.xlf b/translations/messages.en.xlf index db4370f4..77169792 100644 --- a/translations/messages.en.xlf +++ b/translations/messages.en.xlf @@ -3448,7 +3448,7 @@ Sub elements will be moved upwards.]]> group.label - Group: + Group @@ -14412,5 +14412,53 @@ Please note that this system is currently experimental, and the synonyms defined Parts + + + project_bom_entry.labelp + BOM entries + + + + + part_lot.labelp + Part lots + + + + + orderdetail.labelp + Order details + + + + + pricedetail.labelp + Price details + + + + + parameter.labelp + Parameters + + + + + part_association.labelp + Part associations + + + + + bulk_info_provider_import_job.labelp + Bulk info provider imports + + + + + bulk_info_provider_import_job_part.labelp + Bulk import job part + +