We have now integrated Grunt into our workflow between Transifex and our WordPress plugins/themes, we thought sharing it with you.

With these set of grunt tasks you can:

  • Create a pot file.

  • Create a pot file and push it to Transifex.

  • Pull translations from Transifex and create the .mo files.

  • Extras: Build a zip folder of all your files – Ready to use.


Getting started

If you haven’t used Grunt before check out Chris Coyier’s post on getting started with Grunt.

And for more WP-Grunt tools check out Devin Price’s post Using Grunt with WordPress Themes.

Clone our GitHub repo, cd to the directory, run npm install to install the necessary packages.

git clone https://github.com/WP-Translations/grunt-transifex-wordpress 
cd grunt-transifex-wordpress 
npm install


TX client config file

In .tx->config replace the project_slug and the pot_slug by your own Transifex project data.

Creates pot

In your Gruntfile.js, replace in the section named makepot the data below:

makepot: {
 target: {
  options: {
   mainFile: 'foo.php', // Main project file.
   potFilename: 'foo.pot', // Name of the POT file.
   type: 'wp-plugin', // Type of project (wp-plugin or wp-theme).
   updateTimestamp: true, // Whether the POT-Creation-Date should be updated without other changes.

Creates pot and pushes it to Transifex

In your Gruntfile.js, replace in the section named exec the — minimum percentage value if needed:

exec: {
  txpull: { // Pull Transifex translation - grunt exec:txpull
   cmd: 'tx pull -a --minimum-perc=100' // Change the percentage with --minimum-perc=yourvalue

That’s it you’re ready to Grunt it now with those commands!

How it works

Creates pot

grunt makepot

Creates pot and pushes it to Transifex

grunt makandpush

Pulls translations from Transifex and creates the .mo files

grunt tx

Extras: Builds a zip folder of all your files – Ready to use

grunt build

More infos – Thanks to

grunt-wp-i18n by Bradley Vercher to generate the .pot files.

grunt-po2mo by Michele Bertoli to generate automatically the .mo files

transifex client the client command tool and much more…

All the Grunt Crew & @grappler the i18n Petit-Suisse expert 😉


    1. FxB

      Thanks for the compliment. This is definitely the idea: The all in one package, easy to implement with your actual workflow.

      About the api, for sure I thought about it but I’m kind of stuck, I’m a better translator than a developer. If you have any ideas, plans, I’ll be happy to join in and discuss them with you.

Leave a Reply

Your email address will not be published. Required fields are marked *