Description

Select translation implements a Views filter which allows you to select, for a group of nodes representing a same translation, which of the translation should be displayed.

The options are :

  • Use current language ; if not available use original language
  • Use current language ; if not available use default language ; if not available use original language
  • Provide a list of languages, so that the most appropriate language is selected. The list can contain the special values 'current', 'default' and 'original' for, respectively, the current language, the default language and the node's original language.

API

Select translation also provides an API to let users select the correct translation of a given node. This can be useful in code snippets, or when writing your own module. Given a node id, the function returns the node id to display, following the same algorithm as the view filter. Usage :

  <?php
    $my_nid
= select_translation_of_node($nid); // Uses 'default' mode
   
$my_nid = select_translation_of_node($nid, 'original'); // Uses 'original' algorithm
   
$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 6 Compatibility

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

Note: Drupal 7 version released with an optimized query for the views filter plugin.

Project Information

Downloads