When I use this token:

[node:book:parents:join-path]

parent's titles are not translated.

Comments

brtamas created an issue. See original summary.

brtamas’s picture

Status: Needs review » Needs work

The last submitted patch, 2: token_8_1_3_2982284_parents_translation_01.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

brtamas’s picture

Here is a better one.

berdir’s picture

+++ b/token.module
@@ -652,14 +653,22 @@ function token_book_load_all_parents(array $book) {
-      $cache[$nid][] = Node::load($book["p$i"])->getTitle();
+      $node_parent = Node::load($book["p$i"]);
+      $node_parent_translated = $node_parent->getTranslation($langcode);
+      $node_final = !empty($node_parent_translated) ? $node_parent_translated : $node_parent;
+

this should use \Drupal\Core\Entity\EntityRepositoryInterface::getTranslationFromContext() (entity.repository service), that will check if a translation exists and also do fallback logic if not.

Then you can use NULL s fallback and not 'und'.

aurora-norris’s picture

Rerolled patch for 1.17