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

View file

@ -3448,7 +3448,7 @@ Sub elements will be moved upwards.]]></target>
</notes>
<segment state="translated">
<source>group.label</source>
<target>Group:</target>
<target>Group</target>
</segment>
</unit>
<unit id="6KVtnw_" name="user.permissions">
@ -14412,5 +14412,53 @@ Please note that this system is currently experimental, and the synonyms defined
<target>Parts</target>
</segment>
</unit>
<unit id=".tjK0ju" name="project_bom_entry.labelp">
<segment>
<source>project_bom_entry.labelp</source>
<target>BOM entries</target>
</segment>
</unit>
<unit id="ftBf11d" name="part_lot.labelp">
<segment>
<source>part_lot.labelp</source>
<target>Part lots</target>
</segment>
</unit>
<unit id="UVDJmYp" name="orderdetail.labelp">
<segment>
<source>orderdetail.labelp</source>
<target>Order details</target>
</segment>
</unit>
<unit id="83AQqv." name="pricedetail.labelp">
<segment>
<source>pricedetail.labelp</source>
<target>Price details</target>
</segment>
</unit>
<unit id="4KRV2mB" name="parameter.labelp">
<segment>
<source>parameter.labelp</source>
<target>Parameters</target>
</segment>
</unit>
<unit id="AAYYeiw" name="part_association.labelp">
<segment>
<source>part_association.labelp</source>
<target>Part associations</target>
</segment>
</unit>
<unit id="2_3Lz7i" name="bulk_info_provider_import_job.labelp">
<segment>
<source>bulk_info_provider_import_job.labelp</source>
<target>Bulk info provider imports</target>
</segment>
</unit>
<unit id="BXTqi16" name="bulk_info_provider_import_job_part.labelp">
<segment>
<source>bulk_info_provider_import_job_part.labelp</source>
<target>Bulk import job part</target>
</segment>
</unit>
</file>
</xliff>