WordPress.org

Making WordPress.org

Changeset 7808


Ignore:
Timestamp:
10/31/2018 04:54:04 PM (21 months ago)
Author:
ocean90
Message:

Translate: In wporg-translate make-core-pot enable JavaScript string extraction if supported.

See #3748.

File:
1 edited

Legend:

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

    r7807 r7808  
    5353        }
    5454
     55        $extract_js = version_compare( $wp_version, '5.0-beta', '>=' );
     56
    5557        $dry_run = Utils\get_flag_value( $assoc_args, 'dry-run', false );
    5658
    5759        $headers = wp_json_encode( [
    5860            'Report-Msgid-Bugs-To' => 'https://core.trac.wordpress.org/',
    59             'PO-Revision-Date'     => 'YEAR-MO-DA HO:MI+ZONE',
    6061        ], JSON_UNESCAPED_SLASHES );
    6162
    6263        $file_comment = sprintf(
    63             "Copyright (C) %s by the contributors\nThis file is distributed under the same license as the WordPress package.",
     64            'Copyright (C) %s by the contributors\nThis file is distributed under the same license as the WordPress package.',
    6465            date( 'Y' )
    6566        );
     
    7778
    7879        WP_CLI::line( $command );
    79         ! $dry_run && WP_CLI::runcommand( $command/*, [ 'launch' => false ]*/ );
     80        ! $dry_run && WP_CLI::runcommand( $command );
    8081
    8182        // Front end.
     83        $front_end_exclude = [
     84            'wp-admin/*',
     85            'wp-content/themes/*',
     86            'wp-includes/class-pop3.php',
     87            'wp-content/plugins/akismet/*',
     88            // External JavaScript libaries.
     89            'wp-includes/js/tinymce/*',
     90            'wp-includes/js/codemirror/*',
     91            'wp-includes/js/crop/*',
     92            'wp-includes/js/imgareaselect/*',
     93            'wp-includes/js/jcrop/*',
     94            'wp-includes/js/jquery/*',
     95            'wp-includes/js/mediaelement/*',
     96            'wp-includes/js/plupload/*',
     97            'wp-includes/js/swfupload/*',
     98            'wp-includes/js/thickbox/*',
     99            'wp-includes/js/tinymce/*',
     100            'wp-includes/js/tw-sack.js',
     101            '*.js.map', // TODO: Currently not parsable, https://wordpress.slack.com/archives/C02RP4T41/p1541003227208000.
     102        ];
     103
    82104        $command  = 'i18n make-pot ' . escapeshellarg( $this->source );
    83105        $command .= ' ' . escapeshellarg( $this->destination . '/wordpress.pot' );
    84         $command .= ' --exclude="wp-admin/*,wp-content/themes/*,wp-includes/class-pop3.php,wp-content/plugins/akismet/"';
     106        $command .= ' --exclude=' . escapeshellarg( implode( ',', $front_end_exclude ) );
    85107        $command .= ' --package-name=' . escapeshellarg( self::PACKAGE_NAME );
    86108        $command .= ' --headers=' . escapeshellarg( $headers );
    87109        $command .= ' --file-comment=' . escapeshellarg( $file_comment );
    88         $command .= ' --skip-js';
    89110        $command .= ' --skip-audit';
    90111        $command .= ' --ignore-domain';
    91112
     113        if ( ! $extract_js ) {
     114            $command .= ' --skip-js';
     115        }
     116
    92117        WP_CLI::line( $command );
    93         ! $dry_run && WP_CLI::runcommand( $command/*, [ 'launch' => false ]*/ );
     118        ! $dry_run && WP_CLI::runcommand( $command );
    94119
    95120        // Hello Dolly, included in admin.
     
    108133
    109134        WP_CLI::line( $command );
    110         ! $dry_run && WP_CLI::runcommand( $command/*, [ 'launch' => false ]*/ );
     135        ! $dry_run && WP_CLI::runcommand( $command );
    111136
    112137        // Admin.
     
    133158        $command .= ' --headers=' . escapeshellarg( $headers );
    134159        $command .= ' --file-comment=' . escapeshellarg( $file_comment );
    135         $command .= ' --skip-js';
     160        $command .= ' --skip-js'; // TODO: No use of wp.i18n, yet.
    136161        $command .= ' --skip-audit';
    137162        $command .= ' --ignore-domain';
    138163
    139164        WP_CLI::line( $command );
    140         ! $dry_run && WP_CLI::runcommand( $command/*, [ 'launch' => false ]*/ );
     165        ! $dry_run && WP_CLI::runcommand( $command );
    141166
    142167        unlink( $hello_dolly_pot );
     
    150175        $command .= ' --headers=' . escapeshellarg( $headers );
    151176        $command .= ' --file-comment=' . escapeshellarg( $file_comment );
    152         $command .= ' --skip-js';
     177        $command .= ' --skip-js'; // TODO: No use of wp.i18n, yet.
    153178        $command .= ' --skip-audit';
    154179        $command .= ' --ignore-domain';
    155180
    156181        WP_CLI::line( $command );
    157         ! $dry_run && WP_CLI::runcommand( $command/*, [ 'launch' => false ]*/ );
     182        ! $dry_run && WP_CLI::runcommand( $command );
    158183    }
    159184
Note: See TracChangeset for help on using the changeset viewer.