1

I'm developing a child theme and I want to get .pot file using wp-cli.

I follow the wp-cli handbook and run:

cd /media/sf_TOOLS/ubuntu-20.04/bin
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar 

then in the folder where are theme files I run:

/media/sf_TOOLS/ubuntu-20.04/bin/wp-cli.phar i18n make-pot --domain=test-child . languages/test-child.pot

This command generate a .pot file without theme strings:

msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2020-12-29T09:38:20+01:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.4.0\n"
"X-Domain: test-child\n"

so using --debug option I got this log:

Debug (bootstrap): No readable global config found (1.419s)
Debug (bootstrap): No project config found (1.419s)
Debug (bootstrap): argv: /media/sf_TOOLS/ubuntu-20.04/bin/wp-cli.phar i18n make-pot --debug --domain=test-child . languages/test-child.pot (1.419s)
Debug (bootstrap): ABSPATH defined: / (1.447s)
Debug (hooks): Processing hook "before_run_command" with 1 callbacks (1.463s)
Debug (hooks): On hook "before_run_command": WP_CLI\Bootstrap\RegisterDeferredCommands->add_deferred_commands() (1.463s)
Debug (bootstrap): Running command: i18n make-pot (1.463s)
Debug (make-pot): No valid theme stylesheet or plugin file found, treating as a regular project. (1.603s)
Debug (make-pot): Extracting all strings with text domain "test-child" (1.604s)
Debug (make-pot): Destination: languages/test-child.pot (1.604s)
Debug (make-pot): Excluding the following files: node_modules,.git,.svn,.CVS,.hg,vendor,Gruntfile.js,webpack.config.js,*.min.js (2.047s)
Debug (make-pot): Extracted 0 strings (2.151s)
 

It seems that: No valid theme stylesheet or plugin file found.

In the folder where I run wp-cli there is a file style.css that contains:

/* 
Theme Name: Test Child
Theme URI: https://www.example.com/
Author: Test Author 
Author URI: https://www.example.com/
Description: Child Theme just for test.
Tags: translation-ready, custom-background, theme-options, custom-menu, threaded-comments, featured-images, footer-widgets, editor-style, right-sidebar, full-width-template, two-columns, grid-layout, custom-colors, custom-header, custom-logo, featured-image-header, portfolio, news, entertainment
Version: 1.0.8
Requires at least: 5.0
Tested up to: 5.4.1
Requires PHP: 5.6
License: Test License
License URI: https://www.example.com/test_license.html
Text Domain: test-child
Template: test
*/

Theme file that contains strings to be translated is in admin sub-folder, here is an example of string that I expect to see in .pot file:

<button type="button" class="button rnc-user-image_remove <?php if ( empty($userImage) ) { echo 'hidden'; } ?>"><?php _e('Remove this image', 'test-child'); ?></button>

I've also tested in my wordpress development site running command in:

wp-content/themes/test-child

but I got the same result.

What is wrong here?

Here is wp-cli --info result:

$ /media/sf_TOOLS/ubuntu-20.04/bin/wp-cli.phar --info
OS: Linux 5.4.0-58-generic #64-Ubuntu SMP Wed Dec 9 08:16:25 UTC 2020 x86_64
Shell:  /bin/bash
PHP binary: /usr/bin/php7.4
PHP version:    7.4.3
php.ini used:   /etc/php/7.4/cli/php.ini
WP-CLI root dir:    phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:  phar://wp-cli.phar/vendor
WP_CLI phar path:   /media/sf_TEST/test-child
WP-CLI packages dir:    
WP-CLI global config:   
WP-CLI project config:  
WP-CLI version: 2.4.0

I got the same result running the command on a theme downloaded from official repository.

1 Answer 1

0

The problem here is that Wordpress project folder is a shared folder on Ubuntu VirtualBox guest OS with guest additions.

Searching in wp cli source code, I found that to scan the directory is used:

$files = new IteratorIterator( new DirectoryIterator( $this->source ) );

and I could verify that it returns only . and .. files.

Moving Wordpress project files, for example, in $HOME directory and it works as expected.

make-pot needs mbstring package, so I have to install it with:

sudo apt-get install php-mbstring 

I don't know if it is a php bug or a Ubuntu bug, but on local filesystem it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.