我正在开发一个儿童主题,我想.pot
文件使用wp-cli
.
我遵循wp-cli handbook 并运行:
cd /media/sf_TOOLS/ubuntu-20.04/bin
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
然后在我运行的主题文件所在的文件夹中:
/media/sf_TOOLS/ubuntu-20.04/bin/wp-cli.phar i18n make-pot --domain=test-child . languages/test-child.pot
此命令生成
.pot
没有主题字符串的文件:
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"
所以使用
--debug
选项我得到了这个日志:
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)
似乎:
No valid theme stylesheet or plugin file found
.
在我运行的文件夹中wp-cli
有一个文件style.css
包含:
/*
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
*/
包含要翻译的字符串的主题文件位于
admin
子文件夹,下面是我希望在中看到的字符串示例
.pot
文件:
<button type="button" class="button rnc-user-image_remove <?php if ( empty($userImage) ) { echo \'hidden\'; } ?>"><?php _e(\'Remove this image\', \'test-child\'); ?></button>
我还在wordpress开发站点中测试了以下命令:
wp-content/themes/test-child
但我得到了同样的结果。
这里怎么了?
这里是wp-cli --info
结果:
$ /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
我在从官方存储库下载的主题上运行该命令时得到了相同的结果。