Skip to content

Commit

Permalink
bug #6126 Don't translate form values that are already translated (ja…
Browse files Browse the repository at this point in the history
…viereguiluz)

This PR was merged into the 4.x branch.

Discussion
----------

Don't translate form values that are already translated

In #6121 we fixed this problem for countries ... but other form types also pass their values translated to the template, so let's not translate any of them.

Commits
-------

584a7e6 Don't translate form values that are already translated
  • Loading branch information
javiereguiluz committed Feb 2, 2024
2 parents 66cdc15 + 584a7e6 commit 54a13f6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Field/Configurator/CurrencyConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public function supports(FieldDto $field, EntityDto $entityDto): bool
public function configure(FieldDto $field, EntityDto $entityDto, AdminContext $context): void
{
$field->setFormTypeOptionIfNotSet('attr.data-ea-widget', 'ea-autocomplete');
// currency names passed to the form are already translated, so don't translate them again in the template
$field->setFormTypeOptionIfNotSet('choice_translation_domain', false);

if (null === $currencyCode = $field->getValue()) {
return;
Expand Down
2 changes: 2 additions & 0 deletions src/Field/Configurator/LanguageConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public function configure(FieldDto $field, EntityDto $entityDto, AdminContext $c
$field->getCustomOption(LanguageField::OPTION_LANGUAGE_CODES_TO_REMOVE))
);
$field->setFormTypeOption('choice_loader', null);
// language names passed to the form are already translated, so don't translate them again in the template
$field->setFormTypeOptionIfNotSet('choice_translation_domain', false);
}

if (null === $languageCode = $field->getValue()) {
Expand Down
2 changes: 2 additions & 0 deletions src/Field/Configurator/LocaleConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public function configure(FieldDto $field, EntityDto $entityDto, AdminContext $c
if (\in_array($context->getCrud()->getCurrentPage(), [Crud::PAGE_EDIT, Crud::PAGE_NEW], true)) {
$field->setFormTypeOption('choices', $this->generateFormTypeChoices($field->getCustomOption(LocaleField::OPTION_LOCALE_CODES_TO_KEEP), $field->getCustomOption(LocaleField::OPTION_LOCALE_CODES_TO_REMOVE)));
$field->setFormTypeOption('choice_loader', null);
// locale names passed to the form are already translated, so don't translate them again in the template
$field->setFormTypeOptionIfNotSet('choice_translation_domain', false);
}

if (null === $localeCode = $field->getValue()) {
Expand Down
2 changes: 2 additions & 0 deletions src/Field/Configurator/TimezoneConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@ public function configure(FieldDto $field, EntityDto $entityDto, AdminContext $c
{
$field->setFormTypeOptionIfNotSet('attr.data-ea-widget', 'ea-autocomplete');
$field->setFormTypeOptionIfNotSet('intl', true);
// timezone names passed to the form are already translated, so don't translate them again in the template
$field->setFormTypeOptionIfNotSet('choice_translation_domain', false);
}
}

0 comments on commit 54a13f6

Please sign in to comment.