Making WordPress.org


Ignore:
Timestamp:
04/12/2022 06:52:51 PM (4 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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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' ],
Note: See TracChangeset for help on using the changeset viewer.