• Main Page
  • Related Pages
  • Modules
  • Classes
  • Files
  • File List
  • File Members

plugins/views_plugin_localization.inc

Go to the documentation of this file.
00001 <?php
00002 
00013 class views_plugin_localization extends views_plugin {
00014   // Store for exported strings
00015   var $export_strings = array();
00016   var $translate = TRUE;
00017 
00024   function init(&$view) {
00025     $this->view = &$view;
00026   }
00027 
00043   function translate($source) {
00044     // Allow other modules to make changes to the string before and after translation
00045     $source['pre_process'] = $this->invoke_translation_process($source, 'pre');
00046     $source['translation'] = $this->translate_string($source['value'], $source['keys'], $source['format']);
00047     $source['post_process'] = $this->invoke_translation_process($source, 'post');
00048     return $source['translation'];
00049   }
00050 
00062   function translate_string($string, $keys = array(), $format = '') {}
00063 
00070   function save($source) {
00071     // Allow other modules to make changes to the string before saving
00072     $source['pre_process'] = $this->invoke_translation_process($source, 'pre');
00073     $this->save_string($source['value'], $source['keys'], isset($source['format']) ? $source['format'] : '');
00074   }
00075 
00087   function save_string($string, $keys = array(), $format = '') {}
00088 
00095   function delete($source) { }
00096 
00103   function export($source) { }
00104 
00111   function export_render($indent = '  ') { }
00112 
00119   function invoke_translation_process(&$value, $op) {
00120     $return = array();
00121     $hook = 'translation_' . $op . '_process';
00122     foreach (module_implements($hook) as $module) {
00123       $function = $module . '_' . $hook;
00124       $result = $function($value);
00125       if (isset($result)) {
00126         $return[$module] = $result;
00127       }
00128     }
00129     return $return;
00130   }
00131 
00132   function process_locale_strings($op) {
00133     $this->view->init_display();
00134 
00135     foreach ($this->view->display as $display_id => $display) {
00136       $translatable = array();
00137       // Special handling for display title.
00138       if (isset($display->display_title)) {
00139         $translatable[] = array('value' => $display->display_title, 'keys' => array('display_title'));
00140       }
00141       // Unpack handlers.
00142       if (is_object($this->view->display[$display_id]->handler)) {
00143         $this->view->display[$display_id]->handler->unpack_translatables($translatable);
00144       }
00145       foreach ($translatable as $data) {
00146         $data['keys'] = array_merge(array($this->view->name, $display_id), $data['keys']);
00147         switch ($op) {
00148           case 'save':
00149             $this->save($data);
00150             break;
00151           case 'delete':
00152             $this->delete($data);
00153             break;
00154           case 'export':
00155             $this->export($data);
00156             break;
00157         }
00158       }
00159     }
00160   }
00161 }

Generated on Sun Feb 26 2012 12:52:51 for Views by  doxygen 1.7.1