lloc / composer-i18n-scripts
Simplify the internationalization of your WordPress plugin or theme using WP-CLI — powered by Composer.
Installs: 16
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:composer-plugin
pkg:composer/lloc/composer-i18n-scripts
Requires
- composer-plugin-api: ^2.6
- wp-cli/wp-cli-bundle: ^2.12@dev
Requires (Dev)
- composer/composer: ^2.8
- phpstan/extension-installer: ^1.4
- phpunit/phpunit: ^12.3
- wp-coding-standards/wpcs: ^3.0
README
Automate the internationalization workflow of your WordPress plugin or theme by wiring WP-CLI translation tools into familiar Composer commands.
Requirements
- PHP 7.4+ and Composer 2.6+ (Composer plugin API 2.6 is required)
- WP-CLI 2.12+ available on your
$PATH - A WordPress plugin or theme with
Text DomainandDomain Pathheaders defined
Installation
composer require --dev lloc/composer-i18n-scripts
Composer automatically registers the plugin; no manual bootstrap code is needed. Running composer install on the project will keep the plugin active for all contributors.
Configuration
The plugin inspects your project root to infer settings:
- Themes: reads
style.css - Plugins: reads the main plugin file (matching the directory name or
index.php)
Provide headers like the following so WP-CLI receives the right text domain and language directory:
/* Plugin Name: Sample Plugin Text Domain: sample-plugin Domain Path: /languages */
If no metadata is found, defaults are Text Domain: messages and Domain Path: /languages.
Usage
Run the commands from the WordPress project root so that wp can load your environment.
| Command | Purpose |
|---|---|
composer i18n:make-pot |
Scan the source directory and generate languages/<domain>.pot. |
composer i18n:create-po <locale> |
Copy the .pot file to a locale-specific .po file (e.g. de_DE). |
composer i18n:update-po |
Merge the current .pot changes into every .po in languages/. |
composer i18n:make-mo |
Compile all .po files into .mo binaries. |
composer i18n:make-php |
Export .po translations into PHP array files for performance-sensitive setups. |
composer i18n:make-json |
Build JavaScript translation catalogs (*.json) without purging existing assets. |
Example workflow:
composer i18n:make-pot composer i18n:update-po composer i18n:make-json composer i18n:make-mo
Development
composer install– install dependencies and register the plugincomposer qa– PHPCS (WordPress Coding Standards) + PHPStan level 10composer tests– run PHPUnit suite undertests/Commandscomposer tests:coverage– generate HTML coverage intests/coverage/composer cs:fix– automatically fix style violations
Refer to AGENTS.md for contributor conventions, coding standards, and pull request expectations.
Troubleshooting
- “Text domain is not set”: ensure your plugin/theme headers declare
Text DomainandDomain Path. - WP-CLI not found: verify
wpis installed globally or provide an absolute path (e.g. symlinkwpinto/usr/local/bin). - Translations not picking up new strings: rerun
composer i18n:make-potbefore updating.pofiles so the template is up to date.