Skip to content

Instantly share code, notes, and snippets.

@idimopoulos
Created March 9, 2026 18:04
Show Gist options
  • Select an option

  • Save idimopoulos/4f3a10e7e06d7d052d8011bb0461aad5 to your computer and use it in GitHub Desktop.

Select an option

Save idimopoulos/4f3a10e7e06d7d052d8011bb0461aad5 to your computer and use it in GitHub Desktop.
analysis on translations.

Summary

  • Expanded the analysis of translation-related issues to include custom themes and preprocess functions.
  • Identified several new areas where translation context is missing, particularly in theme-level logic and data attributes.
  • Added new entries for preprocess functions in custom modules.

Changes

  • No code changes were made; the output is a comprehensive analysis of the codebase.
  • Conducted a deep dive into web/themes/ventuno and web/modules/custom to find improper uses of $entity->label(), $entity->getTitle(), and other language-sensitive methods in preprocess hooks.
  • Verified that numerous preprocess functions used for building UI components (like tiles and badges) lack language awareness, which could lead to mixed-language interfaces.

Verification

  • Manual code inspection of web/themes/ventuno/includes/utility.inc and multiple *.module files in web/modules/custom.
  • Analyzed how entities are passed and processed in hook_preprocess and hook_preprocess_HOOK functions.

Notes

  • The ventuno theme is a significant source of "Low" to "Mid" risk issues where labels are extracted from entities for UI purposes without ensuring the correct translation is used.
  • joinup_group_preprocess in joinup_group.module uses parent group labels in data attributes, which may result in incorrect metadata for shared content in a multilingual environment.
  • Several custom module preprocess hooks use $entity->label() or hardcoded strings for UI elements without full translation context.
