Skip to content

Commit 3459731

Browse files
committed
Show plural translation for entity type labels in synonym settings
1 parent 819a8cc commit 3459731

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

src/Form/Settings/TypeSynonymRowType.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
use Symfony\Component\Form\FormBuilderInterface;
3333
use Symfony\Component\Intl\Locales;
3434
use Symfony\Component\Validator\Constraints as Assert;
35+
use Symfony\Contracts\Translation\TranslatorInterface;
3536

3637
/**
3738
* A single translation row: data source + language + translations (singular/plural).
@@ -50,6 +51,7 @@ class TypeSynonymRowType extends AbstractType
5051

5152
public function __construct(
5253
private readonly LocalizationSettings $localizationSettings,
54+
private readonly TranslatorInterface $translator,
5355
#[Autowire(param: 'partdb.locale_menu')] private readonly array $preferredLanguagesParam,
5456
) {
5557
}
@@ -64,6 +66,9 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
6466
'constraints' => [
6567
new Assert\NotBlank(),
6668
],
69+
'choice_label' => function (ElementTypes $choice) {
70+
return $this->translator->trans($choice->getDefaultLabelKey()) . ' (' . $this->translator->trans($choice->getDefaultPluralLabelKey()) . ')';
71+
},
6772
'row_attr' => ['class' => 'mb-0'],
6873
'attr' => ['class' => 'form-select-sm'],
6974
'preferred_choices' => self::PREFERRED_TYPES

translations/messages.en.xlf

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3448,7 +3448,7 @@ Sub elements will be moved upwards.]]></target>
34483448
</notes>
34493449
<segment state="translated">
34503450
<source>group.label</source>
3451-
<target>Group:</target>
3451+
<target>Group</target>
34523452
</segment>
34533453
</unit>
34543454
<unit id="6KVtnw_" name="user.permissions">
@@ -14412,5 +14412,53 @@ Please note that this system is currently experimental, and the synonyms defined
1441214412
<target>Parts</target>
1441314413
</segment>
1441414414
</unit>
14415+
<unit id=".tjK0ju" name="project_bom_entry.labelp">
14416+
<segment>
14417+
<source>project_bom_entry.labelp</source>
14418+
<target>BOM entries</target>
14419+
</segment>
14420+
</unit>
14421+
<unit id="ftBf11d" name="part_lot.labelp">
14422+
<segment>
14423+
<source>part_lot.labelp</source>
14424+
<target>Part lots</target>
14425+
</segment>
14426+
</unit>
14427+
<unit id="UVDJmYp" name="orderdetail.labelp">
14428+
<segment>
14429+
<source>orderdetail.labelp</source>
14430+
<target>Order details</target>
14431+
</segment>
14432+
</unit>
14433+
<unit id="83AQqv." name="pricedetail.labelp">
14434+
<segment>
14435+
<source>pricedetail.labelp</source>
14436+
<target>Price details</target>
14437+
</segment>
14438+
</unit>
14439+
<unit id="4KRV2mB" name="parameter.labelp">
14440+
<segment>
14441+
<source>parameter.labelp</source>
14442+
<target>Parameters</target>
14443+
</segment>
14444+
</unit>
14445+
<unit id="AAYYeiw" name="part_association.labelp">
14446+
<segment>
14447+
<source>part_association.labelp</source>
14448+
<target>Part associations</target>
14449+
</segment>
14450+
</unit>
14451+
<unit id="2_3Lz7i" name="bulk_info_provider_import_job.labelp">
14452+
<segment>
14453+
<source>bulk_info_provider_import_job.labelp</source>
14454+
<target>Bulk info provider imports</target>
14455+
</segment>
14456+
</unit>
14457+
<unit id="BXTqi16" name="bulk_info_provider_import_job_part.labelp">
14458+
<segment>
14459+
<source>bulk_info_provider_import_job_part.labelp</source>
14460+
<target>Bulk import job part</target>
14461+
</segment>
14462+
</unit>
1441514463
</file>
1441614464
</xliff>

0 commit comments

Comments
 (0)