Skip to content

Commit

Permalink
Issue #3464971 by SV: Use entity translation to display translated te…
Browse files Browse the repository at this point in the history
…rm name
  • Loading branch information
volodymyr-sydor authored and ribel committed Aug 1, 2024
1 parent e5efe49 commit 6361c70
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\ReplaceCommand;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\FieldableEntityInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Link;
Expand Down Expand Up @@ -75,6 +76,8 @@ function social_event_type_preprocess_node(array &$variables): void {
$variables['event_type'] = NULL;
$event_type = empty($event_types) ? NULL : reset($event_types);
if ($event_type instanceof TermInterface) {
/** @var \Drupal\Core\Entity\EntityInterface $event_type */
$event_type = \Drupal::service('entity.repository')->getTranslationFromContext($event_type);
$variables['metadata'] = t('in @event', [
'@event' => $event_type->toLink()
->toString(),
Expand All @@ -93,6 +96,7 @@ function social_event_type_preprocess_node(array &$variables): void {
->toString();
$variables['event_type'] = $event_type_link;
if (
$event_type instanceof FieldableEntityInterface &&
$event_type->hasField('field_event_type_icon') &&
!$event_type->get('field_event_type_icon')->isEmpty()
) {
Expand Down

0 comments on commit 6361c70

Please sign in to comment.