public function print_exported_file($project, $locale, $translation_set, $entries)
{
$po = new $this->class();
// See https://www.gnu.org/software/gettext/manual/html_node/Header-Entry.html for header details.
// TODO: add more meta data in the project: language team, report URL.
$this->set_header($po, 'PO-Revision-Date', GP::$translation->last_modified($translation_set) . '+0000');
$this->set_header($po, 'MIME-Version', '1.0');
$this->set_header($po, 'Content-Type', 'text/plain; charset=UTF-8');
$this->set_header($po, 'Content-Transfer-Encoding', '8bit');
$this->set_header($po, 'Plural-Forms', "nplurals={$locale->nplurals}; plural={$locale->plural_expression};");
$this->set_header($po, 'X-Generator', 'GlotPress/' . GP_VERSION);
$language_code = $this->get_language_code($locale);
if (false !== $language_code) {
$this->set_header($po, 'Language', $language_code);
}
// Force export only current translations.
$filters = array();
$filters['status'] = 'current';
foreach ($entries as $entry) {
$po->add_entry($entry);
}
$current = $project;
$project_tree = array();
$project_tree[] = $current->name;
while ($current->parent_project_id > 0) {
$current = GP::$project->get($current->parent_project_id);
$project_tree[] = $current->name;
}
$project_tree = array_reverse($project_tree);
$project_id_version = implode(' - ', $project_tree);
/**
* Filter the project name and version header before export.
*
* @since 2.1.0
*
* @param string $project_id_version The default project name/version to use in the header and
* comments ( "Parent - Child - GrandChild - etc." by default).
* @param array $project_tree An array of the parent/child project tree, ordered from Parent
* to child to grandchild to etc...
*/
$project_id_version = apply_filters('gp_pomo_export_project_id_version', $project_id_version, $project_tree);
$this->set_header($po, 'Project-Id-Version', $project_id_version);
$this->add_comments_before_headers($po, "Translation of {$project_id_version} in {$locale->english_name}\n");
$this->add_comments_before_headers($po, "This file is distributed under the same license as the {$project_id_version} package.\n");
return $po->export();
}