Example #1
0
 function 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();
     }
     $glossary = GP::$glossary->by_set_or_parent_project($translation_set, $project);
     $page = gp_get('page', 1);
     $filters = gp_get('filters', array());
     $sort = gp_get('sort', array());
     if ('random' == gp_array_get($sort, 'by')) {
         add_filter('gp_pagination', '__return_null');
     }
     $per_page = get_user_option('gp_per_page');
     if (0 == $per_page) {
         $per_page = GP::$translation->per_page;
     } else {
         GP::$translation->per_page = $per_page;
     }
     $translations = GP::$translation->for_translation($project, $translation_set, $page, $filters, $sort);
     $total_translations_count = GP::$translation->found_rows;
     $can_edit = $this->can('edit', 'translation-set', $translation_set->id);
     $can_write = $this->can('write', 'project', $project->id);
     $can_approve = $this->can('approve', 'translation-set', $translation_set->id);
     $url = gp_url_project($project, gp_url_join($locale->slug, $translation_set->slug));
     $set_priority_url = gp_url('/originals/%original-id%/set_priority');
     $discard_warning_url = gp_url_project($project, gp_url_join($locale->slug, $translation_set->slug, '-discard-warning'));
     $set_status_url = gp_url_project($project, gp_url_join($locale->slug, $translation_set->slug, '-set-status'));
     $bulk_action = gp_url_join($url, '-bulk');
     // Add action to use different font for translations
     add_action('gp_head', function () use($locale) {
         return gp_preferred_sans_serif_style_tag($locale);
     });
     $this->tmpl('translations', get_defined_vars());
 }
Example #2
0
<?php

gp_title(sprintf(__('Translations &lt; %s &lt; %s &lt; GlotPress'), $translation_set->name, $project->name));
gp_breadcrumb(array(gp_project_links_from_root($project), gp_link_get($url, $translation_set->name)));
wp_enqueue_script('jquery-ui');
wp_enqueue_script('editor');
wp_enqueue_script('translations-page');
wp_localize_script('translations-page', '$gp_translations_options', array('sort' => __('Sort'), 'filter' => __('Filter')));
// localizer adds var in front of the variable name, so we can't use $gp.editor.options
$editor_options = compact('can_approve', 'can_write', 'url', 'discard_warning_url', 'set_priority_url', 'set_status_url');
wp_localize_script('editor', '$gp_editor_options', $editor_options);
$parity = gp_parity_factory();
add_action('gp_head', function () use($locale) {
    return gp_preferred_sans_serif_style_tag($locale);
});
gp_tmpl_header();
$i = 0;
?>
<h2>
	<?php 
printf(__("Translation of %s"), esc_html($project->name));
?>
: <?php 
echo esc_html($translation_set->name);
?>
	<?php 
gp_link_set_edit($translation_set, $project, __('(edit)'));
?>
	<?php 
if ($glossary) {
    ?>