Making WordPress.org

Changeset 11768


Ignore:
Timestamp:
04/12/2022 06:52:51 PM (2 years ago)
Author:
ocean90
Message:

Translate: Update Slack notifications for #meta-language-packs.

  • Include project type in notifications for translation syncs.
  • Exclude lines for sets without any translations when building new language packs.
Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins
Files:
4 edited

Legend:

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

    r10222 r11768  
    619619                    continue;
    620620                }
    621             } else {
    622                 WP_CLI::log( "Skipping threshold check for {$wp_locale}, has existing language pack." );
    623621            }
    624622
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-plugin-directory/inc/language-pack/class-build-listener.php

    r8156 r11768  
    4747
    4848        // Build in a separate process.
    49         $cmd = WPORGTRANSLATE_WPCLI . ' wporg-translate language-pack generate plugin ' . escapeshellarg( $args['plugin'] ) . ' 2>&1';
     49        $cmd        = WPORGTRANSLATE_WPCLI . ' wporg-translate language-pack generate plugin ' . escapeshellarg( $args['plugin'] ) . ' 2>&1';
     50        $output     = [];
     51        $return_var = 0;
    5052        exec( $cmd, $output, $return_var );
     53        $output = array_filter( $output, fn( $line ) => ! str_ends_with( $line, ', no translations.' ) );
    5154        if ( $return_var ) {
    52             $message .= "\tFailure: " . implode( "\n\t", $output ) . "\n";
     55            $message .= 'Failure: ' . implode( "\n", $output ) . "\n";
    5356        } else {
    54             $message .= "\t" . implode( "\n\t", $output ) . "\n";
     57            $message .= implode( "\n", $output ) . "\n";
    5558        }
    5659
    57         $message .= "Language packs for {$args['plugin']} processed.\n";
     60        $message = trim( $message );
     61        if ( ! $message ) {
     62            $message = "No language packs for {$args['plugin']} generated.";
     63        }
    5864
    5965        $attachment = [
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-plugin-directory/inc/sync/class-translation-sync.php

    r11068 r11768  
    4949
    5050        // Sync translations only if the stable project was updated.
    51         if ( false === strpos( $project->path, '/stable' ) ) {
     51        if ( str_ends_with( $project->path, '/dev' ) || str_ends_with( $project->path, '/dev-readme' ) ) {
    5252            return;
    5353        }
     
    8585        }
    8686
    87         $sub_project = basename( $args['gp_project'] );
    88         $sub_project_counterpart = $this->project_mapping[ $sub_project ];
    89 
    9087        $timestamp = time();
    9188        $message   = '';
    92         $updates   = 0;
    9389
    9490        foreach ( $translation_sets as $translation_set ) {
     
    9894
    9995            // Sync translations in a separate process.
    100             $cmd = WPORGTRANSLATE_WPCLI . ' wporg-translate sync-plugin-translations ' . escapeshellarg( $args['gp_project'] ) . ' ' . escapeshellarg( $translation_set->locale ) . ' --set=' . escapeshellarg( $translation_set->slug ) . ' 2>&1';
    101             $output = '';
     96            $cmd        = WPORGTRANSLATE_WPCLI . ' wporg-translate sync-plugin-translations ' . escapeshellarg( $args['gp_project'] ) . ' ' . escapeshellarg( $translation_set->locale ) . ' --set=' . escapeshellarg( $translation_set->slug ) . ' 2>&1';
     97            $output     = [];
    10298            $return_var = 0;
    10399            exec( $cmd, $output, $return_var );
    104100            if ( $return_var ) {
    105                 $message .= "\tFailure: " . implode( "\n\t", $output ) . "\n";
     101                $message .= 'Failure: ' . implode( "\n", $output ) . "\n";
    106102            } else {
    107                 $message .= "\t" . implode( "\n\t", $output ) . "\n";
    108             }
    109             $updates += 1;
    110         }
    111 
    112         if ( ! $updates ) {
    113             $message .= "\tNo translations are available to sync.\n";
    114         }
    115 
    116         $message .= 'Translation sync was successfully processed.';
     103                $message .= implode( "\n", $output ) . "\n";
     104            }
     105        }
     106
     107        $message = trim( $message );
     108        if ( ! $message ) {
     109            $message = 'No translations are available to sync.';
     110        }
     111
     112        $type = str_ends_with( $project->path, '/dev-readme' ) ? 'readme' : 'code';
    117113
    118114        $attachment = [
    119             'title'      => "Translation Sync for {$args['plugin']}",
     115            'title'      => "Translation sync for {$type} of {$args['plugin']}",
    120116            'title_link' => "https://translate.wordpress.org/projects/wp-plugins/{$args['plugin']}",
    121117            'text'       => $message,
    122             'fallback'   => "Translations for {$args['plugin']} were synced.",
     118            'fallback'   => "Translations for {$type} of {$args['plugin']} were synced.",
    123119            'color'      => '#00a0d2',
    124120            'mrkdwn_in'  => [ 'text' ],
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-theme-directory/inc/language-pack/class-build-listener.php

    r8156 r11768  
    4747
    4848        // Build in a separate process.
    49         $cmd = WPORGTRANSLATE_WPCLI . ' wporg-translate language-pack generate theme ' . escapeshellarg( $args['theme'] ) . ' 2>&1';
     49        $cmd        = WPORGTRANSLATE_WPCLI . ' wporg-translate language-pack generate theme ' . escapeshellarg( $args['theme'] ) . ' 2>&1';
     50        $output     = [];
     51        $return_var = 0;
    5052        exec( $cmd, $output, $return_var );
     53        $output = array_filter( $output, fn( $line ) => ! str_ends_with( $line, ', no translations.' ) );
    5154        if ( $return_var ) {
    52             $message .= "\tFailure: " . implode( "\n\t", $output ) . "\n";
     55            $message .= 'Failure: ' . implode( "\n", $output ) . "\n";
    5356        } else {
    54             $message .= "\t" . implode( "\n\t", $output ) . "\n";
     57            $message .= implode( "\n", $output ) . "\n";
    5558        }
    5659
    57         $message .= "Language packs for {$args['theme']} processed.\n";
     60        $message = trim( $message );
     61        if ( ! $message ) {
     62            $message = "No language packs for {$args['theme']} generated.";
     63        }
    5864
    5965        $attachment = [
Note: See TracChangeset for help on using the changeset viewer.