Skip to main content
Drupal is a registered trademark of Dries Buytaert
EOL Warning: Drupal 11.0 has reached end of life and no longer receives security updates. EOL Warning: Drupal 10.3 has reached end of life and no longer receives security updates. EOL Warning: Drupal 10.2 has reached end of life and no longer receives security updates. EOL Warning: Drupal 10.1 has reached end of life and no longer receives security updates. EOL Warning: Drupal 10.0 has reached end of life and no longer receives security updates. EOL Warning: Drupal 9.5 has reached end of life and no longer receives security updates. EOL Warning: Drupal 9.4 has reached end of life and no longer receives security updates. EOL Warning: Drupal 9.3 has reached end of life and no longer receives security updates. Release: Raven: Sentry Integration 7.5.2 Minor update available for module raven (7.5.2). Usage Milestone: jQuery UI Datepicker Module jquery_ui_datepicker crossed 1,000 active installs.

Select translation

9,261 sites Security covered
View on drupal.org

This module provides a Views filter that allows you to select which translation of a node to display based on various language settings. It also offers an API for retrieving specific node translations programmatically.

Description

Select translation implements a Views filter to select which translation of a node should be displayed in a list of nodes.

Several modes are available to select a translation:

  • Use the current interface language; if not available use the original node language.
  • Use the current interface language; if not available use the default site language; if not available use the original node language.
  • Specify a list of languages, and use the most appropriate language.

    Some special values are recognized in the languages list:
    • "current" will be replaced with the current interface language;
    • "default" will be replaced with the default site language;
    • "original" will be replaced with the original node language.

Select translation also provides an API following the same selection algorithm as the Views filter.

Drupal 6 Compatibility

Select translation works with Content translations (not Entity translations).

If you have i18n, you should set 'Content selection mode' to 'All content' in i18nsettings (admin/settings/i18n).

API

Given a node id, and a selection mode, the function returns the node id to display.

Example:

  <?php
  $my_nid = select_translation_of_node($nid); // Uses 'default' mode
  $my_nid = select_translation_of_node($nid, 'original'); // Uses 'original' mode
  $my_nid = select_translation_of_node($nid, array('en', 'fr', 'current')); // Returns the best match
  ?>

Similar project : Active translation performs a similar function but it is not a Views filter - it acts on all queries of the whole site.

Drupal 7

Select translation starts using an optimized query for the Views filter plugin.

Drupal 8

Select translation works on Entity translations.

Since in Drupal 8 any node always have at least one "translation" (the original one), the include_content_without_translation option has been removed.

Drupal 9+

2.x is a Drupal 9+ successor of 8.x-1.x-dev. It's stability is currently alpha, so use with care!

API

Given a node id, and a selection mode, the function returns the entity translation.

Example:

  <?php
  use Drupal\node\Entity\Node;

  /* @var \Drupal\node\Entity\Node $my_node */
  $my_node = select_translation_of_node($nid); // Uses 'default' mode
  $my_node = select_translation_of_node($nid, 'original'); // Uses 'original' mode
  $my_node = select_translation_of_node($nid, 'en,fr,current'); // Returns the best match
  ?>

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
1
Tracked since
Jul 2026
Latest release
1 month ago
Releases (12 mo)
1 ▲ from 0
Maintenance
Active

Releases

Version Type Core Release date
2.0.0-alpha6 Pre-release 9–11 Jul 13, 2026