brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: wp i18n make-pot builds the translation template for a WordPress plugin

WordPress
~/tips/tip-wordpress-i18n-make-pot

wp i18n make-pot . languages/my-plugin.pot

Scans a plugin or theme for translatable strings and writes a POT file.

Translators need a POT file with every string your plugin or theme can show. WP-CLI makes one without Poedit.

From the plugin folder:

wp i18n make-pot . languages/my-plugin.pot

It scans PHP and JavaScript files for calls like __(), _e() and _n() and writes them all to the POT file with file and line references. The text domain comes from the Text Domain header in your main plugin file or style.css. --domain=my-plugin overrides it.

Some folders are always left out: node_modules, vendor, .git and minified *.min.js files. Add your own with --exclude=tests,build. If a bundler already extracts the JavaScript strings, --skip-js stops them from being counted twice.

I’d run this before every release, because a string that is not in the POT simply stays English. It only finds strings written as literal text, though. Something like __( $label, 'my-plugin' ) with a variable cannot be extracted, and that string will never be translated. The command does not warn you about it, so keep translatable text literal.

Further reading: wp i18n make-pot, Internationalization in plugins

Going deeper: Guide: let git bisect find the commit that broke your code

More WordPress tips wp user application-password create anna backup-script --porcelain define( 'MEDIA_TRASH', true ); wp cli check-update wp theme delete --all wp media image-size All WordPress tips (85) All topics

Link