external_link_translation
This module builds on Drupal's multilingual capabilities by providing a straightforward means for translating external links. It uses a custom entity that enables content editors to define external link translations within the admin UI. To apply translations, editors just need to copy the canonical link generated by the entity and paste it into menus, link fields, or any site component that accepts internal links. The module then transforms these paths into the appropriate external links, helping support a consistent navigation structure for users in different languages.
Additional Info & Use Cases
Drupal's translation system works by creating content in a source language and then translating it into other languages. This setup allows users to link to translated content by using an internal link in the source language, and Drupal automatically updates the link for each translation.
Because of this model, many of Drupal's core functions, such as menu links, are designed for internal paths and don't support translating URIs directly.
This module's approach is to treat external links as content. By doing so, translating external links becomes as straightforward as translating other types of content in Drupal and opens up various practical use cases:
- Translating External Menu Links: Supports both traditional and decoupled menu setups.
- Reusing External Link Translations: Enables the reuse of translated external links across different pages and components, such as linking to a multilingual support minisite multiple times. You can translate it once and reuse it.
- Integrating with Twig Templates: Offers the ability to create translatable external links in Twig templates using the url function. Example:
url('entity.external_link_translation.canonical', { 'external_link_translation': 1 }) - Leveraging Linkit Integration: Supports use as a Linkit matcher, simplifying content editing with a selection of pre-translated external links.
Post-Installation
- Make the External link translation entity translatable by going to Administration > Configuration > Content language and translation.
- Users with the Administer external link translations permission can begin creating and managing external link translations under Administration > Content > External Link Translations.
Similar projects
- Translatable menu link uri - Allows the translation of menu links by overriding the link field.