Skip to content

Commit

Permalink
bug #3195 Don't translate labels in form pages because Symfony Form d…
Browse files Browse the repository at this point in the history
…oes that (javiereguiluz)

This PR was merged into the 3.0.x-dev branch.

Discussion
----------

Don't translate labels in form pages because Symfony Form does that

Fixes #3187.

Commits
-------

c5ee8a6 Don't translate labels in form pages because Symfony Form does that
  • Loading branch information
javiereguiluz committed May 8, 2020
2 parents 0069bdb + c5ee8a6 commit 1213267
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Field/Configurator/CommonPreConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace EasyCorp\Bundle\EasyAdminBundle\Field\Configurator;

use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext;
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldConfiguratorInterface;
use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto;
Expand Down Expand Up @@ -125,6 +126,12 @@ private function buildLabelOption(FieldDto $field, string $translationDomain, ?s
return $label;
}

// don't translate labels in form-related pages because Smyfony Forms translates
// labels automatically and that causes false "translation is missing" errors
if (in_array($currentPage, [Crud::PAGE_EDIT, Crud::PAGE_NEW])) {
return $label;
}

return $this->translator->trans($label, $field->getTranslationParameters(), $translationDomain);
}

Expand Down

0 comments on commit 1213267

Please sign in to comment.