public function load_from_file($ext_filename) { $makepot = new MakePOT(); $source = $makepot->get_first_lines($ext_filename); $pot = ''; foreach ($this->headers as $header) { $string = $makepot->get_addon_header($header, $source); if (!$string) { continue; } $args = array('singular' => $string, 'extracted_comments' => $header . ' of the plugin/theme'); $entry = new Translation_Entry($args); $pot .= "\n" . PO::export_entry($entry) . "\n"; } return $pot; }
protected function makePot($path, $pot_file) { $makepot = new \MakePOT(); $slug = preg_replace("!^{$this->path}/(.*)\\.php!", '$1', $this->getPluginFile()); $makepot->wp_plugin($path, $pot_file, $slug); }
private function extract_project($project, $project_settings, $format_message = true) { $url_name = sprintf($this->source_type_templates[$project_settings[$project->id]['type']], $project_settings[$project->id]['setting']); $source_file = download_url($url_name); if (!is_wp_error($source_file)) { include dirname(__FILE__) . '/include/extract/makepot.php'; // Get a temporary file, use gpa as the first four letters of it. $temp_dir = tempnam(sys_get_temp_dir(), 'gpa'); $temp_pot = tempnam(sys_get_temp_dir(), 'gpa'); // Now delete the file and recreate it as a directory. unlink($temp_dir); mkdir($temp_dir); $zip = new ZipArchive(); if ($zip->open($source_file) === TRUE) { $zip->extractTo($temp_dir); $zip->close(); unlink($source_file); } else { unlink($source_file); return '<div class="notice updated"><p>' . sprintf(__('Failed to extract zip file: "%s".'), $source_file) . '</p></div>'; } $makepot = new MakePOT(); $makepot->generic($temp_dir, $temp_pot); $format = gp_array_get(GP::$formats, gp_post('format', 'po'), null); $translations = $format->read_originals_from_file($temp_pot); $this->delTree($temp_dir); unlink($temp_pot); if (FALSE === $translations) { return '<div class="notice updated"><p>' . __('Failed to read strings from source code.') . '</p></div>'; } list($originals_added, $originals_existing, $originals_fuzzied, $originals_obsoleted) = GP::$original->import_for_project($project, $translations); if (true === $format_message) { $message = '<div class="notice updated"><p>'; } $message .= sprintf(__('%1$s new strings added, %2$s updated, %3$s fuzzied, and %4$s obsoleted in the "%5$s" project.'), $originals_added, $originals_existing, $originals_fuzzied, $originals_obsoleted, $project->name); if (true === $format_message) { $message .= '</p></div>'; } } else { if (true === $format_message) { $message = '<div class="notice updated"><p>'; } $message .= sprintf(__('Failed to download "%s".'), $url_name) . '</p></div>'; if (true === $format_message) { $message .= '</p></div>'; } } return $message; }
function create_glotpress_projects($parent_project_path) { require_once $this->glotpress_source_dir . '/gp-load.php'; require_once dirname(__FILE__) . '/makepot.php'; $makepot = new MakePOT(); $parent_project = GP::$project->by_path($parent_project_path); if (!$parent_project) { echo "Couldn't find project with path {$parent_project_path}.\n"; return; } foreach ($this->importers as $importer) { $source = $makepot->get_first_lines($this->s($importer, '%trunk%/%importer%.php'), $makepot->max_header_lines); if (!GP::$project->by_path("{$parent_project_path}/{$importer}")) { $importer_project = GP::$project->create_and_select(array('name' => $makepot->get_addon_header('Plugin Name', $source), 'slug' => $importer, 'description' => $makepot->get_addon_header('Description', $source), 'parent_project_id' => $parent_project->id)); } else { echo "Project {$parent_project_path}/{$importer} already exists.\n"; } if (!GP::$project->by_path("{$parent_project_path}/{$importer}/dev")) { $trunk_project = GP::$project->create_and_select(array('name' => 'Development (trunk)', 'slug' => 'dev', 'description' => 'Development version of ' . $makepot->get_addon_header('Plugin Name', $source), 'parent_project_id' => $importer_project->id, 'source_url_template' => $this->s($importer, "http://plugins.trac.wordpress.org/browser/%importer%/trunk/%file%#L%line%"))); } else { echo "Project {$parent_project_path}/{$importer}/dev already exists.\n"; } } }
protected function makePot($path, $pot_file) { $makepot = new \MakePOT(); $makepot->wp_theme($path, $pot_file); }