From e136944ded0933d714c8f1d348b8ac5294f18529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Kalij=C3=A4rvi?= Date: Mon, 29 Jul 2024 09:09:20 +0300 Subject: [PATCH] UHF-8909: Use language manager to get current language. --- public/themes/custom/hdbt_subtheme/hdbt_subtheme.theme | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/public/themes/custom/hdbt_subtheme/hdbt_subtheme.theme b/public/themes/custom/hdbt_subtheme/hdbt_subtheme.theme index 95e213be0..78c7b8312 100644 --- a/public/themes/custom/hdbt_subtheme/hdbt_subtheme.theme +++ b/public/themes/custom/hdbt_subtheme/hdbt_subtheme.theme @@ -82,9 +82,10 @@ function hdbt_subtheme_preprocess_node(array &$variables) { continue; } $district_title = $district_node->getTitle(); - - if ($district_node->hasTranslation($variables['current_langcode'])) { - $district_title = $district_node->getTranslation($variables['current_langcode'])->getTitle(); + $language = \Drupal::languageManager() + ->getCurrentLanguage(LanguageInterface::TYPE_CONTENT); + if ($district_node->hasTranslation($language->getId())) { + $district_title = $district_node->getTranslation($language->getId())->getTitle(); } $district_titles[] = $district_title;