Exemple #1
0
 function export_as_po()
 {
     if (!isset($this->project) || !$this->project) {
         $this->project = GP::$project->get($this->project_id);
     }
     // TODO: rename locale column to locale_slug and use freely $this->locale as the locale object
     $locale = GP_Locales::by_slug($this->locale);
     $po = new PO();
     // TODO: add more meta data in the project: language team, report URL
     // TODO: last updated for a translation set
     $po->set_header('PO-Revision-Date', gmdate('Y-m-d H:i:s+0000'));
     $po->set_header('MIME-Version', '1.0');
     $po->set_header('Content-Type', 'text/plain; charset=UTF-8');
     $po->set_header('Content-Transfer-Encoding', '8bit');
     $po->set_header('Plural-Forms', "nplurals={$locale->nplurals}; plural={$locale->plural_expression};");
     $po->set_header('X-Generator', 'GlotPress/' . gp_get_option('version'));
     $entries = GP::$translation->for_translation($this->project, $this, 'no-limit', array('status' => 'current'));
     foreach ($entries as $entry) {
         $po->add_entry($entry);
     }
     $po->set_header('Project-Id-Version', $this->project->name);
     return $po->export();
 }
Exemple #2
0
 function test_export_to_file()
 {
     $po = new PO();
     $entry = new Translation_Entry(array('singular' => 'baba'));
     $entry2 = new Translation_Entry(array('singular' => 'dyado'));
     $po->set_header('Project-Id-Version', 'WordPress 2.6-bleeding');
     $po->set_header('POT-Creation-Date', '2008-04-08 18:00+0000');
     $po->add_entry($entry);
     $po->add_entry($entry2);
     $temp_fn = $this->temp_filename();
     $po->export_to_file($temp_fn, false);
     $this->assertEquals($po->export(false), file_get_contents($temp_fn));
     $temp_fn2 = $this->temp_filename();
     $po->export_to_file($temp_fn2);
     $this->assertEquals($po->export(), file_get_contents($temp_fn2));
 }