So I need to create links to specific translations of a node but am having issues.
This is my code:
foreach($entities as $entity) {
$urls[] = Url::fromRoute('entity.node.canonical', [
'node' => $entity->id(),
'language' => $entity->language()->getId(),
]);
}
$entity
in this context is EntityInterface
.
But this gives me /node/1185?language=es
instead of /es/node/1185
.