Making WordPress.org

Changeset 9615


Ignore:
Timestamp:
03/22/2020 11:21:55 AM (4 years ago)
Author:
ocean90
Message:

Translate, Consistency: Add jump links for next/previous translation.

Fixes #4505.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins
Files:
3 edited

Legend:

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

    r6570 r9615  
    8282        foreach ( $translations_unique as $translation ) {
    8383            printf(
    84                 '<li>%s <small>(%s)</small> <a href="#%s">&darr;</a></li>',
     84                '<li>%s <small>(%s)</small> <a class="anchor-jumper with-tooltip" aria-label="Go to translation" href="#%s">&darr;</a></li>',
    8585                str_replace( ' ', '<span class="space"> </span>', esc_translation( $translation ) ),
    8686                1 === $translations_unique_counts[ $translation ] ? $translations_unique_counts[ $translation ] . ' time' : $translations_unique_counts[ $translation ] . ' times',
     
    100100        <tbody>
    101101            <?php
    102             $previous_translation = '';
    103 
     102            $previous_translation      = '';
     103            $translations_unique_index = 0;
    104104            foreach ( $results as $result ) {
    105105                $project_name = $result->project_name;
     
    120120
    121121                if ( $has_different_translations && $previous_translation !== $result->translation ) {
     122                    $prev_arrow = '';
     123                    $next_arrow = '';
     124
     125
     126                    if ( 0 === $translations_unique_index ) {
     127                        $next_arrow = '<a class="anchor-jumper with-tooltip" aria-label="Go to next translation" href="' . esc_attr( '#t-' . md5( $translations_unique[ $translations_unique_index + 1 ] ) ) . '">&darr;</a>';
     128                    } elseif ( $translations_unique_count - 1 === $translations_unique_index ) {
     129                        $prev_arrow = '<a class="anchor-jumper with-tooltip" aria-label="Go to previous translation" href="' . esc_attr( '#t-' . md5( $translations_unique[ $translations_unique_index - 1 ] ) ) . '">&uarr;</a>';
     130                    } else {
     131                        $prev_arrow = '<a class="anchor-jumper with-tooltip" aria-label="Go to previous translation" href="' . esc_attr( '#t-' . md5( $translations_unique[ $translations_unique_index - 1 ] ) ) . '">&uarr;</a>';
     132                        $next_arrow = '<a class="anchor-jumper with-tooltip" aria-label="Go to next translation" href="' . esc_attr( '#t-' . md5( $translations_unique[ $translations_unique_index + 1 ] ) ) . '">&darr;</a>';
     133                    }
     134
     135                    printf(
     136                        '<tr id="%s" class="new-translation"><th colspan="2"><strong>%s</strong> %s %s</th></tr>',
     137                        esc_attr( 't-' . md5( $result->translation ) ),
     138                        esc_translation( $result->translation ),
     139                        $next_arrow,
     140                        $prev_arrow
     141                    );
     142
    122143                    $previous_translation = $result->translation;
    123                     printf(
    124                         '<tr id="%s" class="new-translation"><td colspan="2"><strong>%s</strong> <a href="#translations-overview">&uarr;</a></td></tr>',
    125                         esc_attr( 't-' . md5( $result->translation ) ),
    126                         esc_translation( $result->translation )
    127                     );
     144                    $translations_unique_index++;
    128145                }
    129146
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/style.css

    r9558 r9615  
    20272027
    20282028.consistency-table tr.new-translation {
    2029     border-bottom-width: 3px;
     2029    border-bottom-width: 0;
    20302030}
    20312031
     
    20352035}
    20362036
    2037 .consistency-table tr.new-translation td {
    2038     padding: 40px 0 10px;
     2037.consistency-table tr.new-translation th {
     2038    position: sticky;
     2039    top: 0;
     2040    padding: 20px 0 10px;
     2041    background: #fff;
     2042    text-align: left;
     2043    box-shadow: 0 -1px 0 #e2e4e7, 0 3px 0 #e2e4e7;
     2044}
     2045
     2046@media screen and (min-width: 600px) {
     2047    .consistency-table tr.new-translation th {
     2048        top: 46px;
     2049    }
     2050}
     2051
     2052@media screen and (min-width: 783px) {
     2053    .consistency-table tr.new-translation th {
     2054        top: 32px;
     2055    }
     2056}
     2057
     2058.anchor-jumper {
     2059    padding: 0 5px;
     2060    font-weight: 600;
     2061}
     2062
     2063.consistency-table tr.new-translation th .anchor-jumper {
     2064    float: right;
    20392065}
    20402066
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/inc/routes/class-consistency.php

    r6570 r9615  
    7373            ] );
    7474
    75             $translations = wp_list_pluck( $results, 'translation', 'translation_id' );
    76             $translations_unique = array_unique( $translations );
     75            $translations               = wp_list_pluck( $results, 'translation', 'translation_id' );
     76            $translations_unique        = array_values( array_unique( $translations ) );
    7777            $translations_unique_counts = array_count_values( $translations );
    7878        }
Note: See TracChangeset for help on using the changeset viewer.