WordPress.org

Making WordPress.org


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

Translate: Use table ordering logic from Stats Overview.

See [2065], #1365.

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