Back to Top

Create a .pot or .po File using Poedit

Previous Post:

Create a .pot or .po File using Poedit

Poedit1 is an extremely popular Gettext2 catalogs editing tool known for its ease of use and fast speed. Numerous WordPress developers and translators are now constantly using this tool to internationalize and localize plugins and themes.

During such internalization and localization processes, a .pot and .po file are created. They are identical in every aspect except for their purposes. A .pot file is often created by the plugin or theme author himself and then delivered along with that plugin or theme so that translators can translate such project using Poedit conveniently. When a translator finishes his job, a .po and a .mo file will be created and will be eventually used by end-users.

Creating a .pot file (for developers)

After you have downloaded Poedit and installed it, fire the application up and then choose File → New Catalog. You’re now at the ‘Project info’ tab. ‘Project name and version’ should be your plugin’s name, ‘Charset’ and ‘Source code charset’ should be ‘utf-8′. Switch to ‘Paths’ tab and choose to add a new item, as described in the screenshot below:

Add a new path

Add a new path

Type in a dot (.) to tell Poedit to search for PHP files in the same folder as the .pot file. Next switch to ‘Keywords’ tab, press the same ‘New item’ button and add all Gettext functions you use for your plugin, most of the time only __ and _e are needed. Make sure all necessary functions are added and press OK. Now press File again and save your file in the same folder as your plugin’s main file (i.e. the PHP file that WordPress will use to load your plugin). By default Poedit saves your file as a .po file but since the two files are identical you can get around that by simply choosing to save the .po file as a .pot file:

Save the .po file as .pot

Save the .po file as .pot

You can rename the .po file later if you wish. Remember to delete the .mo file created along with our fake .pot file because it is not needed by our translators.

After your .pot file is nicely saved, navigate to Catalog and choose to ‘Update from sources’:

Update .pot file from sources

Update .pot file from sources

Just sit back and wait for the process to complete. After you press OK the main screen should be filled with strings that need translating from all of your plugin’s PHP files, excellent! The last thing to do is to save the file again and packed it with your project (remember to again delete the .mo file because each time you save the .pot file another .mo file will be created).

Creating a .po file (for translators)

To create a .po file, simply follow these steps3:

.pot File Editting Screen

.pot File Editting Screen

  1. Download and install Poedit if you haven’t done so already.
  2. Download/request a .pot file or create one yourself if the plugin or theme doesn’t supply such file.
  3. Open the .pot file in Poedit.
  4. (See Image on the right) The box labeled (1) is the original message (in English) from the .pot file. The box labeled (2) is where you add your translation. Boxes labeled (3) and (4) are used for adding comments about the messages. These come in handy if you are working with a team of translators and would like to pass around ideas through the .po file.
  5. Go to File → Save as… to save your translations in a .po file. If you do not know how to name it, take a look at this page: http://codex.wordpress.org/WordPress_in_Your_Language. The name you should use is the combination of the project’s text domain (locate it inside codes) and a short string in parentheses next to a language’s name (e.g. French – Français (fr_FR)). For example, if the text domain is bwp-minify and the translation is French, just name the .po file bwp-minify-fr_FR.
  6. When you have finished translating, go to File → Save as… again to generate the .mo file. Or you can set your Poedit to always compile a .mo file when saving changes by clicking File → Preferences and on the Editor tab check the Automatically compile .mo file on save box.

Updating a .po (and .mo) file

Another task of a translator is to update a .po file whenever a particular project has just been updated with more strings to translate, or even obsolete ones. To update your .po file, again navigate to Catalog, but this time choose ‘Update from POT file’, and then choose the .pot file from which you would like to get updated contents. Next, translate the project as you would normally do and save all changes.

Now that you’ve known how to create a .po file, i.e. translate a plugin, please consider translating my WordPress plugins. Finished translations should be sent through the contact fom or through a direct email to contact (at) betterwp (dot) net. Thanks!

References

  1. http://www.poedit.net/index.php []
  2. http://www.gnu.org/software/gettext/ []
  3. http://codex.wordpress.org/Translating_WordPress#Transl ... ith_Poedit []
Print Article Trackback Trackback to this Article   Subscribe to Comments RSS Subscribe to Comments RSS
 Sponsor   Themes by Elegant Themes - Unlimited access to all themes for $39!

9 Opinions for Create a .pot or .po File using Poedit

  1. User's Gravatar
    1
    xman February 26, 2012 at 7:16 pm – Permalink

    thank you for the useful post

  2. User's Gravatar
    2
    md moniruzzaman August 23, 2012 at 8:16 am – Permalink

    Thanks. This tutorial saves a lot of time.

  3. User's Gravatar
    3
    summ3r September 4, 2012 at 6:59 pm – Permalink

    hi,

    my team just developed a new online software localization tool for getttext po files http://poeditor.com/
    it is a free translation utility, of course.
    here are some of its features:

    -unlimited projects
    -unlimited languages
    - unlimited terms
    - add contributors
    - option for open project – everyone can participate
    - stats
    - import from pot, po, xls, xlsx (for now)
    - export to po, mo, json, php array(for now)
    - support for context (without plurals for now)

    we would be grateful if you could try it out. any feedback is welcome. thank you!

    POEditor Team

    • User's Gravatar
      9
      Jay March 14, 2014 at 5:04 am – Permalink

      Seems you can barely maintain a website?

  4. User's Gravatar
    4
    Rakhitha Nimesh January 11, 2013 at 3:51 pm – Permalink

    Awesome post with easy to understand explanations. What are the other tools available for translation?

  5. User's Gravatar
    5
    Vee September 13, 2013 at 5:37 pm – Permalink

    This post really help me a lot, i found this post when I was buying the blanco theme from themeforest.net and this post really solve my problem about translating my website.

    Thank you a lot

  6. User's Gravatar
    6
    nasrul November 30, 2013 at 4:54 am – Permalink

    i have send indonesian translation, do you recieve it?thanks

  7. User's Gravatar
    7
    Luis January 26, 2014 at 3:22 am – Permalink

    Any idea when the developer updates the .po file and I don´t provide the .pot file and I don’t want to translate all over. Is there a way to generate a .pot file from the provided .po file from the developer or can I import the previous .po already translated to merge and use what was already translated. Any idea how to procedure for updates without the .pot file?

    • User's Gravatar
      8
      Khang Minh February 6, 2014 at 5:25 pm – Permalink

      According to my previous test a .pot file and a .po file are identical, so you can safely open the .po file in poedit and add your own translation, make sure you have renamed the file so you don’t overwrite original .po file.

Speak Up Your Mind!

An asterisk (*) indicates a required field and must be filled.




  • Web page and e-mail addresses turn into links automatically.
  • Wrap codes in: <code lang=""></code> or <pre lang="" extra="">
  • Lines and paragraphs break automatically.

Next Post: