WordPress.org

Making WordPress.org

Changeset 1163


Ignore:
Timestamp:
01/22/2015 07:18:11 PM (7 years ago)
Author:
ocean90
Message:

i18n Teams: Add filters for translation status.

see #340.

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

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams/css/i18n-teams.css

    r1061 r1163  
    1616}
    1717
     18.i18n-filter.current-filter {
     19    color: #555;
     20    border-bottom: 1px solid #555;
     21}
     22
    1823.translators-info tbody tr {
    1924    display: none;
    2025}
     26
    2127.show-all tbody tr,
    2228.translators-info.show-latest tbody tr.latest,
     
    2531.translators-info.show-major-behind-many tbody tr.major-behind-many,
    2632.translators-info.show-no-releases tbody tr.no-releases,
    27 .translators-info.show-no-site tbody tr.no-site {
     33.translators-info.show-no-site tbody tr.no-site,
     34.translators-info.show-translated-100 tbody tr.translated-100,
     35.translators-info.show-translated-95 tbody tr.translated-95,
     36.translators-info.show-translated-90 tbody tr.translated-90,
     37.translators-info.show-translated-50-less tbody tr.translated-50-less,
     38.translators-info.show-translated-50 tbody tr.translated-50 {
    2839    display: table-row;
    2940}
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams/js/i18n-teams.js

    r1061 r1163  
    22
    33$('.locale-filters').on( 'click', '.i18n-filter', function() {
     4    $( '.current-filter' ).removeClass( 'current-filter' );
    45    $( '.translators-info' )[0].className = 'translators-info show-' + $( this ).data( 'filter' );
     6    $( this ).addClass( 'current-filter' );
    57    return false;
    68});
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams/views/all-locales.php

    r1139 r1163  
    22    <p class="locale-filters">
    33    <?php
    4         $statuses = array(
    5             'all' => _n_noop( '%s locale.', '%s locales.' ),
     4        _e( 'Releases:', 'worg' );
     5
     6        $release_statuses = array(
     7            'all' => _n_noop( '%s locale.', '%s locales.', 'wporg' ),
    68            'latest' => _n_noop( '%s locale up to date.', '%s locales up to date.', 'wporg' ),
    79            'minor-behind' => _n_noop( '%s locale behind by minor versions.', '%s locales behind by minor versions.', 'wprog' ),
     
    1214        );
    1315
    14         foreach ( $statuses as $status => $nooped_plural ) {
     16        foreach ( $release_statuses as $status => $nooped_plural ) {
    1517            $string = translate_nooped_plural( $nooped_plural, $locale_data['status_counts'][ $status ] );
    1618            $string = sprintf( $string, sprintf( '<strong class="i18n-label %s">%s</strong>', $status, $locale_data['status_counts'][ $status ] ) );
    17             printf( '<a href="#" class="i18n-filter" data-filter="%s">%s</a> ', $status, $string );
     19            printf( ' <a href="#" class="i18n-filter" data-filter="%s">%s</a>', $status, $string );
     20        }
     21    ?>
     22    </p>
     23
     24    <p class="locale-filters">
     25    <?php
     26        _e( 'Translations:', 'worg' );
     27
     28        $translation_statuses = array(
     29            'all' => _n_noop( '%s locale.', '%s locales.', 'wporg' ),
     30            'translated-100' => _n_noop( '%s locale at 100%%.', '%s locales at 100%%.', 'wporg' ),
     31            'translated-95' => _n_noop( '%s locale has more than 95%%.', '%s locales have more than 95%%.', 'wporg' ),
     32            'translated-90' => _n_noop( '%s locale has more than 90%%.', '%s locales have more than 90%%.', 'wporg' ),
     33            'translated-50' => _n_noop( '%s locale has more than 50%%.', '%s locales have more than 50%%.', 'wporg' ),
     34            'translated-50-less' => _n_noop( '%s locale has less than 50%%.', '%s locales have less than 50%%.', 'wporg' ),
     35        );
     36
     37        foreach ( $translation_statuses as $status => $nooped_plural ) {
     38            $string = translate_nooped_plural( $nooped_plural, $locale_data['status_counts'][ $status ] );
     39            $string = sprintf( $string, sprintf( '<strong class="i18n-label %s">%s</strong>', $status, $locale_data['status_counts'][ $status ] ) );
     40            printf( ' <a href="#" class="i18n-filter" data-filter="%s">%s</a>', $status, $string );
    1841        }
    1942    ?>
     
    2346        <thead>
    2447            <tr>
    25                 <th colspan="2"><?php _e( 'Locale',      'wporg' ); ?></th>
    26                 <th><?php _e( 'WP Locale',   'wporg' ); ?></th>
    27                 <th><?php _e( 'Version',     'wporg' ); ?></th>
     48                <th colspan="2"><?php _e( 'Locale', 'wporg' ); ?></th>
     49                <th><?php _e( 'WP Locale', 'wporg' ); ?></th>
     50                <th><?php _e( 'Version', 'wporg' ); ?></th>
    2851                <th colspan="2">GlotPress</th>
    2952                <th><!-- intentionally blank --></th>
     
    3356        <tbody>
    3457            <?php foreach ( $locales as $locale ) : ?>
    35                 <tr class="locale-version <?php echo esc_attr( $locale_data[ $locale->wp_locale ]['status'] ); ?>">
     58                <?php
     59                $classes  = 'locale-version ';
     60                $classes .= $locale_data[ $locale->wp_locale ]['release_status'] . ' ' . $locale_data[ $locale->wp_locale ]['translation_status'];
     61                ?>
     62                <tr class="<?php echo trim( $classes ); ?>">
    3663                    <td class="no-right-border">
    3764                        <?php if ( $locale_data[ $locale->wp_locale ]['rosetta_site_url'] ) : ?>
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams/views/locale-details.php

    r1140 r1163  
     1<p><a href="<?php echo esc_url( get_permalink() ); ?>"><?php _e( '&larr; All locales', 'wporg' ); ?></a></p>
    12<div id="locale-header">
    23    <h1>
     
    5253
    5354
    54 <h2>Validators</h2>
     55<h2><?php _e( 'Validators', 'wporg' ); ?></h2>
    5556
    5657<?php if ( empty( $locale_data['validators'] ) ) : ?>
     
    7071
    7172
    72 <h2>Translators</h2>
     73<h2><?php _e( 'Translators', 'wporg' ); ?></h2>
    7374
    7475<?php if ( empty( $locale_data['translators'] ) ) : ?>
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams/wp-i18n-teams.php

    r1139 r1163  
    104104    public function get_locales_data() {
    105105        global $wpdb;
     106
     107        $cache = get_transient( 'wp_i18n_teams_locales_data' );
     108        if ( false !== $cache ) {
     109            return $cache;
     110        }
     111
    106112        $gp_locales = self::get_locales();
     113        $translation_data = $this->get_core_translation_data();
    107114        $locale_data = array();
    108115
    109         $statuses = array( 'no-site' => 0, 'no-releases' => 0, 'latest' => 0, 'minor-behind' => 0, 'major-behind-one' => 0, 'major-behind-many' => 0 );
     116        $statuses = array(
     117            'no-site'            => 0,
     118            'no-releases'        => 0,
     119            'latest'             => 0,
     120            'minor-behind'       => 0,
     121            'major-behind-one'   => 0,
     122            'major-behind-many'  => 0,
     123            'translated-100'     => 0,
     124            'translated-95'      => 0,
     125            'translated-90'      => 0,
     126            'translated-50'      => 0,
     127            'translated-50-less' => 0,
     128        );
    110129
    111130        $wporg_data = $wpdb->get_results( "SELECT locale, subdomain, latest_release FROM locales ORDER BY locale", OBJECT_K );
     
    114133            $subdomain = $wporg_data[ $locale->wp_locale ]->subdomain;
    115134            $latest_release = $wporg_data[ $locale->wp_locale ]->latest_release;
    116             $status = self::get_locale_status( $subdomain, $latest_release );
    117             $statuses[ $status ]++;
     135            $release_status = self::get_locale_release_status( $subdomain, $latest_release );
     136            $statuses[ $release_status ]++;
     137
     138            $translation_status = '';
     139            if ( isset ( $translation_data[ $locale->wp_locale ] ) ) {
     140                $translation_status = self::get_locale_translation_status( $translation_data[ $locale->wp_locale ] );
     141                $statuses[ $translation_status ]++;
     142            }
    118143
    119144            $locale_data[ $locale->wp_locale ] = array(
    120                 'status'           => $status,
    121                 'rosetta_site_url' => $subdomain ? 'https://' . $subdomain . '.wordpress.org' : false,
    122                 'latest_release'   => $latest_release ? $latest_release : false,
     145                'release_status'     => $release_status,
     146                'translation_status' => $translation_status,
     147                'rosetta_site_url'   => $subdomain ? 'https://' . $subdomain . '.wordpress.org' : false,
     148                'latest_release'     => $latest_release ? $latest_release : false,
    123149            );
    124150        }
    125151
    126152        $locale_data['status_counts'] = $statuses;
    127         $locale_data['status_counts']['all'] = array_sum( $statuses );
     153        $locale_data['status_counts']['all'] = count( $gp_locales );
     154        set_transient( 'wp_i18n_teams_locales_data', $locale_data, 900 );
    128155        return $locale_data;
    129156    }
     
    201228
    202229    /**
    203      * Determine the status of the given locale
     230     * Determine the release status of the given locale,
    204231     *
    205232     * @param string $rosetta_site_url
     
    208235     * @return string
    209236     */
    210     protected static function get_locale_status( $rosetta_site_url, $latest_release ) {
     237    protected static function get_locale_release_status( $rosetta_site_url, $latest_release ) {
    211238        if ( ! $rosetta_site_url ) {
    212239            return 'no-site';
     
    229256        }
    230257    }
     258
     259    /**
     260     * Determine the translation status of the given locale.
     261     *
     262     * @param int $percent_translated
     263     *
     264     * @return string
     265     */
     266    protected static function get_locale_translation_status( $percent_translated ) {
     267        if ( $percent_translated == 100 ) {
     268            return 'translated-100';
     269        } elseif ( $percent_translated >= 95 ) {
     270            return 'translated-95';
     271        } elseif ( $percent_translated >= 90 ) {
     272            return 'translated-90';
     273        } elseif ( $percent_translated >= 50 ) {
     274            return 'translated-50';
     275        } else {
     276            return 'translated-50-less';
     277        }
     278    }
    231279}
    232280
Note: See TracChangeset for help on using the changeset viewer.