Exemplo n.º 1
0
 function xgettext($project, $dir, $output_file, $placeholders = array(), $excludes = array(), $includes = array())
 {
     $meta = array_merge($this->meta['default'], $this->meta[$project]);
     $placeholders = array_merge($meta, $placeholders);
     $meta['output'] = $this->realpath_missing($output_file);
     $placeholders['year'] = date('Y');
     $placeholder_keys = array_map(create_function('$x', 'return "{".$x."}";'), array_keys($placeholders));
     $placeholder_values = array_values($placeholders);
     foreach ($meta as $key => $value) {
         $meta[$key] = str_replace($placeholder_keys, $placeholder_values, $value);
     }
     $originals = $this->extractor->extract_from_directory($dir, $excludes, $includes);
     $pot = new PO();
     $pot->entries = $originals->entries;
     $pot->set_header('Project-Id-Version', $meta['package-name'] . ' ' . $meta['package-version']);
     $pot->set_header('Report-Msgid-Bugs-To', $meta['msgid-bugs-address']);
     $pot->set_header('POT-Creation-Date', gmdate('Y-m-d H:i:s+00:00'));
     $pot->set_header('MIME-Version', '1.0');
     $pot->set_header('Content-Type', 'text/plain; charset=UTF-8');
     $pot->set_header('Content-Transfer-Encoding', '8bit');
     $pot->set_header('PO-Revision-Date', date('Y') . '-MO-DA HO:MI+ZONE');
     $pot->set_header('Last-Translator', 'FULL NAME <EMAIL@ADDRESS>');
     $pot->set_header('Language-Team', 'LANGUAGE <*****@*****.**>');
     $pot->set_comment_before_headers($meta['comments']);
     $pot->export_to_file($output_file);
     return true;
 }