Making WordPress.org

Changeset 9721


Ignore:
Timestamp:
04/14/2020 05:41:30 PM (5 years ago)
Author:
ocean90
Message:

Translate: Skip threshold check for building language packs for plugins/themes with an existing language pack.

Also, reduce initial threshold to 90%.

See https://make.wordpress.org/polyglots/?p=28345.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/inc/cli/class-language-pack.php

    r8489 r9721  
    1616    const BUILD_DIR = '/nfs/rosetta/builds';
    1717    const SVN_URL = 'https://i18n.svn.wordpress.org';
    18     const PACKAGE_THRESHOLD = 95;
     18    const PACKAGE_THRESHOLD = 90;
    1919
    2020    /**
     
    320320
    321321    /**
    322      * Retrieves activate language packs for a theme/plugin of a version.
     322     * Retrieves active language packs for a theme/plugin of a version.
    323323     *
    324324     * @param string $type    Type of the language pack. Supports 'plugin' or 'theme'.
     
    342342
    343343        return $active_language_packs;
     344    }
     345
     346    /**
     347     * Whether there's at least one active language pack for a theme/plugin of any version.
     348     *
     349     * @param string $type   Type of the language pack. Supports 'plugin' or 'theme'.
     350     * @param string $domain Slug of a theme/plugin.
     351     * @param string $locale WordPress locale.
     352     * @return boolean True if theme/plugin has an active language pack, false if not.
     353     */
     354    private function has_active_language_pack( $type, $domain, $locale ) {
     355        global $wpdb;
     356
     357        return (bool) $wpdb->get_var( $wpdb->prepare(
     358            'SELECT updated FROM language_packs WHERE type = %s AND domain = %s AND language = %s AND active = 1 LIMIT 1',
     359            $type,
     360            $domain,
     361            $locale
     362        ) );
    344363    }
    345364
     
    588607            }
    589608
    590             // Check if percent translated is above threshold.
    591             $percent_translated = $set->percent_translated();
    592             if ( ! $this->force && $percent_translated < self::PACKAGE_THRESHOLD ) {
    593                 WP_CLI::log( "Skip {$wp_locale}, translations below threshold ({$percent_translated}%)." );
    594                 continue;
     609            // Check if percent translated is above threshold for initial language pack.
     610            $has_existing_pack = $this->has_active_language_pack( $data->type, $data->domain, $wp_locale );
     611            if ( ! $has_existing_pack ) {
     612                $percent_translated = $set->percent_translated();
     613                if ( ! $this->force && $percent_translated < self::PACKAGE_THRESHOLD ) {
     614                    WP_CLI::log( "Skip {$wp_locale}, translations below threshold ({$percent_translated}%)." );
     615                    continue;
     616                }
     617            } else {
     618                WP_CLI::log( "Skipping threshold check for {$wp_locale}, has existing language pack." );
    595619            }
    596620
Note: See TracChangeset for help on using the changeset viewer.