Index: apachesolr_search.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr_search.module,v
retrieving revision 1.1.2.9
diff -u -r1.1.2.9 apachesolr_search.module
--- apachesolr_search.module	29 Jun 2008 13:53:29 -0000	1.1.2.9
+++ apachesolr_search.module	4 Jul 2008 12:37:26 -0000
@@ -46,7 +46,7 @@
           'rows' => variable_get('apachesolr_rows', 10),
           'facet' => 'true',
           'facet.limit' => $facet_limit,
-          'facet.field' => array('tid', 'type', 'uid'),
+          'facet.field' => array('tid', 'type', 'uid', 'language'),
           'facet.mincount' => 1,
           'facet.sort' => 'true'
         );
Index: apachesolr.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr.module,v
retrieving revision 1.1.2.16
diff -u -r1.1.2.16 apachesolr.module
--- apachesolr.module	29 Jun 2008 13:53:29 -0000	1.1.2.16
+++ apachesolr.module	4 Jul 2008 12:37:26 -0000
@@ -215,7 +215,7 @@
           // Let modules add to the document
           module_invoke_all('apachesolr_update_index', &$document, $node);
 
-          $fields = array('title', 'body', 'type', 'uid', 'changed', 'nid', 'comment_count', 'name');
+          $fields = array('title', 'body', 'type', 'uid', 'changed', 'nid', 'comment_count', 'name', 'language');
           foreach ((array)$node as $key => $value) {
             if (in_array($key, $fields)) {
               $document->$key = $value;
Index: schema.xml
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/schema.xml,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 schema.xml
--- schema.xml	14 Jun 2008 18:44:29 -0000	1.1.2.2
+++ schema.xml	4 Jul 2008 12:37:27 -0000
@@ -256,7 +256,7 @@
    <field name="vid"  type="integer" indexed="true" stored="true" multiValued="true"/>
    <field name="taxonomy_name" type="string" indexed="true" stored="true" multiValued="true"/>
    <field name="text" type="text" indexed="true" stored="false"/>
-
+   <field name="language" type="string" indexed="true" stored="true"/>
 
    <!-- Here, default is used to create a "timestamp" field indicating
         When each document was indexed.
Index: sites/all/modules/apachesolr/apachesolrlang.module
===================================================================
RCS file: sites/all/modules/apachesolr/apachesolrlang.module
diff -N sites/all/modules/apachesolr/apachesolrlang.module
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sites/all/modules/apachesolr/apachesolrlang.module	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,73 @@
+<?php
+
+// $Id$
+
+/**
+ * Implementation of hook_block().
+ */
+function apachesolrlang_block($op = 'list', $delta = 0, $edit = array()) {
+  $title = t('ApacheSolr: Filter by language');
+  switch ($op) {
+    case 'list':
+      $blocks['language'] = array('info' => $title);
+      return $blocks;
+
+    case 'view':
+      if (apachesolr_has_searched()) {
+        // Get the query and response. Without these no blocks make sense.
+        $response =& apachesolr_static_response_cache();
+        if (empty($response)) {
+          return;
+        }
+        $query =& apachesolr_drupal_query();
+        
+        switch ($delta) {
+          case 'language':
+            if (is_array($response->facets->language)) {
+              $contains_active = FALSE;
+              foreach ($response->facets->language as $language => $count) {
+                $unclick_link = '';
+                unset($active);
+                $new_query = clone $query;
+                if ($active = $query->has_field('language', $language)) {
+                  $contains_active = TRUE;
+                  $new_query->remove_field('language', $language);
+                  $path = 'search/'. arg(1). '/'. $new_query->get_query();
+                  $unclick_link = theme('apachesolr_unclick_link', $path);
+                }
+                else {
+                  $new_query->add_field('language', $language);
+                  $path = 'search/'. arg(1). '/'. $new_query->get_query();
+                }
+                $countsort = $count == 0 ? '' : 1 / $count;
+                // if numdocs == 1 and !active, don't add.
+                if ($response->numFound == 1 && !$active) {
+                  // skip
+                }
+                else {
+                  $result = db_query("SELECT name FROM {locales_meta} WHERE locale = '%s' LIMIT 1", $language);
+                  $lang_name = db_result($result);
+                  $languages[] = theme('apachesolr_facet_item', $lang_name ? $lang_name : $language, $count, $path, $active, $unclick_link);
+                }
+              }
+              if (is_array($languages)) {
+                $facet_limits = variable_get('apachesolr_facet_limits', array());
+                $facet_limit = isset($facet_limits[$delta]) ? $facet_limits[$delta] : 10;
+                $languages = array_slice($languages, 0, $facet_limit);
+                $output = theme('apachesolr_facet_list', $languages);
+                return array('subject' => $title, 'content' => $output);
+              }
+            }
+
+            break;
+        }
+      }
+      break;
+    
+    case 'configure':
+      return apachesolr_block($op, $delta);
+    
+    case 'save':
+      return apachesolr_block($op, $delta, $edit);
+  }
+}
Index: sites/all/modules/apachesolr/apachesolrlang.info
===================================================================
RCS file: sites/all/modules/apachesolr/apachesolrlang.info
diff -N sites/all/modules/apachesolr/apachesolrlang.info
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sites/all/modules/apachesolr/apachesolrlang.info	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,5 @@
+; $Id$
+name = Apache Solr languages
+description = Adds language facets.
+dependencies = locale apachesolr search
+package = ApacheSolr
