I18n
The Make Pot package provides WP-CLI commands and utilities for extracting translatable strings and generating POT files for T2 blocks, extensions, and other components.
Last modified: June 2, 2025
Features
- WP-CLI command for generating
.pot
files from PHP and JSON sources. - Custom extractor for
extension.json
files to ensure all extension metadata is included in translations. - Integrates with the standard WordPress i18n workflow.
Usage
After installing and activating the package, you can use the following WP-CLI command:
wp t2 make-pot <source> [--include=<paths>] [--exclude=<paths>] [--output=<file>]
<source>
: The directory to scan for translatable strings.--include
: (Optional) Paths to include.--exclude
: (Optional) Paths to exclude.--output
: (Optional) Output file for the generated POT.
How it works
- The command is registered in
src/i18n-command.php
and uses theMakePot
class. - The
MakePot
class extends the standard WP-CLI MakePotCommand and adds support for extracting strings fromextension.json
files using theExtensionExtractor
. - Only files named
extension.json
are processed for JSON string extraction.
Example
wp t2 make-pot ./packages/block-library --output=languages/t2-block-library.pot
This will generate a POT file including all PHP and extension metadata strings.
File Structure
src/class-makepot.php
: Main command logic for extracting and generating POT files.src/class-extensionextractor.php
: Handles extraction of strings fromextension.json
.src/i18n-command.php
: Registers the WP-CLI command.