Making WordPress.org


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

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

Fixes #4505.

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.