Using the wp i18n make-pot I can create a .pot file that can interpret .php files.
This is the command I use

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

This is good but because I use timber with my wordpress as its template engine, timber uses .twig files.
How can I use wp-cli create .pot command to look into .twig files?
I tried this command

wp i18n make-pot . languages/my-plugin.pot --include=*.twig

That creates the same .pot file that only interpreted .php and not .twig files as well.

Looking at github issues this is a open issue ease inheritance in order to support Twig/Timber.
Reading this thread I could not really come to a solution.

2 Answers 2


As you mentioned - it's an open issue so unlikely to have been resolved by any of the solutions in the thread... This seems to be the most likely working solution though

wp timber make-pot && wp i18n make-pot --merge=twig.pot

I haven't used timber before but check what file is created with wp timber make-pot and ensure that's the one merged into the i18n command

The other code examples refer to improvements in the i18n-command package itself


Looking at the ticket again this is actually just another "suggested" use case. But there's still hope...

According to this page on the timber GitHub support there are a few options available to you.

  1. Use a tool that supports parsing Twig files to detect all your translations like Poedit. This will make your .pot files and the merge command can be run to work it into the i18n function.
  2. A nasty twig vs. gettext hack is to add {#<?php#} to the top of your twig files. By doing this, gettext will interpret whatever comes next as PHP, and start looking for __.
  3. Twig gettext extractor - a special Twig parser for Poedit.
  4. There is mention of a gulp script to do this... however the links I followed don't seem to work any more - this is the original ticket for the gulp solution though and can be used as a base if you feel like having a crack at that
  • This wp timber make-pot returns 'timber' is not recognized as an internal or external command, it doesn't seem that you need to add timber to PATH, don't even know where to look for it, as timber is installed via composer Dec 21, 2021 at 11:28
  • Have edited the answer @Buttered_Toast
    – Bysander
    Dec 21, 2021 at 12:13
  • Apologize for the delayed comment. Will check all those resources and let you know. Dec 23, 2021 at 10:14

I had the same issue and located this package: timber/wp-i18n-twig https://packagist.org/packages/timber/wp-i18n-twig

After installing this package the wp i18n make-pot . languages/my-plugin.pot worked on .twig files as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.