We offer a handy EntityTranslatorTrait so you can translate entities anywhere.
You can pass a parameter (bool $strict = TRUE) to make sure the trait only returns entities that are in the target language.
If they aren't translated, the Trait doesn't return it back and either returns NULL or an empty array, depending on which method you used.

When the checked entity doesn't implement the TranslatableInterface, we ignore the $strict check.
However, we should also skip when ->isTranslatable() returns FALSE.
Right now, the entity is being discarded.

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

Robin.Houtevelts created an issue. See original summary.

dieterholvoet’s picture

Looks good!

dieterholvoet’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.