Making WordPress.org


Ignore:
Timestamp:
05/02/2020 10:13:03 AM (5 years ago)
Author:
ocean90
Message:

Translate: Remove unchanged template copies and update translation editor template to use renamed variable.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/translation-row-editor.php

    r8971 r9813  
    44 */
    55
    6 $user = wp_get_current_user();
    7 $can_reject_self = ( isset( $t->user->user_login ) && $user->user_login === $t->user->user_login && 'waiting' === $t->translation_status );
    86
    97$more_links = array();
    10 if ( $t->translation_status ) {
    11     $translation_permalink = gp_url_project_locale( $project, $locale->slug, $translation_set->slug, array( 'filters[status]' => 'either', 'filters[original_id]' => $t->original_id, 'filters[translation_id]' => $t->id ) );
     8if ( $translation->translation_status ) {
     9    $translation_permalink = gp_url_project_locale( $project, $locale->slug, $translation_set->slug, array( 'filters[status]' => 'either', 'filters[original_id]' => $translation->original_id, 'filters[translation_id]' => $translation->id ) );
    1210    $more_links['translation-permalink'] = '<a href="' . esc_url( $translation_permalink ) . '">Permalink to translation</a>';
    1311} else {
    14     $original_permalink = gp_url_project_locale( $project, $locale->slug, $translation_set->slug, array( 'filters[original_id]' => $t->original_id ) );
     12    $original_permalink = gp_url_project_locale( $project, $locale->slug, $translation_set->slug, array( 'filters[original_id]' => $translation->original_id ) );
    1513    $more_links['original-permalink'] = '<a href="' . esc_url( $original_permalink ) . '">Permalink to original</a>';
    1614}
    1715
    18 $original_history = gp_url_project_locale( $project, $locale->slug, $translation_set->slug, array( 'filters[status]' => 'either', 'filters[original_id]' => $t->original_id, 'sort[by]' => 'translation_date_added', 'sort[how]' => 'asc' ) );
     16$original_history = gp_url_project_locale( $project, $locale->slug, $translation_set->slug, array( 'filters[status]' => 'either', 'filters[original_id]' => $translation->original_id, 'sort[by]' => 'translation_date_added', 'sort[how]' => 'asc' ) );
    1917$more_links['history'] = '<a href="' . esc_url( $original_history ) . '">Translation History</a>';
    2018
     
    2422 * @since 2.3.0
    2523 *
    26  * @param array              $more_links      The links to be output.
    27  * @param GP_Project         $project        Project object.
    28  * @param GP_Locale          $locale          Locale object.
     24 * @param array $more_links The links to be output.
     25 * @param GP_Project $project Project object.
     26 * @param GP_Locale $locale Locale object.
    2927 * @param GP_Translation_Set $translation_set Translation Set object.
    30  * @param GP_Translation     $t              Translation object.
     28 * @param GP_Translation $translation Translation object.
    3129 */
    32 $more_links = apply_filters( 'gp_translation_row_template_more_links', $more_links, $project, $locale, $translation_set, $t );
    33 
    34 if ( is_object( $glossary ) ) {
    35     if ( ! isset( $glossary_entries_terms ) ) {
    36         $glossary_entries = $glossary->get_entries();
    37         $glossary_entries_terms = gp_sort_glossary_entries_terms( $glossary_entries );
    38     }
    39 
    40     $t = map_glossary_entries_to_translation_originals( $t, $glossary, $glossary_entries_terms );
    41 }
    42 
     30$more_links = apply_filters( 'gp_translation_row_template_more_links', $more_links, $project, $locale, $translation_set, $translation );
    4331?>
    44 <tr class="editor <?php echo gp_translation_row_classes( $t ); ?>" id="editor-<?php echo esc_attr( $t->row_id ); ?>" row="<?php echo esc_attr( $t->row_id ); ?>">
     32<tr class="editor <?php echo gp_translation_row_classes( $translation ); ?>" id="editor-<?php echo esc_attr( $translation->row_id ); ?>" row="<?php echo esc_attr( $translation->row_id ); ?>">
    4533    <td colspan="<?php echo $can_approve ? 5 : 4 ?>">
    4634        <div class="editor-panel">
     
    5038                    $status = sprintf(
    5139                        '<span class="panel-header__bubble%s">%s</span>',
    52                         $t->translation_status ? ' panel-header__bubble--' . $t->translation_status : '',
    53                         display_status( $t->translation_status )
     40                        $translation->translation_status ? ' panel-header__bubble--' . $translation->translation_status : '',
     41                        display_status( $translation->translation_status )
    5442                    );
    5543
    56                     $warnings_count = wporg_gp_count_warnings( $t );
     44                    $warnings_count = wporg_gp_count_warnings( $translation );
    5745                    $warnings_info  = '';
    5846                    if ( $warnings_count ) {
     
    8775                </div>
    8876                <div class="panel-content">
    89                     <?php
    90                     $singular = isset( $t->singular_glossary_markup ) ? $t->singular_glossary_markup : esc_translation( $t->singular );
    91                     $plural   = isset( $t->plural_glossary_markup ) ? $t->plural_glossary_markup : esc_translation( $t->plural );
    92                     ?>
    9377                    <div class="source-string strings">
    94                         <?php if ( ! $t->plural ) : ?>
     78                        <?php
     79                        $singular = $translation->singular_glossary_markup ?? esc_translation( $translation->singular );
     80                        $plural   = $translation->plural_glossary_markup ?? esc_translation( $translation->plural );
     81
     82                        if ( ! $translation->plural ) : ?>
    9583                            <div class="source-string__singular">
    9684                                <span class="original"><?php echo prepare_original( $singular ); ?></span>
    97                                 <span aria-hidden="true" class="original-raw"><?php echo esc_translation( $t->singular ); ?></span>
     85                                <span aria-hidden="true" class="original-raw"><?php echo esc_translation( $translation->singular ); ?></span>
    9886                            </div>
    9987                        <?php else: ?>
     
    10189                                <small>Singular:</small>
    10290                                <span class="original"><?php echo $singular; ?></span>
    103                                 <span aria-hidden="true" class="original-raw"><?php echo esc_translation( $t->singular ); ?></span>
     91                                <span aria-hidden="true" class="original-raw"><?php echo esc_translation( $translation->singular ); ?></span>
    10492                            </div>
    10593                            <div class="source-string__plural">
    10694                                <small>Plural:</small>
    10795                                <span class="original"><?php echo $plural; ?></span>
    108                                 <span aria-hidden="true" class="original-raw"><?php echo esc_translation( $t->plural ); ?></span>
     96                                <span aria-hidden="true" class="original-raw"><?php echo esc_translation( $translation->plural ); ?></span>
    10997                            </div>
    11098                        <?php endif; ?>
     
    112100
    113101                    <div class="source-details">
    114                         <?php if ( $t->context ): ?>
     102                        <?php if ( $translation->context ): ?>
    115103                            <details open class="source-details__context">
    116104                                <summary>Context</summary>
    117                                 <span class="context bubble"><?php echo esc_translation( $t->context ); ?></span>
     105                                <span class="context bubble"><?php echo esc_translation( $translation->context ); ?></span>
    118106                            </details>
    119107                        <?php endif; ?>
    120                         <?php if ( $t->extracted_comments ) :
    121                             $comments = trim( preg_replace( '/^translators:/ ', '', $t->extracted_comments ) );
     108                        <?php if ( $translation->extracted_comments ) :
     109                            $comments = trim( preg_replace( '/^translators:/ ', '', $translation->extracted_comments ) );
    122110                            ?>
    123111                            <details open class="source-details__comment">
     
    126114                            </details>
    127115                        <?php endif; ?>
    128                         <?php if ( $t->references ) : ?>
     116                        <?php if ( $translation->references ) : ?>
    129117                            <details class="source-details__references">
    130118                                <summary>References</summary>
    131                                 <?php wporg_references( $project, $t ); ?>
     119                                <?php wporg_references( $project, $translation ); ?>
    132120                            </details>
    133121                        <?php endif; ?>
     
    135123
    136124                    <div class="translation-wrapper">
    137                         <?php if ( $t->plural && $locale->nplurals > 1 ) : ?>
     125                        <?php if ( $translation->plural && $locale->nplurals > 1 ) : ?>
    138126                            <div class="translation-form-wrapper">
    139127                                <span>Form:</span>
     
    175163                        <?php endif; ?>
    176164
    177                         <?php if ( ! $t->plural ) : ?>
    178                             <?php wporg_gp_translate_textarea( $t, [ $can_edit, $can_approve_translation ] ); ?>
     165                        <?php if ( ! $translation->plural ) : ?>
     166                            <?php wporg_gp_translate_textarea( $translation, [ $can_edit, $can_approve_translation ] ); ?>
    179167                        <?php else : ?>
    180168                            <?php foreach( range( 0, $locale->nplurals - 1 ) as $plural_index ): ?>
    181                                 <?php wporg_gp_translate_textarea( $t, [ $can_edit, $can_approve ], $plural_index ); ?>
     169                                <?php wporg_gp_translate_textarea( $translation, [ $can_edit, $can_approve ], $plural_index ); ?>
    182170                            <?php endforeach; ?>
    183171                        <?php endif; ?>
     
    189177                                            type="button"
    190178                                            aria-label="<?php echo $can_approve_translation ? 'Save and approve translation' : 'Suggest new translation'; ?>"
    191                                             data-nonce="<?php echo esc_attr( wp_create_nonce( 'add-translation_' . $t->original_id ) ); ?>">
     179                                            data-nonce="<?php echo esc_attr( wp_create_nonce( 'add-translation_' . $translation->original_id ) ); ?>">
    192180                                        <?php echo $can_approve_translation ? 'Save' : 'Suggest'; ?>
    193181                                    </button>
     
    226214                        ?>
    227215                        <div class="suggestions-wrapper">
    228                             <?php do_action( 'wporg_translate_suggestions', $t ); ?>
     216                            <?php do_action( 'wporg_translate_suggestions', $translation ); ?>
    229217                        </div>
    230218                        <?php
     
    241229                    <div class="meta">
    242230
    243                         <?php if ( $t->translation_status ): ?>
     231                        <?php if ( $translation->translation_status ): ?>
    244232                            <div class="status-actions">
    245233                            <?php if ( $can_approve_translation ) : ?>
    246                                 <?php if ( 'current' !== $t->translation_status ) : ?>
    247                                     <button class="approve" tabindex="-1" data-nonce="<?php echo esc_attr( wp_create_nonce( 'update-translation-status-current_' . $t->id ) ); ?>"><strong>+</strong> <?php _e( 'Approve', 'glotpress' ); ?></button>
     234                                <?php if ( 'current' !== $translation->translation_status ) : ?>
     235                                    <button class="approve" tabindex="-1" data-nonce="<?php echo esc_attr( wp_create_nonce( 'update-translation-status-current_' . $translation->id ) ); ?>"><strong>+</strong> <?php _e( 'Approve', 'glotpress' ); ?></button>
    248236                                <?php endif; ?>
    249                                 <?php if ( 'rejected' !== $t->translation_status ) : ?>
    250                                     <button class="reject" tabindex="-1" data-nonce="<?php echo esc_attr( wp_create_nonce( 'update-translation-status-rejected_' . $t->id ) ); ?>"><strong>&minus;</strong> <?php _e( 'Reject', 'glotpress' ); ?></button>
     237                                <?php if ( 'rejected' !== $translation->translation_status ) : ?>
     238                                    <button class="reject" tabindex="-1" data-nonce="<?php echo esc_attr( wp_create_nonce( 'update-translation-status-rejected_' . $translation->id ) ); ?>"><strong>&minus;</strong> <?php _e( 'Reject', 'glotpress' ); ?></button>
    251239                                <?php endif; ?>
    252                                 <?php if ( 'fuzzy' !== $t->translation_status ) : ?>
    253                                     <button class="fuzzy" tabindex="-1" data-nonce="<?php echo esc_attr( wp_create_nonce( 'update-translation-status-fuzzy_' . $t->id ) ); ?>"><strong>~</strong> <?php _e( 'Fuzzy', 'glotpress' ); ?></button>
     240                                <?php if ( 'fuzzy' !== $translation->translation_status ) : ?>
     241                                    <button class="fuzzy" tabindex="-1" data-nonce="<?php echo esc_attr( wp_create_nonce( 'update-translation-status-fuzzy_' . $translation->id ) ); ?>"><strong>~</strong> <?php _e( 'Fuzzy', 'glotpress' ); ?></button>
    254242                                <?php endif; ?>
    255243                            <?php elseif ( $can_reject_self ): ?>
    256                                 <button class="reject" tabindex="-1" data-nonce="<?php echo esc_attr( wp_create_nonce( 'update-translation-status-rejected_' . $t->id ) ); ?>"><strong>&minus;</strong> <?php _e( 'Reject Suggestion', 'glotpress' ); ?></button>
    257                                 <button class="fuzzy" tabindex="-1" data-nonce="<?php echo esc_attr( wp_create_nonce( 'update-translation-status-fuzzy_' . $t->id ) ); ?>"><strong>~</strong> <?php _e( 'Fuzzy', 'glotpress' ); ?></button>
     244                                <button class="reject" tabindex="-1" data-nonce="<?php echo esc_attr( wp_create_nonce( 'update-translation-status-rejected_' . $translation->id ) ); ?>"><strong>&minus;</strong> <?php _e( 'Reject Suggestion', 'glotpress' ); ?></button>
     245                                <button class="fuzzy" tabindex="-1" data-nonce="<?php echo esc_attr( wp_create_nonce( 'update-translation-status-fuzzy_' . $translation->id ) ); ?>"><strong>~</strong> <?php _e( 'Fuzzy', 'glotpress' ); ?></button>
    258246                            <?php endif; ?>
    259247                            </div>
     
    263251                            <dt><?php _e( 'Status:', 'glotpress' ); ?></dt>
    264252                            <dd>
    265                                 <?php echo display_status( $t->translation_status ); ?>
     253                                <?php echo display_status( $translation->translation_status ); ?>
    266254                            </dd>
    267255                        </dl>
    268256
    269                         <?php if ( $t->translation_added && $t->translation_added != '0000-00-00 00:00:00' ): ?>
     257                        <?php if ( $translation->translation_added && $translation->translation_added != '0000-00-00 00:00:00' ): ?>
    270258                            <dl>
    271259                                <dt><?php _e( 'Date added:', 'glotpress' ); ?></dt>
    272                                 <dd><?php echo $t->translation_added; ?> GMT</dd>
     260                                <dd><?php echo $translation->translation_added; ?> GMT</dd>
    273261                            </dl>
    274262                        <?php endif; ?>
    275                         <?php if ( $t->user ) : ?>
     263                        <?php if ( $translation->user ) : ?>
    276264                            <dl>
    277265                                <dt><?php _e( 'Translated by:', 'glotpress' ); ?></dt>
    278                                 <dd><?php gp_link_user( $t->user ); ?></dd>
     266                                <dd><?php gp_link_user( $translation->user ); ?></dd>
    279267                            </dl>
    280268                        <?php endif; ?>
    281                         <?php if ( $t->user_last_modified && ( ! $t->user || $t->user->ID !== $t->user_last_modified->ID ) ) : ?>
     269                        <?php if ( $translation->user_last_modified && ( ! $translation->user || $translation->user->ID !== $translation->user_last_modified->ID ) ) : ?>
    282270                            <dl>
    283271                                <dt><?php
    284                                     if ( 'current' === $t->translation_status ) {
     272                                    if ( 'current' === $translation->translation_status ) {
    285273                                        _e( 'Approved by:', 'glotpress' );
    286                                     } elseif ( 'rejected' === $t->translation_status ) {
     274                                    } elseif ( 'rejected' === $translation->translation_status ) {
    287275                                        _e( 'Rejected by:', 'glotpress' );
    288276                                    } else {
     
    291279                                    ?>
    292280                                </dt>
    293                                 <dd><?php gp_link_user( $t->user_last_modified ); ?></dd>
     281                                <dd><?php gp_link_user( $translation->user_last_modified ); ?></dd>
    294282                            </dl>
    295283                        <?php endif; ?>
     
    300288                                <dd><?php
    301289                                    echo gp_select(
    302                                         'priority-' . $t->original_id,
     290                                        'priority-' . $translation->original_id,
    303291                                        GP::$original->get_static( 'priorities' ),
    304                                         $t->priority,
     292                                        $translation->priority,
    305293                                        array(
    306294                                            'class'      => 'priority',
    307295                                            'tabindex'   => '-1',
    308                                             'data-nonce' => wp_create_nonce( 'set-priority_' . $t->original_id ),
     296                                            'data-nonce' => wp_create_nonce( 'set-priority_' . $translation->original_id ),
    309297                                        )
    310298                                    );
    311299                                    ?></dd>
    312300                            <?php else : ?>
    313                                 <dd><?php echo gp_array_get( GP::$original->get_static( 'priorities' ), $t->priority, 'unknown' ); // WPCS: XSS ok. ?></dd>
     301                                <dd><?php echo gp_array_get( GP::$original->get_static( 'priorities' ), $translation->priority, 'unknown' ); ?></dd>
    314302                            <?php endif; ?>
    315303                        </dl>
    316304                    </div>
    317305
    318                     <?php do_action( 'wporg_translate_meta', $t ); ?>
     306                    <?php do_action( 'wporg_translate_meta', $translation ); ?>
    319307                </div>
    320308            </div>
Note: See TracChangeset for help on using the changeset viewer.