[wp-meta] [Making WordPress.org] #3748: Consider using WP-CLI for string extraction

Making WordPress.org noreply at wordpress.org
Tue Aug 7 07:56:22 UTC 2018


#3748: Consider using WP-CLI for string extraction
--------------------------------------+--------------------
 Reporter:  swissspidy                |      Owner:  (none)
     Type:  enhancement               |     Status:  new
 Priority:  normal                    |  Milestone:
Component:  Translate Site & Plugins  |   Keywords:
--------------------------------------+--------------------
 The last 8 months or so I have been working on a new WP-CLI
 [https://github.com/wp-cli/i18n-command 18n-command] that makes it easier
 for WordPress projects to generate POT files.

 Before that, I have been using `makepot.php` for years, but the tool is
 not intuitive and really flexible. Also, with JavaScript
 internationalization (#wp20491) and Gutenberg being a thing, it was clear
 that `makepot.php` wasn't the right tool for the job anymore.

 Then there's also issues like #3601 and #wp42747 that make it harder for
 WordPress projects to really use `makepot.php`. Even for WordPress core I
 discovered two cases where strings were not extracted at all:

 * `<strong>ERROR</strong>: "Table Prefix" can only contain numbers,
 letters, and underscores.` (source: wp-admin/setup-config.php:262)
 * `<strong>ERROR</strong>: "Table Prefix" must not be empty.` (source: wp-
 admin/setup-config.php:258)

 The WP-CLI command on the other hand does not have these issues.

 That's why I propose switching to this new WP-CLI command for string
 extraction on WordPress.org infrastructure.

 Some of the features:

 * Automatically detects plugins and themes and extracts file headers.
 * Allows extraction of only a specific text domain.
 * Supports JavaScript string extraction, even for JSX and ESNext.
 * Allows merging the resulting POT file with an existing one, e.g. one
 created by Babel.
 * Powerful rules to include/exclude specific directories (minified JS
 files, vendor, .git folder, etc.)
 * Supports extracting strings from WordPress core the same way it's done
 today with 4 different projects. See https://github.com/wp-cli/i18n-
 command/pull/69 for examples.
 * Can warn about strings with wrong placeholders, as well as misleading or
 missing translator comments. This could be very useful for core but also
 plugin/developers to improve polyglots UX.

 Also, the command is extensively tested with Behat (with PHPUnit tests for
 some parts planned) and is already used in
 [https://github.com/wearerequired/traduttore third-party projects].

 With WP-CLI being an official WordPress project and this new command being
 superior to makepot.php in many ways, I think we have an opportunity to
 consolidate lots of things here, reduce the maintenance burden, and to
 make it easier for people to use WordPress I18N tools and to contribute to
 them.

 It goes without saying that I'd love to help making this a reality, even
 if it means adding some new features to the command or fixing nasty bugs.

 I'd suggest giving this command a go locally with some plugin, theme, or
 core to get a feeling for it.

 Since we built it with WP-CLI 2.0 in mind, which should be released
 tomorrow, you might need to run the following commands to install it
 locally:

 {{{
 wp cli update --nightly
 wp package install wp-cli/i18n-command
 }}}

 Alternatively, you can check out the [https://github.com/wp-cli/i18n-
 command GitHub repository] and run it from within its directory (still
 requiring WP-CLI 2.0 though).

-- 
Ticket URL: <https://meta.trac.wordpress.org/ticket/3748>
Making WordPress.org <https://meta.trac.wordpress.org/>
Making WordPress.org


More information about the wp-meta mailing list