SocialGroupListBuilder does not display translated titles

Created on 27 March 2020, over 4 years ago
Updated 1 March 2024, 4 months ago

Problem/Motivation

User story:

Benefit: In order to find a group
Role: As a site manager
Goal/desire: I want to see a list of group titles in my currently-selected language

I have a multi-lingual OpenSocial 8 site, where the primary language is English, and the other installed language is French (detection is done with /en/ and /fr/ path prefixes. I have marked Group entities, and their Title field, as translatable at /en/admin/config/regional/content-language.

If I create a Group in English, then translate it into French, the group title always appears in the source language (i.e.: English) at BOTH /en/admin/group and /fr/admin/group. I was expecting the English title to appear at /en/admin/group and the French title to appear at /fr/admin/group.

Proposed resolution

Some investigation reveals that \Drupal\group\Entity\Controller\GroupListBuilder::buildRow() is being overridden by \Drupal\social_group\Controller\SocialGroupListBuilder::buildRow(). This file calls $entity->label() (where $entity is an instance of \Drupal\group\Entity\Group). While I'd expect this to work, it does not - near as I can tell, the $entity instance does not have context about the current language for whatever reason.

Things do seem to work when I call $entity->getTranslation(\Drupal::languageManager()->getCurrentLanguage()->getId())->toLink()->toRenderable()

I will attach a patch which uses proper dependency injection.

Remaining tasks

  1. Review and feedback
  2. RTBC
  3. Commit and release

User interface changes

The list of groups at /admin/group will display content in the currently-selected content language.

API changes

N/A

Data model changes

N/A

Release notes snippet

To be determined.

πŸ› Bug report
Status

Needs review

Version

12.1

Component

Groups

Created by

πŸ‡¨πŸ‡¦Canada mparker17 UTC-4

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024