1.20.x gettext.inc _locale_export_po($language = NULL, $output = NULL)

Writes a generated PO or POT file to the output.

Parameters

stdClass $language: Language object to generate the output for, or NULL if generating translation template.

string $output: The PO(T) file to output as a string. See _locale_export_generate_po() on how it can be generated.

Related topics

File

includes/gettext.inc, line 1028
Gettext parsing and generating API.

Code

function _locale_export_po($language = NULL, $output = NULL) {
  // Log the export event.
  if (isset($language)) {
    $filename = $language->langcode . '.po';
    watchdog('locale', 'Exported %locale translation file: %filename.', array('%locale' => $language->name, '%filename' => $filename));
  }
  else {
    $filename = 'backdrop.pot';
    watchdog('locale', 'Exported translation file: %filename.', array('%filename' => $filename));
  }
  // Download the file for the client.
  backdrop_add_http_header('Content-Disposition', "attachment; filename=$filename");
  backdrop_add_http_header('Content-Type', 'text/plain; charset=utf-8');
  print $output;
  backdrop_exit();
}