Select all content avoiding duplicates and using some preference rules to show
the translation of a group of translations.

This changes implements pretty much what is described here:
  http://drupal.org/node/429996

This patch is a port to Drupal 6 version of i18n module of this patch from
mardy78:
  http://drupal.org/node/78973

Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>

Index: i18n/i18n.module
===================================================================
--- i18n.orig/i18n.module	2009-04-10 23:49:12.000000000 +0200
+++ i18n/i18n.module	2009-04-10 23:49:40.000000000 +0200
@@ -368,6 +368,8 @@
  *  off = No language conditions inserted.
  *  simple = Only current language and no language.
  *  mixed = Only current and default languages.
+ *  mixed_single = All content, but remove duplicate translations favouring
+ *                 current language, then default language
  *  strict = Only current language.
  *  default = Only default language.
  *  user = User defined, in the module's settings page.
@@ -486,10 +488,6 @@
     // Special case. Selection mode is 'strict' but this should be only for node queries.
     $mode = 'simple';
   }
-  elseif ($mode == 'mixed' && $current == $default) {
-    // If mode is mixed but current = default, is the same as 'simple'.
-    $mode = 'simple';
-  }
 
   switch ($mode) {
     case 'off':
@@ -501,6 +499,14 @@
     case 'mixed':
       return "$alias.language ='$current' OR $alias.language ='$default' OR $alias.language ='' OR $alias.language IS NULL" ;
 
+    case 'mixed_single':
+      $pref_lang = i18n_get_lang();
+      $def_lang = i18n_default_language();
+      return "$alias.tnid = 0 OR $alias.tnid IS NULL OR $alias.language
+        ='$pref_lang' OR ($alias.language = '$def_lang' AND NOT EXISTS (SELECT
+        * FROM {node} as i18nrw WHERE i18nrw.tnid = $alias.tnid AND
+        i18nrw.language='$pref_lang') )";
+
     case 'strict':
       return "$alias.language ='$current'" ;
 
Index: i18n/i18n.admin.inc
===================================================================
--- i18n.orig/i18n.admin.inc	2009-04-10 23:49:12.000000000 +0200
+++ i18n/i18n.admin.inc	2009-04-10 23:49:40.000000000 +0200
@@ -55,6 +55,7 @@
   return array(
     'simple' => t('Current language and language neutral.'),
     'mixed' => t('Mixed current language (if available) or default language (if not) and language neutral.'),
+    'mixed_single' => t('All content, but remove duplicate translations favouring current language, then default language'),
     'default' => t('Only default language and language neutral.'),
     'strict' => t('Only current language.'),
     'off' => t('All content. No language conditions apply.'),
