Making WordPress.org

Changeset 2069


Ignore:
Timestamp:
11/10/2015 11:24:24 PM (9 years ago)
Author:
obenland
Message:

Translate: Use table ordering logic from Stats Overview.

See [2065], #1365.

Location:
sites/trunk/translate.wordpress.org
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/translate.wordpress.org/includes/gp-plugins/wporg-routes/routes/wp-plugins.php

    r2051 r2069  
    5757        unset( $project_path, $locale_key, $rows, $set, $sub_project );
    5858
    59         // Order by waiting strings, ascending.
    60         uksort( $translation_locale_statuses, function ( $a, $b ) use ( $translation_locale_statuses ) {
    61             if ( $translation_locale_statuses[ $a ]['untranslated'] > $translation_locale_statuses[ $b ]['untranslated'] ) {
     59        // Calculate a list of [Locale] = % subtotals
     60        $translation_locale_complete = array();
     61        foreach ( $translation_locale_statuses as $locale => $sets ) {
     62            unset( $sets['waiting'] );
     63            $translation_locale_complete[ $locale ] = round( array_sum( $sets ) / count( $sets ), 3 );
     64        }
     65        unset( $locale, $sets );
     66
     67        // Sort by Percent Complete, secondly by Slug
     68        uksort( $translation_locale_complete, function ( $a, $b ) use ( $translation_locale_complete, $translation_locale_statuses ) {
     69            if ( $translation_locale_complete[ $a ] > $translation_locale_complete[ $b ] ) {
    6270                return 1;
    63             } elseif ( $translation_locale_statuses[ $a ]['untranslated'] == $translation_locale_statuses[ $b ]['untranslated'] ) {
    64                 return strnatcmp( $a, $b );
     71            } elseif ( $translation_locale_complete[ $a ] == $translation_locale_complete[ $b ] ) {
     72                if ( $translation_locale_statuses[ $a ]['waiting'] != $translation_locale_statuses[ $b ]['waiting'] ) {
     73                    return strnatcmp( $translation_locale_statuses[ $a ]['waiting'], $translation_locale_statuses[ $b ]['waiting'] );
     74                } else {
     75                    return strnatcmp( $a, $b );
     76                }
    6577            } else {
    6678                return -1;
  • sites/trunk/translate.wordpress.org/public_html/gp-templates/projects-wp-plugins.php

    r2054 r2069  
    4141        <tbody>
    4242            <?php
    43             foreach ( $translation_locale_statuses as $locale_slug => $set ) :
     43            foreach ( $translation_locale_complete as $locale_slug => $total_complete ) :
    4444                $gp_locale = GP_Locales::by_slug( $locale_slug );
    4545                $set_slug  = 'default';
     
    6464                    </th>
    6565                    <?php
    66                         if ( $set ) :
     66                        if ( $translation_locale_statuses[ $locale_slug ] ) :
    6767                            foreach ( array( 'dev', 'dev-readme', 'stable', 'stable-readme', 'waiting' ) as $subproject_slug ) :
    6868                                if ( isset( $translation_locale_statuses[ $locale_slug ][ $subproject_slug ] ) ) :
Note: See TracChangeset for help on using the changeset viewer.