Generate the .pot
file to include all translatable strings:
wp i18n make-pot . /languages/my-plugin.pot --domain=my-plugin
.
: Root directory of your plugin./languages/my-plugin.pot
: Destination for the.pot
file.--domain=my-plugin
: Text domain of your plugin.
When adding new strings, run the same command to update the .pot
file:
wp i18n make-pot . /languages/my-plugin.pot --domain=my-plugin
For a plugin structure like:
my-plugin/
includes/
templates/
languages/
Run:
wp i18n make-pot my-plugin/ my-plugin/languages/my-plugin.pot --domain=my-plugin
- Ensure your text domain matches your plugin name.
- Use translation functions:
__()
,_e()
,_x()
, etc. - Backup
.po
and.mo
files before updating.pot
.
Quick and easy for handling translations!