WPAutoPot: Auto Generate WordPress .POT for i18n & l10n

Auto Generate WordPress .POT (Portable Objects Template) files via NPM Scripts or Gulp.

πŸš€ GITHUB: β˜… 16 β‘‚ 0 β†’

 

WPAutoPot
Auto Generate WordPress .POT (Portable Objects Template) files via NPM Scripts or Gulp.
A FOSS (Free & Open Source Software) project. Maintained by @AhmadAwais.

Auto Generate WordPress .POT (Portable Objects Template) files via NPM Scripts or Gulp.

WPAutoPot

Make sure you have node installed. If not download and install node.

β†’ STEP #1: Install NodeJS & NPM

After installing NodeJS you can verify the install of both NodeJS and Node Package Manager by typing the following commands. This step needs to be followed only once i.e. if you don't have NodeJS installed. No need to repeat it ever again.

node -v
# v7.10.0

npm -v
# 4.2.0

β†’ Step #2. Download package.json

Download package.json file inside the root folder of your WordPress plugin or WordPress theme If you have cURL installed then you can run the following command to download it in one go (just make sure you open the root folder of your WordPress plugin or WordPress theme and download package.json file in it).

curl -L 'https://git.io/WPAutoPot' -o package.json

β†’ STEP #3: Configure NPM Scripts & Install WP-POT-CLI

Now, if you want to use NPM Scripts then you need to do the following:

  • Install the WP POT CLI β€” just run npm install --global wp-pot-cli in your terminal.
  • Configure the NPM script called pot β€” If you open the package.json file you can find it under scripts.
"scripts": {
    "pot": "wp-pot --src '**/*.php' --dest-file 'languages/WPAutoPot.pot' --package 'WPAutoPot' --domain 'WPAutoPot' --last-translator 'Ahmad Awais <[email protected]>' --team 'Team <[email protected]>' --bug-report 'https://your-domain.com/contact'"
}

In the pot script, you need to change

NOTE: That currently this little WP plugin has following file structure

β”œβ”€β”€ languages
|  └── WPAutoPot.pot
β”œβ”€β”€ package.json
β”œβ”€β”€ gulpfile.js
└── plugin.php

β†’ STEP #4: Run NPM Scripts

All that's left now is for you to run the NPM script in the root folder of your WP project β€” where you downloaded the package.json file.

NOTE: Before you run, make sure there is a languages directory. Otherwise running the script will display an error.

# Compile POT file.
npm run pot

β†’ STEP #5: Compile via Gulp β€” Installing Node Dependencies

If you want to use Gulp to compile the pot files. then follow the following steps otherwise jump to the last step.

We are in the root folder of our WordPress plugin or WordPress theme at the moment, let's install the Node Dependencies. In the terminal run this command and wait for it to download all the NodeJS dependencies. It's a one time process and can take about a minute depending on the internet speed of your connection.

# For MAC OS X run the following command with super user
sudo npm install

# For Linux run the following command
npm install

β†’ STEP #6: Download, Configure & Run Gulp

First of all, download the gulpfile.js file in the root folder .

curl -L 'https://git.io/WPAutoPotGulp' -o gulpfile.js

Now that you have gulpfile.js downloaded in the root, you can open it up and configure the info at the top where it says //β€” START Editing Project Variables. β€”//. till it says //β€” STOP Editing Project Variables. β€”//. (these lines)These are the similar project variables described in the Step #3.

All you have to do now is run gulp in your command line terminal and your translated POT file will get generated.

# Run gulp to compile .pot file.
gulp

GIF

β†’ STEP #7: Share!

Yup, there are no more steps. Just share it with your friends. Or Click to Tweet about it.

Contribute

Feel free to contribute. PR's are welcomed.

Changelog

Version 1.0.0

  • First version
  • Compile: POT files via NPM Scripts
  • Compile: POT files via Gulp

License

Released under MIT License. Copyright Ahmad Awais


πŸ™Œ β€” If 500 people signup here, I will build a video series for this.

It’s free and open source. Issues/PR’s are welcomed on GitHub.

πŸš€ GITHUB: β˜… 16 β‘‚ 0 β†’

Let me know what you think about this πŸ™‚

Ahmad Awais

I am a Full Stack WordPress Developer, WP Core Contributor, Front-end Fanatic , a Designer by night, and an accidental writer. I love to create optimized but advanced workflows to produce professionally built Open Source software.

Leave a thought

Your email address will not be published.

*
*