Use wizard to try to translate headers. It should give better results, especially with compounds like 'Street (Business)', where translation has no such phrase

This commit is contained in:
Nathan Gray 2011-12-05 19:33:29 +00:00
parent d0f9f93d4a
commit d033d3b651
3 changed files with 28 additions and 3 deletions

View File

@ -479,6 +479,9 @@ class importexport_definitions_ui
{
$wizard_plugin = $content['plugin'];
}
// App translations
if($content['application']) translation::add_app($content['application']);
$this->plugin = is_object($GLOBALS['egw']->$wizard_plugin) ? $GLOBALS['egw']->$wizard_plugin : new $wizard_plugin;
// Global object needs to be the same, or references to plugin don't work

View File

@ -153,11 +153,25 @@ class importexport_export_csv implements importexport_iface_export_record
// Load translations for app
list($appname, $part2) = explode('_', get_class($_record));
if(!$GLOBALS['egw_info']['apps'][$appname]) $appname .= $part2; // Handle apps with _ in the name
// Get translations from wizard, if possible
$backtrace = debug_backtrace();
$plugin = $backtrace[1]['class'];
$wizard_name = $appname . '_wizard_' . str_replace($appname . '_', '', $plugin);
try {
$wizard = new $wizard_name;
$fields = $wizard->get_export_fields();
foreach($this->mapping as $field => &$label)
{
$label = $fields[$field];
}
} catch (Exception $e) {
translation::add_app($appname);
foreach($this->mapping as $field => &$label) {
$label = lang($label);
}
}
}
$mapping = ! empty( $this->mapping ) ? $this->mapping : array_keys ( $this->record );
$mapping = $this->translation->convert( $mapping, $this->translation->charset(), $this->csv_charset );
fputcsv( $this->handle ,$mapping ,$this->csv_options['delimiter'], $this->csv_options['enclosure'] );

View File

@ -200,4 +200,12 @@ class importexport_wizard_basic_export_csv
}
}
/**
* Expose export fields for use elsewhere
*/
public function get_export_fields()
{
return $this->export_fields;
}
}