public function exportAction()
 {
     $output = array();
     $locale = $this->_getParam('locale', 'en');
     $translate = Zend_Registry::get('Zend_Translate');
     // export en, then the language being exported, so that language pack will always contain ALL possible keys
     $output = array_merge($translate->getMessages('en'), $translate->getMessages($locale));
     /*
     $languages = $translate->getList();
     $languages = array_unshift($languages, 'en');
     $languages = array_unique($languages);
     echo "<pre>"; print_r($languages);exit;
     // english first, then the exported language will overwrite english
     foreach ($languages as $language) {
       $output = array_merge($output, $translate->getMessages($language));
     }
     */
     // dump to temporary file to get CSV formatting
     $tmp_file = APPLICATION_PATH . "/temporary/lang_export_{$locale}.csv";
     touch($tmp_file);
     chmod($tmp_file, 0777);
     $export = new Engine_Translate_Writer_Csv($tmp_file);
     $export->setTranslations($output);
     $export->write();
     // force download of CSV file
     header("Content-Disposition: attachment; filename=\"{$locale}.csv\"");
     $fh = @fopen($tmp_file, 'r');
     if ($fh) {
         while (!feof($fh)) {
             echo fgets($fh, 4096);
             flush();
         }
         fclose($fh);
     } else {
         echo Zend_Registry::get('Zend_Translate')->_("CSV export failed.");
     }
     @unlink($tmp_file);
     exit;
 }