Skip to content

Commit e112a8d

Browse files
committed
Use static message in settings to remove translation editor clutter
1 parent 5d843ec commit e112a8d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/Form/Settings/TypeSynonymRowType.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
use Symfony\Component\Form\Extension\Core\Type\TextType;
3232
use Symfony\Component\Form\FormBuilderInterface;
3333
use Symfony\Component\Intl\Locales;
34+
use Symfony\Component\Translation\StaticMessage;
3435
use Symfony\Component\Validator\Constraints as Assert;
3536
use Symfony\Contracts\Translation\TranslatorInterface;
3637

@@ -67,7 +68,9 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
6768
new Assert\NotBlank(),
6869
],
6970
'choice_label' => function (ElementTypes $choice) {
70-
return $this->translator->trans($choice->getDefaultLabelKey()) . ' (' . $this->translator->trans($choice->getDefaultPluralLabelKey()) . ')';
71+
return new StaticMessage(
72+
$this->translator->trans($choice->getDefaultLabelKey()) . ' (' . $this->translator->trans($choice->getDefaultPluralLabelKey()) . ')'
73+
);
7174
},
7275
'row_attr' => ['class' => 'mb-0'],
7376
'attr' => ['class' => 'form-select-sm'],

src/Settings/MiscSettings/IpnSuggestSettings.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
use Jbtronics\SettingsBundle\Settings\Settings;
3131
use Jbtronics\SettingsBundle\Settings\SettingsParameter;
3232
use Jbtronics\SettingsBundle\Settings\SettingsTrait;
33+
use Symfony\Component\Translation\StaticMessage;
3334
use Symfony\Component\Translation\TranslatableMessage as TM;
3435
use Symfony\Component\Validator\Constraints as Assert;
3536

@@ -43,7 +44,7 @@ class IpnSuggestSettings
4344
label: new TM("settings.misc.ipn_suggest.regex"),
4445
description: new TM("settings.misc.ipn_suggest.regex.help"),
4546
options: ['type' => StringType::class],
46-
formOptions: ['attr' => ['placeholder' => '^[A-Za-z0-9]{3,4}(?:-[A-Za-z0-9]{3,4})*-\d{4}$']],
47+
formOptions: ['attr' => ['placeholder' => new StaticMessage( '^[A-Za-z0-9]{3,4}(?:-[A-Za-z0-9]{3,4})*-\d{4}$')]],
4748
envVar: "IPN_SUGGEST_REGEX", envVarMode: EnvVarMode::OVERWRITE,
4849
)]
4950
public ?string $regex = null;

0 commit comments

Comments
 (0)