Making WordPress.org

Changeset 1139


Ignore:
Timestamp:
01/14/2015 12:20:37 PM (12 years ago)
Author:
ocean90
Message:

i18n Teams: Improve translation counts.

  • Fix division by zero warning.
  • Show 0% for locales which have the projects, but without translations.

see #340.

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

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams/views/all-locales.php

    r1061 r1139  
    6262                                        <td class="right no-right-border">
    6363                                                <a href="https://translate.wordpress.org/languages/<?php echo $locale->slug; ?>">
    64                                                         <?php echo ! empty( $percentages[ $locale->wp_locale ] ) ? $percentages[ $locale->wp_locale ] . '%' : '&mdash;'; ?>
     64                                                        <?php echo ( isset( $percentages[ $locale->wp_locale ] ) ) ? $percentages[ $locale->wp_locale ] . '%' : '&mdash;'; ?>
    6565                                                </a>
    6666                                        </td>
    … …  
    7979        </table>
    8080</div> <!-- /.translators-info -->
    81 
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams/wp-i18n-teams.php

    r1068 r1139  
    174174                }
    175175                foreach ( $counts as $locale => $count ) {
    176                         $percentages[ $locale ] = floor( $count['current'] / $count['total'] * 100 );
     176                        $percentages[ $locale ] = ( $count['total'] > 0 ) ? floor( $count['current'] / $count['total'] * 100 ) : 0;
    177177                }
    178178                set_transient( 'core_translation_data', $percentages, 900 );
Note: See TracChangeset for help on using the changeset viewer.