? comment_remove.patch
Index: l10n_server/l10n_community/export.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/l10n_server/l10n_community/Attic/export.inc,v
retrieving revision 1.1.2.15.2.12
diff -u -p -r1.1.2.15.2.12 export.inc
--- l10n_server/l10n_community/export.inc	16 Aug 2009 15:00:51 -0000	1.1.2.15.2.12
+++ l10n_server/l10n_community/export.inc	5 Sep 2009 17:16:13 -0000
@@ -124,6 +124,13 @@ function l10n_community_export_form(&$fo
       '#default_value' => 'drupal-6',
       '#description' => t("Drupal 5's autolocale module and Drupal 6 use different conventions for directory naming in packages. Temporarily, as long as you need to use CVS to distribute translations the flat package helps you generate a package for committing to Drupal.org. Additionally, for testing, spell checking and smaller modules, you can also export in one file without packaging as well. It is not advised to use big .po files for importing in Drupal though, as it might lead to incomplete imports. Use packages for usage with Drupal importing."),
     );
+    // TODO: please review the text! ;)
+    $form['format']['comments'] = array(
+      '#title' => t('Export comments'),
+      '#description' => t('If you want comments check it. But we suggest do not do it because the exported file will be huge'),
+      '#type' => 'checkbox',
+      '#default_value' => 0,
+    );
   }
   $form['submit'] = array(
     '#type' => 'submit',
@@ -185,7 +192,8 @@ function l10n_community_export_form_subm
     $language,
     ($type != 'translation'),
     // If not set (exporting a template for a module), stick to all-in-one.
-    isset($form_state['values']['version']) ? $form_state['values']['version'] : 'all-in-one'
+    isset($form_state['values']['version']) ? $form_state['values']['version'] : 'all-in-one',
+    $form_state['values']['comments']
   );
 
   if (isset($export_result) && is_array($export_result)) {
@@ -207,7 +215,7 @@ function l10n_community_export_form_subm
 /**
  * Helper function to store the export string.
  */
-function _l10n_community_export_string_files(&$string_files, $uri, $language, $template, $version, $export_string) {
+function _l10n_community_export_string_files(&$string_files, $uri, $language, $template, $version, $export_string, $export_comments = 0) {
   $po_folder = ($version == 'drupal-5' ? 'po' : 'translations');
 
   if (!empty($export_string)) {
@@ -272,7 +280,10 @@ function _l10n_community_export_string_f
     if (strpos($export_string['value'], "\0") !== FALSE) {
       // This is a string with plural variants.
       list($singular, $plural) = explode("\0", $export_string['value']);
-      $output = $comment .'msgid '. _l10n_community_export_string($singular) .'msgid_plural '. _l10n_community_export_string($plural);
+      if ($export_comments) {
+        $output = $comment;
+      }
+      $output .= 'msgid '. _l10n_community_export_string($singular) .'msgid_plural '. _l10n_community_export_string($plural);
       if (!empty($export_string['context'])) {
         $output .= 'msgctxt '. _l10n_community_export_string($export_string['context']);
       }
@@ -298,7 +309,10 @@ function _l10n_community_export_string_f
     }
     else {
       // Simple string (and possibly translation pair).
-      $output = $comment .'msgid '. _l10n_community_export_string($export_string['value']);
+      if ($export_comments) {
+        $output = $comment;
+      }
+      $output .= 'msgid '. _l10n_community_export_string($export_string['value']);
       if (!empty($export_string['context'])) {
         $output .= 'msgctxt '. _l10n_community_export_string($export_string['context']);
       }
@@ -330,7 +344,10 @@ function _l10n_community_export_string_f
         $string_files[$filename] = array('file' => '', 'changed' => 0, 'revisions' => array());
       }
       // Add to existing file storage.
-      $string_files[$filename]['file'] .= $output ."\n";
+      $string_files[$filename]['file'] .= $output;
+      if ($export_comments) {
+        $string_files[$filename]['file'] .= "\n";
+      }
       if (!$template) {
         $string_files[$filename]['changed'] = max($string_files[$filename]['changed'], $export_string['changed']);
       }
@@ -361,7 +378,7 @@ function _l10n_community_export_string_f
  * @todo
  *   Look into possibly exporting suggestions as fuzzy translations.
  */
-function l10n_community_export($uri, $release = NULL, $language = NULL, $template = TRUE, $version = NULL) {
+function l10n_community_export($uri, $release = NULL, $language = NULL, $template = TRUE, $version = NULL, $comments) {
   // l10n_community_requirements() makes sure there is a status
   // error if this is not installed.
   include_once 'Archive/Tar.php';
@@ -397,7 +414,7 @@ function l10n_community_export($uri, $re
   while ($string = db_fetch_object($result)) {
     if ($string->sid != $previous_sid) {
       // New string in the stream.
-      _l10n_community_export_string_files($string_files, $uri, $language, $template, $version, $export_string);
+      _l10n_community_export_string_files($string_files, $uri, $language, $template, $version, $export_string, $comments);
 
       // Now fill in the new string values.
       $previous_sid = $string->sid;
@@ -424,7 +441,7 @@ function l10n_community_export($uri, $re
   }
   if ($previous_sid > 0) {
     // Store the last string.
-    _l10n_community_export_string_files($string_files, $uri, $language, $template, $version, $export_string);
+    _l10n_community_export_string_files($string_files, $uri, $language, $template, $version, $export_string, $comments);
   }
 
   if (empty($string_files)) {
@@ -450,11 +467,16 @@ function l10n_community_export($uri, $re
     $tar = new Archive_Tar($tempfile, 'gz');
   }
   foreach ($string_files as $filename => $fileinfo) {
-    if (count($fileinfo['revisions']) == 1) {
-      $file_list = '# Generated from file: '. $fileinfo['revisions'][0] ."\n";
+    if ($comments) {
+      if (count($fileinfo['revisions']) == 1) {
+        $file_list = '# Generated from file: '. $fileinfo['revisions'][0] ."\n";
+      }
+      else {
+        $file_list = '# Generated from files:'."\n#  ". join("\n#  ", $fileinfo['revisions']) ."\n";
+      }
     }
     else {
-      $file_list = '# Generated from files:'."\n#  ". join("\n#  ", $fileinfo['revisions']) ."\n";
+      $file_list = '';
     }
 
     $release_title = $project->title .' ('. (isset($release) ? $release->title : 'all releases') .')';
