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

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

This patch started as a port to Drupal 6 version of i18n module of this patch
from mardy78:
  http://drupal.org/node/78973
but is is evolving to be more readable while keeping some performance.

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

Index: i18n/i18n.module
===================================================================
--- i18n.orig/i18n.module	2009-04-15 22:22:42.000000000 +0200
+++ i18n/i18n.module	2009-04-15 22:32:47.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.
@@ -501,6 +503,19 @@
     case 'mixed':
       return "$alias.language ='$current' OR $alias.language ='$default' OR $alias.language ='' OR $alias.language IS NULL" ;
 
+    case 'mixed_single':
+      return "$alias.tnid IS NULL OR $alias.tnid = 0 OR $alias.nid = (
+         SELECT nid FROM {node} AS n2
+            WHERE n2.tnid=$alias.tnid
+              ORDER BY
+                CASE n2.language
+                  WHEN '$current' THEN 1
+                  WHEN '$default' THEN 2
+                  ELSE 1000
+                END
+              LIMIT 1
+          )";
+
     case 'strict':
       return "$alias.language ='$current'" ;
 
Index: i18n/i18n.admin.inc
===================================================================
--- i18n.orig/i18n.admin.inc	2009-04-15 22:22:42.000000000 +0200
+++ i18n/i18n.admin.inc	2009-04-15 22:22:59.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.'),