File / Line Description Risk Possible Fix
web/modules/custom/custom_page/custom_page.module (line 139) custom_page_node_update() updates all menu links' titles using $entity->getTitle(). This can overwrite translated menu link titles with the title of the translation being saved. High Load the corresponding translation of the menu link if available, or use getTranslation() on the node before setting the title.
web/modules/custom/custom_page/src/CustomPageOgMenuLinksManager.php (lines 44, 56, 114) getChildren() and moveLinks() query menu links by URI (entity:node/{$id}) without filtering by language, which can result in picking up links from all translations. Mid Add a langcode condition to the entity query to target only the relevant translation.
web/modules/custom/custom_page/src/CustomPageOgMenuLinksManager.php (line 92) addLink() creates menu links with $customPage->label() without setting langcode. Links are created in the site's default language regardless of the node's language. High Pass the $customPage->language()->getId() to the menu_link_content entity creation and use $customPage->label() from the correct translation.
web/modules/custom/eu_oss_catalogue/modules/eu_oss_translation/src/Plugin/QueueWorker/TranslationRequester.php (line 59) processItem() loads a node by ID without specifying a translation, which might lead to incorrect translation job creation. High Load the specific translation using getTranslation() or ensure the loader is language-aware.
web/modules/custom/joinup_communities/joinup_oss_catalogue/joinup_oss_catalogue.module (line 130) joinup_oss_catalogue_preprocess_field__in_modal() uses $entity->label() for a label string without ensuring it's in the correct language. Mid Use getTranslationFromContext($entity)->label().
web/modules/custom/joinup_communities/joinup_oss_catalogue/src/Plugin/Field/FieldFormatter/EntityReferenceLabelTooltip.php (line 128) getTooltipText() uses token replacement for tooltip text without ensuring language context. High Pass the langcode to Token::replace().
web/modules/custom/joinup_core/joinup_core.module (line 175) joinup_core_file_delete() uses $entity->label() and $group->label() in log messages without translation. Low Use the default language for logging or ensure the labels are consistently retrieved.
web/modules/custom/joinup_core/src/Plugin/Field/FieldFormatter/EntityReferenceCustomLinkFormatter.php (line 150) viewElements() uses token replacement for link labels without ensuring the tokens are replaced using the correct language context. High Pass the langcode to Token::replace() to ensure translated tokens are used.
web/modules/custom/joinup_core/src/Plugin/Field/FieldFormatter/UrlFormatterWithCustomTitle.php (line 86) viewElements() uses a custom link label from settings without translation context, potentially showing the same label in all languages. High Wrap the custom title in t() if it's a fixed string or use config translation for the formatter settings.
web/modules/custom/joinup_core/src/Plugin/QueueWorker/DisableEiraTermsSolutionWorker.php (line 69) processItem() loads a node by ID without translation context. While the field updated is not translatable, the pattern ignores language. Low Good practice to load the default translation explicitly if only updating non-translatable fields.
web/modules/custom/joinup_distribution/joinup_distribution.module (line 182) joinup_distribution_preprocess_views_view_field() uses $entity->label() for a link in a view of download events, potentially using the default language label. Low Use the langcode from the view row or current context.
web/modules/custom/joinup_group/joinup_group.module (line 211) joinup_group_preprocess() uses $parent->label() for data-joinup-parent-label. In a multilingual site, the parent's label might be in a different language than the page's. Low Ensure the parent entity is loaded in the same language as the current entity using getTranslationFromContext().
web/modules/custom/joinup_group/joinup_group.module (lines 465, 1026) Various hooks and methods use $entity->label() for logging or messages. While mostly cosmetic, it can cause confusion in a multi-lingual site. Low Explicitly use the default language for logs or the user's interface language for messages.
web/modules/custom/joinup_group/joinup_group.module (line 910) joinup_group_entity_update() compares labels to decide if it should queue URL alias updates. It might not trigger updates if only a translation's label changes. Mid Compare labels for each translation or iterate over $entity->getTranslationLanguages() to check for changes.
web/modules/custom/joinup_group/src/Plugin/QueueWorker/JoinupGroupContentQueueWorker.php (line 53) processItem() loads an entity by ID without translation context. The subsequent updateEntityAlias() call might only update the default translation's alias. Mid Ensure updateEntityAlias() handles all translations or pass the langcode in the queue item.
web/modules/custom/joinup_notification/joinup_notification.module (line 138) joinup_notification_mail_alter() uses a hardcoded fallback for first name and passes it through t(), but does not explicitly set the translation context to the recipient's language. Low Provide the langcode option to the t() function or TranslatableMarkup.
web/modules/custom/joinup_notification/src/EventSubscriber/NotificationSubscriberBase.php (line 144) generateArguments() uses $entity->label() for the @entity:title argument. Emails might use the default translation title instead of the content's or recipient's language. Mid Use $entity->getTranslation($recipient_langcode)->label() when generating notification arguments.
web/modules/custom/joinup_notification/src/MessageArgumentGenerator.php (lines 142, 175) getGroupArguments() and getOgMembershipArguments() use $group->label() for email arguments, which may result in recipients receiving emails in a language they didn't expect. Mid Load the translation matching the recipient's preferred language ($user->getPreferredLangcode()).
web/modules/custom/joinup_paragraphs/joinup_paragraphs.module (line 136) joinup_paragraphs_preprocess_layout_paragraphs_insert_component_btn() compares a TranslatableMarkup with a hardcoded English string 'Add section'. This might fail if the site default language is different. Mid Compare the untranslated string or use the getUntranslatedString() method of TranslatableMarkup.
web/modules/custom/joinup_release/joinup_release.module (lines 211, 264) joinup_release_preprocess_node() and joinup_release_preprocess_page_title__node__release() use $release->label() to build a full label without translation context. Mid Ensure the release entity is in the current context's language.
web/modules/custom/joinup_seo/src/JoinupSeoExportHelper.php (line 62) exportEntityJsonLd() serializes entities for SEO. It needs to be verified if it handles translations correctly or if it only exports the default translation. Mid Pass the active language context to the serializer or iterate over available translations.
web/modules/custom/topic/topic.module (lines 48, 77) topic_taxonomy_term_update() and topic_meta_entity_presave() synchronize a meta_entity label with a term label using $term->label(), ignoring possible term translations. Mid Use $term->getTranslation($langcode)->label() to ensure synchronization across all languages.
web/modules/custom/topic/topic.module (line 134) topic_form_entity_subqueue_homepage_topics_validate() uses $meta_entity->label() for an error message, which will be in the default language regardless of the user's interface language. Low Use getTranslationFromContext($meta_entity) to display the label in the user's language.
web/themes/ventuno/includes/page_title.inc (line 19) ventuno_preprocess_page_title() uses getSingularLabel() for a bundle label without ensuring it is translated. Mid Use \Drupal::service('entity.repository')->getTranslationFromContext($entity->get('type')->entity) to get the translated bundle label.
web/themes/ventuno/includes/page_title.inc (line 28) ventuno_preprocess_page_title() uses $solution->label() for a title string without translation context. Mid Use getTranslationFromContext($solution)->label().
web/themes/ventuno/includes/utility.inc (line 95) _ventuno_preprocess_tile() uses $bundle_type->label() for tile labels. If the bundle label is translated, the tile might show the default translation instead of the current language. Mid Use \Drupal::service('entity.repository')->getTranslationFromContext($bundle_type) to get the translated bundle label.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment