Making WordPress.org

Changeset 6452


Ignore:
Timestamp:
01/28/2018 05:17:28 PM (6 years ago)
Author:
ocean90
Message:

Translate, Consistency: Add number of occurrences to translations.

Fixes #3274.

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

Legend:

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

    r6006 r6452  
    88?>
    99
    10 <p>Analyze translation consistency across projects.</p>
     10<p>Analyze translation consistency across projects. The result is limited to 500 translations.</p>
    1111
    1212
     
    8282        foreach ( $translations_unique as $translation ) {
    8383            printf(
    84                 '<li>%s <a href="#%s">&darr;</a></li>',
     84                '<li>%s <small>(%s)</small> <a href="#%s">&darr;</a></li>',
    8585                str_replace( ' ', '<span class="space"> </span>', esc_translation( $translation ) ),
     86                1 === $translations_unique_counts[ $translation ] ? $translations_unique_counts[ $translation ] . ' time' : $translations_unique_counts[ $translation ] . ' times',
    8687                esc_attr( sanitize_title( 't-' . $translation ) )
    8788            );
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/inc/routes/class-consistency.php

    r6006 r6452  
    5252        }
    5353
     54        $locale        = '';
     55        $set_slug          = '';
    5456        $locale_is_rtl = false;
     57
    5558        if ( $set ) {
    56             list( $locale, $slug ) = explode( '/', $set );
     59            list( $locale, $set_slug ) = explode( '/', $set );
    5760            $locale_is_rtl = 'rtl' === GP_Locales::by_slug( $locale )->text_direction;
    5861        }
     
    6063        $results = [];
    6164        $performed_search = false;
    62         if ( $search && $set ) {
     65        if ( $search && $locale && $set_slug ) {
    6366            $performed_search = true;
    6467            $results = $this->query( [
    6568                'search'         => $search,
    66                 'set'            => $set,
     69                'locale'         => $locale,
     70                'set_slug'       => $set_slug,
    6771                'case_sensitive' => $search_case_sensitive,
    6872                'project'        => $project,
     
    7175            $translations = wp_list_pluck( $results, 'translation', 'translation_id' );
    7276            $translations_unique = array_unique( $translations );
     77            $translations_unique_counts = array_count_values( $translations );
    7378        }
    7479
     
    112117        global $wpdb;
    113118
    114         list( $locale, $slug ) = explode( '/', $args['set'] );
    115 
    116119        if ( $args['case_sensitive'] ) {
    117120            $collation = 'BINARY';
     
    120123        }
    121124
    122         $search = $wpdb->prepare( "= {$collation} %s", $args['search'] );
    123 
    124         $locale = $wpdb->prepare( '%s', $locale );
    125         $slug = $wpdb->prepare( '%s', $slug );
     125        $search   = $wpdb->prepare( "= {$collation} %s", $args['search'] );
     126        $locale   = $wpdb->prepare( '%s', $args['locale'] );
     127        $set_slug = $wpdb->prepare( '%s', $args['set_slug'] );
    126128
    127129        $project_where = '';
     
    155157                AND t.status = 'current'
    156158                AND o.status = '+active' AND o.singular {$search}
    157                 AND ts.locale = {$locale} AND ts.slug = {$slug}
     159                AND ts.locale = {$locale} AND ts.slug = {$set_slug}
    158160                {$project_where}
    159161            LIMIT 0, 500
Note: See TracChangeset for help on using the changeset viewer.