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.
Make sure you have node installed. If not download and install node.
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
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
Now, if you want to use NPM Scripts then you need to do the following:
npm install --global wp-pot-cli
in your terminal.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
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
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
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
Yup, there are no more steps. Just share it with your friends. Or Click to Tweet about it.
Feel free to contribute. PR's are welcomed.
Released under MIT License. Copyright Ahmad Awais
π β If 500 people signup here, I will build a video series for this.
This open source project is maintained by the help of awesome businesses listed below. What? Read more about it β
For anything else, tweet at @MrAhmadAwais
I have released a video course to help you become a better developer β Become a VSCode Power User β
It’s free and open source. Issues/PR’s are welcomed on GitHub.
Let me know what you think about this π