Making WordPress.org

Changeset 8256


Ignore:
Timestamp:
02/15/2019 07:16:16 AM (8 years ago)
Author:
dd32
Message:

Translate: Update the plugin translate stats overview to only use the Code project, as many locales do not translate the entire readme which results in a skewed stats page.

A toggle may be included in the future, or a separate view for Readme status.

See #2290.

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/stats-plugin-themes-overview.php

    r8249 r8256  
    55$breadcrumb   = array();
    66$breadcrumb[] = gp_link_get( '/stats', __( 'Locale Stats' ) );
    7 $breadcrumb[] = gp_link_get( '/locales/' . $locale . '/' . $locale_slug, $gp_locale->native_name );
     7$breadcrumb[] = gp_link_get( '/locale/' . $locale . '/' . $locale_slug, $gp_locale->english_name );
    88$breadcrumb[] = trim( ucwords( $view ), 's' ) . ' translation status overview';
    99gp_breadcrumb( $breadcrumb );
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/inc/routes/class-stats.php

    r8249 r8256  
    195195                        }
    196196
    197                         if (
    198                                 'plugins' == $view &&
    199                                 (
    200                                         ! GP::$project->by_path( $items[$slug]->project->path . '/dev' )
    201                                         &&
    202                                         ! GP::$project->by_path( $items[$slug]->project->path . '/stable' )
    203                                 )
    204                         ) {
    205                                 // Not all top plugins are translation-aware, lets just skip those..
    206                                 unset( $items[ $slug ] );
    207                                 continue;
    208                         }
    209 
    210                         $project_ids[ $items[$slug]->project->id ] = $slug;
     197                        if ( 'plugins' == $view ) {
     198                                // For plugins, we're ignoring the Readme projects as they're not immediately useful.
     199                                // The display will use the "Code Stable" if present, else "Code Development"
     200                                $code_project =
     201                                        GP::$project->by_path( 'wp-' . $view . '/' . $slug . '/stable' ) ?:
     202                                        GP::$project->by_path( 'wp-' . $view . '/' . $slug . '/dev' );
     203
     204                                // No code project? This happens when the plugin isn't translatable. The readme projects still exist though.
     205                                if ( ! $code_project ) {
     206                                        unset( $items[ $slug ] );
     207                                        continue;
     208                                }
     209
     210                                $project_ids[ $code_project->id ] = $slug;
     211                        } else {
     212                                $project_ids[ $items[$slug]->project->id ] = $slug;
     213                        }
    211214                }
    212215
     
    219222                        $locale, $locale_slug
    220223                ) );
     224
     225                // Link Projects & Stats
    221226                foreach ( $stats as $row ) {
    222227                        $items[ $project_ids[ $row->project_id ] ]->stats = $row;
     228                }
     229
     230                // Final sanity check that we have data to display.
     231                foreach ( $items as $slug => $details ) {
     232                        if (
     233                                ! isset( $details->stats ) || // Didn't find any cached data for a project
     234                                ! $details->stats->all // Project has no strings, not useful for this interface
     235                        ) {
     236                                unset( $items[ $slug ] );
     237                        }
    223238                }
    224239
Note: See TracChangeset for help on using the changeset viewer.