Index: i18nviews/i18nviews.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/i18n/i18nviews/i18nviews.module,v
retrieving revision 1.4.2.12
diff -u -p -r1.4.2.12 i18nviews.module
--- i18nviews/i18nviews.module	3 Jan 2009 18:23:04 -0000	1.4.2.12
+++ i18nviews/i18nviews.module	21 Jan 2009 02:23:13 -0000
@@ -26,14 +26,16 @@ function i18nviews_help($path, $arg) {
  * Implementation of hook_locale().
  */
 function i18nviews_locale($op = 'groups', $group = NULL) {
-  switch ($op) {
-    case 'groups':
-      return array('views' => t('Views'));
-
-    case 'refresh':
-      if ($group == 'views') {
-        return i18nviews_locale_refresh();
-      }
+  if (variable_get('views_localization_plugin', 'core') == 'i18nstrings') {
+    switch ($op) {
+      case 'groups':
+        return array('views' => t('Views'));
+
+      case 'refresh':
+        if ($group == 'views') {
+          return i18nviews_locale_refresh();
+        }
+    }
   }
 }
 
@@ -45,94 +47,6 @@ function i18nviews_locale_refresh() {
 }
 
 /**
- * Implementation of hook_views_pre_view().
- *
- * Views are identified by $view->name.
- *
- * @TODO This needs a lot of research and work.
- * @TODO Ask Earl
- */
-function i18nviews_views_pre_view(&$view, &$display_id, &$args) {
-  // Translate all possible display strings, step by step.
-  // I.e. for a page, there seems to be a 'page' and a 'default' display.
-  $fields = _i18nviews_display_fields();
-  // Also checking weird values for $display_id, see 277711
-  if (!empty($view->display) && is_array($view->display) && is_string($display_id)) {
-    foreach (array($display_id, 'default') as $display) {
-      if(!empty($view->display[$display])) {
-        _i18nviews_localize_array($view->name, $display, $view->display[$display]->handler->options, $fields, TRUE);
-      }
-    }
-  }
-
-  // Translate taxonomy fields.
-  // @todo I don think this works at all.
-  if (module_exists('i18ntaxonomy') && is_array($view->field)) {
-    $translate = variable_get('i18ntaxonomy_vocabularies', array());
-    foreach ($view->field as $index => $data) {
-      $matches = array();
-      if ($data['id'] == 'term_node.name') {
-        // That's a full taxonomy box.
-        $view->field[$index]['handler'] = 'i18ntaxonomy_views_handler_field_allterms';
-      }
-      elseif (preg_match("/term_node_(\d+)\.name/", $data['id'], $matches)) {
-        $vid = $matches[1];
-        if ($translate[$vid]) {
-          // Set new handler for this field.
-          $view->field[$index]['handler'] = 'i18ntaxonomy_views_handler_field_allterms';
-        }
-      }
-    }
-  }
-
-}
-
-/**
- * Return the Views fields that should be translated.
- *
- * @return
- *   Array of field names.
- */
-function _i18nviews_display_fields() {
-  return array('title', 'header', 'footer', 'empty');
-}
-
-/**
- * Translate a group of fields.
- *
- * We get the translated fields out of the array so they are not translated again.
- */
-function _i18nviews_localize_array($name, $group, &$data, &$field_names, $trim = FALSE) {
-  $translated = array();
-  foreach ($field_names as $field) {
-    if (!empty($data[$field])) {
-      $data[$field] = tt("views:$name:$group:$field", $data[$field]);
-      $translated[] = $field;
-    }
-  }
-  if ($trim && $translated) {
-    $field_names = array_diff($field_names, $translated);
-  }
-}
-
-/**
- * Translate a group of fields for an object.
- *
- * We cannot play with object 2 array conversion because some are real typed objects.
- */
-function _i18nviews_localize_object($name, $group, &$data, &$field_names, $trim = FALSE) {
-  $translated = array();
-  foreach ($field_names as $field) {
-    if (!empty($data->$field)) {
-      $data->$field = tt("views:$name:$group:$field", $data->$field);
-    }
-  }
-  if ($trim && $translated) {
-    $field_names = array_diff($field_names, $translated);
-  }
-}
-
-/**
  * Field handler for taxonomy term fields.
  *
  * Remake of views_handler_field_allterms with term name translation.
@@ -162,30 +76,8 @@ function i18ntaxonomy_views_handler_fiel
 }
 
 /**
- * Implementation of hook_form_id_alter().
- *
- * Add a submit handler to the submit button on views_ui_edit_display_form. 
+ * Implementation of hook_veiws_api().
  */
-function i18nviews_form_views_ui_edit_display_form_alter(&$form, $form_state) {
-  $form['buttons']['submit']['#submit'][] = 'i18nviews_views_ui_edit_display_submit';
-}
-
-/**
- * Submit handler for views_ui_edit_display_form.
- *
- * Creates or updates translation source records for specified Views fields.
- */
-function i18nviews_views_ui_edit_display_submit($form, &$form_state) {
-  $fields = _i18nviews_display_fields();
-  foreach ($fields as $field) {
-    if (isset($form_state['values'][$field])) {
-      $name = $form_state['view']->name;
-      $group = $form_state['display_id'];
-      tt("views:$name:$group:$field", $form_state['values'][$field], NULL, TRUE);
-    }
-  }
-}
-
 function i18nviews_views_api() {
   return array(
     'api' => '2.0',
Index: i18nviews/includes/i18nviews.views.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/i18n/i18nviews/includes/Attic/i18nviews.views.inc,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 i18nviews.views.inc
--- i18nviews/includes/i18nviews.views.inc	17 Nov 2008 19:59:37 -0000	1.1.2.1
+++ i18nviews/includes/i18nviews.views.inc	21 Jan 2009 02:23:13 -0000
@@ -1,26 +1,48 @@
 <?php
 
-function i18nviews_views_data() {
+/**
+ * Implementation of hook_views_data_alter().
+ */
+function i18nviews_views_data_alter(&$data) {
   $data['node']['content_negotiation'] = array(
-    'group' => t('i18n'),
+    'group' => t('Node translation'),
     'title' => t('Content negotiation'),
-    'help' => t('Removes the nodes that are not valid according to the content selection mode'),
+    'help' => t('Removes the nodes that are not valid according to the content selection mode.'),
     'filter' => array(
       'handler' => 'content_negotiation_filter_handler',
     ),
   );
-  return $data;
 }
 
 /**
- * Implementation of hook_views_handlers
+ * Implementation of hook_views_handlers().
  */
 function i18nviews_views_handlers() {
   return array(
+    'info' => array(
+      'path' => drupal_get_path('module', 'i18nviews') . '/includes',
+    ),
     'handlers' => array(
       'content_negotiation_filter_handler' => array(
         'parent' => 'views_handler_filter',
-        'file' => 'includes/content_negotiation_filter_handler.inc' 
+      ),
+    ),
+  );
+}
+
+/**
+ * Implementation of hook_views_plugins().
+ */
+function i18nviews_views_plugins() {
+  $path = drupal_get_path('module', 'i18nviews') . '/includes';
+  return array(
+    'module' => 'i18nviews',
+    'localization' => array(
+      'i18nstrings' => array(
+        'title' => t('Views translation module'),
+        'help' => t("Use the locale system as implemented by the Views translation module."),
+        'handler' => 'views_plugin_localization_i18nstrings',
+        'path' => $path,
       ),
     ),
   );
Index: i18nviews/includes/views_plugin_localization_i18nstrings.inc
===================================================================
RCS file: i18nviews/includes/views_plugin_localization_i18nstrings.inc
diff -N i18nviews/includes/views_plugin_localization_i18nstrings.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ i18nviews/includes/views_plugin_localization_i18nstrings.inc	21 Jan 2009 02:23:13 -0000
@@ -0,0 +1,59 @@
+<?php
+// $Id: $
+/**
+ * @file
+ * Contains the i18nstrings localization plugin.
+ */
+
+/**
+ * Localization plugin to pass translatable strings through tt().
+ *
+ * @ingroup views_localization_plugins
+ */
+class views_plugin_localization_i18nstrings extends views_plugin_localization {
+
+  /**
+   * Translate a string.
+   *
+   * @param $string
+   *   The string to be translated.
+   * @param $keys
+   *   An array of keys to identify the string. Generally constructed from
+   *   view name, display_id, and a property, e.g., 'header'.
+   */
+  function translate($string, $keys = array()) {
+    $location = implode(':', $keys);
+    return tt('views:' . $location, $string);
+  }
+
+  /**
+   * Save a string for translation.
+   *
+   * @param $string
+   *   The string to be saved.
+   * @param $keys
+   *   An array of keys to identify the string. Generally constructed from
+   *   view name, display_id, and a property, e.g., 'header'.
+   */
+  function save($string, $keys = array()) {
+    $location = implode(':', $keys);
+    tt('views:' . $location, $string, NULL, TRUE);
+    return TRUE;
+  }
+
+  /**
+   * Delete a string.
+   *
+   * @param $string
+   *   The string to be deleted.
+   * @param $keys
+   *   An array of keys to identify the string. Generally constructed from
+   *   view name, display_id, and a property, e.g., 'header'.
+   */
+  function delete($string, $keys = array()) {
+    $location = implode(':', $keys);
+    i18nstrings_remove_string('views:' . $location, $string, NULL, $update);
+    return TRUE;
+  }
+}
+
