Skip to content

Instantly share code, notes, and snippets.

@junaidtk
Last active September 22, 2022 07:03
Show Gist options
  • Save junaidtk/3d4a18b7e134a1cbb60eb242a4420597 to your computer and use it in GitHub Desktop.
Save junaidtk/3d4a18b7e134a1cbb60eb242a4420597 to your computer and use it in GitHub Desktop.
How to create pot file for the plugin or theme
Step: 1
-----------
Download the WordPress i18n tools directory from SVN using the following command.
svn co http://develop.svn.wordpress.org/trunk/tools/
It will be executed from the website root directory of wordpress. So your wordpress directory contain additional folder tools.
Step: 2
-------------
Create a Softlink of the wordpress directory using the below command.
ln -s . src
Step:3
-------------
Run below command to make pot file in the desired directoy.
php tools/i18n/makepot.php wp-plugin wp-content/plugins/plugin_folder wp-content/plugins/plugin_folder/plugin_text_domain.pot
It is executed from the wordpress root directory.
tools/i18n/makepot.php ----> The path to the makepot.php direcotry.
wp-plugin ----> Type project, it will be wp-theme for theme pot file.
wp-content/plugins/plugin_folder ----> Target folder directory, contain the plugin files.
wp-content/plugins/plugin_folder/plugin_text_domain.pot ----> Path to the newly created pot file.
This command will create a pot file of the plugin in the plugin folder.
if the target folder is just plugin_text_domain.pot, The pot file is created in the wordpress root directory.
This is for creating the Pot file, by using this Pot file, you can create the .PO file and .MO file.
The Po and mo file are saved in to the worddpress language folder wp-content --> languages --> plugin-folder-name OR
you need to add the po and mo file in the plugin language folder.
Reference Url:
http://majadc.com/generating-pot-file-i18n
https://www.vivathemes.com/create-pot-file-theme-plugin/
https://codex.wordpress.org/I18n_for_WordPress_Developers#Generating_a_POT_file
We can also create the POT file using the WP-cli tool
Install the wp-cli then run command as given below.
# Create a POT file for the WordPress plugin/theme in the current directory
$ wp i18n make-pot . languages/my-plugin.pot
This will create pot file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment