function export_translations_get($project_path, $locale_slug, $translation_set_slug) { $project = GP::$project->by_path($project_path); $locale = GP_Locales::by_slug($locale_slug); if (!$project || !$locale) { return $this->die_with_404(); } $translation_set = GP::$translation_set->by_project_id_slug_and_locale($project->id, $translation_set_slug, $locale_slug); if (!$translation_set) { return $this->die_with_404(); } $format = gp_array_get(GP::$formats, gp_get('format', 'po'), null); if (!$format) { return $this->die_with_404(); } $export_locale = apply_filters('gp_export_locale', $locale->slug, $locale); $filename = sprintf('%s-%s.' . $format->extension, str_replace('/', '-', $project->path), $export_locale); $filename = apply_filters('gp_export_translations_filename', $filename, $format, $locale, $project, $translation_set); $entries = GP::$translation->for_export($project, $translation_set, gp_get('filters')); if (gp_has_translation_been_updated($translation_set)) { $last_modified = gmdate('D, d M Y H:i:s', gp_gmt_strtotime(GP::$translation->last_modified($translation_set))) . ' GMT'; $this->headers_for_download($filename, $last_modified); echo $format->print_exported_file($project, $locale, $translation_set, $entries); // As has_translation_been_updated() compared against HTTP_IF_MODIFIED_SINCE here, send an appropriate header. } else { $this->header('HTTP/1.1 304 Not Modified'); } }
public function gp_project_template_translation_set_extra($set, $project) { // Get the translation set's last update time, in GMT. $dt = gp_gmt_strtotime(GP::$translation->last_modified($set)); // Check to see if we have a valid time. if ($dt > 0) { // Output the last update info for the translation set. echo 'Last updated on ' . date($this->dateformat, $dt) . '<br>'; } else { // A 0 value for the time means there has never been an update done. echo 'Never updated<br>'; } }
/** * Has this translation been updated since the passed timestamp? * * @param GP_Translation_Set $translation_set Translation to check * @param int $timestamp Optional; unix timestamp to compare against. Defaults to HTTP_IF_MODIFIED_SINCE if set. * @return bool */ function gp_has_translation_been_updated($translation_set, $timestamp = 0) { // If $timestamp isn't set, try to default to the HTTP_IF_MODIFIED_SINCE header. if (!$timestamp && isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { $timestamp = gp_gmt_strtotime(wp_unslash($_SERVER['HTTP_IF_MODIFIED_SINCE'])); } // If nothing to compare against, then always assume there's an update available if (!$timestamp) { return true; } return gp_gmt_strtotime(GP::$translation->last_modified($translation_set)) > $timestamp; }
public function export_glossary_entries_get($project_path, $locale_slug, $translation_set_slug) { $project = GP::$project->by_path($project_path); $locale = GP_Locales::by_slug($locale_slug); if (!$project || !$locale) { return $this->die_with_404(); } $translation_set = GP::$translation_set->by_project_id_slug_and_locale($project->id, $translation_set_slug, $locale_slug); if (!$translation_set) { return $this->die_with_404(); } $glossary = GP::$glossary->by_set_id($translation_set->id); if (!$glossary) { return $this->die_with_404(); } $glossary_entries = GP::$glossary_entry->by_glossary_id($glossary->id); $filename = sprintf('%s-%s-glossary.csv', str_replace('/', '-', $project->path), $locale->slug); $last_modified = gmdate('D, d M Y H:i:s', gp_gmt_strtotime(GP::$glossary_entry->last_modified($glossary))) . ' GMT'; $this->headers_for_download($filename, $last_modified); $this->print_export_file($locale->slug, $glossary_entries); }
?> </h3> <ul> <?php foreach ($recent_projects as $project) { ?> <li> <p><?php echo gp_link_get($project->project_url, $project->set_name) . ': '; echo gp_link_get($project->project_url . '?filters[status]=either&filters[user_login]=' . $user->user_login, sprintf(_n('%s contribution', '%s contributions', $project->count, 'glotpress'), $project->count)); ?> </p> <p class="ago"> <?php printf(__('last translation about %s ago (UTC)', 'glotpress'), human_time_diff(gp_gmt_strtotime($project->last_updated))); ?> </p> </li> <?php } ?> </ul> </div> <div class="validates-projects"> <h3><?php _e('Validator to', 'glotpress'); ?> </h3> <?php
public function export_translations_get($project_path, $locale_slug, $translation_set_slug) { $project = GP::$project->by_path($project_path); $locale = GP_Locales::by_slug($locale_slug); if (!$project || !$locale) { return $this->die_with_404(); } $translation_set = GP::$translation_set->by_project_id_slug_and_locale($project->id, $translation_set_slug, $locale_slug); if (!$translation_set) { return $this->die_with_404(); } $format = gp_array_get(GP::$formats, gp_get('format', 'po'), null); if (!$format) { return $this->die_with_404(); } /** * Filter the locale in the file name of the translation set export. * * @since 1.0.0 * * @param string $slug Slug of the locale. * @param GP_Locale $locale The current locale. */ $export_locale = apply_filters('gp_export_locale', $locale->slug, $locale); $filename = sprintf('%s-%s.' . $format->extension, str_replace('/', '-', $project->path), $export_locale); /** * Filter the filename of the translation set export. * * @since 1.0.0 * * @param string $filename Filename of the exported translation set. * @param GP_Format $format Format of the export. * @param GP_Locale $locale Locale of the export. * @param GP_Project $project Project the translation set belongs to. * @param GP_Translation_Set $translation_set The translation set to be exported. */ $filename = apply_filters('gp_export_translations_filename', $filename, $format, $locale, $project, $translation_set); $entries = GP::$translation->for_export($project, $translation_set, gp_get('filters')); if (gp_has_translation_been_updated($translation_set)) { $last_modified = gmdate('D, d M Y H:i:s', gp_gmt_strtotime(GP::$translation->last_modified($translation_set))) . ' GMT'; $this->headers_for_download($filename, $last_modified); echo $format->print_exported_file($project, $locale, $translation_set, $entries); // As has_translation_been_updated() compared against HTTP_IF_MODIFIED_SINCE here, send an appropriate header. } else { $this->status_header(304); } }