wp i18n make-pot
Create a POT file for a WordPress project.
Scans PHP, Blade-PHP and JavaScript files for translatable strings, as well as theme stylesheets and plugin files if the source directory is detected as either a plugin or theme.
Synopsis
wp i18n make-pot <source> [<destination>] [--slug=<slug>] [--domain=<domain>] [--ignore-domain] [--merge[=<paths>]] [--subtract=<paths>] [--subtract-and-merge] [--include=<paths>] [--exclude=<paths>] [--headers=<headers>] [--location] [--skip-js] [--skip-php] [--skip-blade] [--skip-block-json] [--skip-theme-json] [--skip-audit] [--file-comment=<file-comment>] [--package-name=<name>]
Options
<source>
: Directory to scan for string extraction.
[<destination>]
: Name of the resulting POT file.
[–slug=<slug>]
: Plugin or theme slug. Defaults to the source directory’s basename.
[–domain=<domain>]
: Text domain to look for in the source code, unless the --ignore-domain option is used. By default, the "Text Domain" header of the plugin or theme is used. If none is provided, it falls back to the project slug.
[–ignore-domain]
: Ignore the text domain completely and extract strings with any text domain.
[–merge[=<paths>]]
: Comma-separated list of POT files whose contents should be merged with the extracted strings. If left empty, defaults to the destination POT file. POT file headers will be ignored.
[–subtract=<paths>]
: Comma-separated list of POT files whose contents should act as some sort of denylist for string extraction. Any string which is found on that denylist will not be extracted.
[–subtract-and-merge]
: Whether source code references and comments from the generated POT file should be instead added to the POT file used for subtraction. Warning: this modifies the files passed to --subtract!
[–include=<paths>]
: Comma-separated list of files and paths that should be used for string extraction. If provided, only these files and folders will be taken into account. Simple glob patterns can be used.
[–exclude=<paths>]
: Comma-separated list of files and paths that should be skipped for string extraction. Simple glob patterns can be used. The following are always excluded: node_modules, .git, .svn, .CVS, .hg, vendor, *.min.js.
[–headers=<headers>]
: Array in JSON format of custom headers which will be added to the POT file.
[–location]
: Whether to write #: filename:line lines. Defaults to true, use --no-location to skip.
[–skip-js]
: Skips JavaScript string extraction.
[–skip-php]
: Skips PHP string extraction.
[–skip-blade]
: Skips Blade-PHP string extraction.
[–skip-block-json]
: Skips string extraction from block.json files.
[–skip-theme-json]
: Skips string extraction from theme.json files.
[–skip-audit]
: Skips string audit where it tries to find possible mistakes in translatable strings.
[–file-comment=<file-comment>]
: String that should be added as a comment to the top of the resulting POT file.
[–package-name=<name>]
: Name to use for package name in the resulting POT file’s Project-Id-Version header.
Examples
# Create a POT file for the WordPress plugin/theme in the current directory.
$ wp i18n make-pot . languages/my-plugin.pot
# Create a POT file for the continents and cities list in WordPress core.
$ wp i18n make-pot . continents-and-cities.pot --include="wp-admin/includes/continents-cities.php" --ignore-domain
# Create a POT file for the WordPress theme in the current directory with custom headers.
$ wp i18n make-pot . languages/my-theme.pot --headers='{"Report-Msgid-Bugs-To":"https://github.com/theme-author/my-theme/","POT-Creation-Date":""}'