Can we add a custom route for asymmetric translated nodes?

Created on 3 March 2023, over 1 year ago
Updated 8 March 2023, over 1 year ago

Problem/Motivation

It would be really useful to be able to link to a specific node and instead get the URL of an asymmetrically translated node back instead.

Currently when we for example link to a node in Twig (e.g. {{ path('entity.node.canonical', {'node': node.id}) }}), Drupal simply doesn't know about the AST. Now this is part of the philosophy, because we don't want this module to interfere too much with core functionality.

However, we should provide a way for the developer to ask for a link in the correct language instead.

Steps to reproduce

Proposed resolution

Provide a route that checks for asymmetric translations and if available, returns a URL in the current language.

Suggestion:
{{ path('entity.asymmetric_node_translation.canonical', {'node': node.id}) }}

Note: We've had an internal discussion on whether this should be entity.ant.canonical or entity.asymmetric_node_translation.canonical. Since in all known cases this seems to the full words, we'll go for that. That will also prevent any collisions with other modules in the future.

In the above suggestion, the new route should:

  • Lookup ANT entities to see if the provided node is found there
  • If found, look for a translation in the current language
  • If found, return the 'entity.node.canonical' URL of the found translation instead

Remaining tasks

  • Build feature
  • Update documentation

User interface changes

API changes

Data model changes

Feature request
Status

Active

Version

1.0

Component

Code

Created by

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.71.5 2024