Problem/Motivation

After enabling translations for courses, lessons, and activities, the TrainingManager method getOrderedLessons() is not language aware. The array produced is always in the site's or content's default language, rather than the currently selected one based on language selection.

Steps to reproduce

Enable translations for courses and lessons.
Create a course with a single lesson.
Translate the lesson.
Call TrainingManager::getOrderedLessons while view the site as the non-default language.

Proposed resolution

Augment Training Manager by injecting `language_manager`, and storing the current langcode as a class variable during initialization.

When calling getOrderedLessons, get the translated entity by calling $lesson->getTranslation($this->currentLangcode)

Remaining tasks

Create patch.

User interface changes

None.

API changes

None, although we may want to consider adding the entity itself to the output array so that downstream modules and custom code can get other translations and/or entity fields as needed.

Data model changes

None.

Issue fork lms-3586791

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

socketwench created an issue.