How to Translate Gettext PO and POT Files with PTC

PTC delivers Better Than Human AI translations for WordPress themes and pluginsStart with a .pot file and get translated .po and .mo files. Learn how to make .pot file translation part of your development workflow.

This guide covers how to translate .pot files using PTC. If you want to learn how to internationalize your entire WordPress project, including JavaScript strings, see our guide to WordPress internationalization.

Translating PO Files with PTC: First-Time Setup

The initial setup requires a few steps. You’ll prepare your code, generate .pot files, set up your project in PTC, and provide context about your software. After that, PTC delivers .po and .mo files with translations.

Step 1: Wrap Translatable Text In WordPress Localization Functions

Use gettext functions to wrap any user-facing text in your code.

Correct – WordPress PHP example:

echo __( 'Read more', 'your-plugin' );
_e( 'Submit', 'your-plugin' );

Incorrect – Hardcoded string:

echo 'Read more';
echo 'Submit';

Hardcoded strings like this won’t be extracted into your .pot file and won’t get translated.

Step 2: Use Placeholders Correctly for Dynamic Text

Make sure to use placeholders like %s and %d when you include variable content in your strings. Avoid splitting sentences or concatenating strings.

Correct – Complete string with placeholders:

printf(__('You have %d new messages.', 'your-plugin'), $count);

Incorrect – String is broken and hard to translate:

echo __('You have', 'your-plugin') . $count . __('new messages.', 'your-plugin');

Breaking sentences into parts makes it difficult to maintain grammar and word order in many languages. This can lead to incorrect or awkward translations.

Step 3: Generate a POT File from the Source Code

Once your code uses __() and _e() properly, generate a .pot file. This file acts as a template that contains all original (untranslated) strings pulled from your theme or plugin.

For WordPress plugins and themes, you can use tools like WP-CLI:

wp i18n make-pot . languages/plugin-name.pot

Example of what a .pot file should look like:

msgid "Read more"
msgstr ""

msgid "Submit"
msgstr ""

Each entry starts with msgid, which holds the original (source) string. The msgstr is where the translation will go. In a .pot file, msgstr is always empty. The translations appear in the .po files.

Step 4: Sign-Up For a PTC Account (Free for 30 Days)

Create a PTC account to start translating. Your free trial gives you full, unlimited access for 30 days.

Step 5: Choose How You Want to Use PTC

PTC gives you three ways to connect your project and start translating:

Step 6: Complete PTC’s Setup So It Can Translate Your Project Accurately

During the initial set up, PTC asks you to:

  • Provide a short description of your plugin or theme, including what it does and who it’s for

Step 7:  Review and Confirm You Received the Correct Translation Files

After PTC finishes translating your .pot file, how it delivers the translated files depends on how you set up your project:

  • Git integration: PTC sends a merge request to your repository with the new .po and .mo files.
  • Manual file upload: You receive a ZIP file containing the translated files.
  • API integration: PTC returns the translated files as part of the API response.

Review the translated files to make sure:

  • You received a .po (Portable Object) file for each language, with entries like:
msgid "Read more"
msgstr "Leer más"
  • Each .po has a corresponding .mo file (the compiled version WordPress uses).

If you’re using Git and something looks incorrect—like a missing file or unexpected folder path—go to Settings → Monitored Files in your PTC dashboard and update the file paths.

Step 8: Load the Translations in WordPress

To make sure your plugin or theme uses the translations, load the text domain in your code. For example:

load_plugin_textdomain( 'your-text-domain', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );

This tells WordPress where to find your .mo files so it can load the correct translations when the user’s site language matches one of the available languages in your plugin or theme.

If your plugin or theme is hosted on WordPress.org, WordPress may try to overwrite your .mo files with translations created by the WordPress community. To prevent this, see how to make WordPress load your bundled translation files.

Step 9: Translate Your Plugin or Theme’s Readme.txt 

If your plugin or theme includes a readme.txt file, it won’t be picked up by PTC automatically. But it contains important content users see, like your plugin description, installation steps, and changelog. WordPress.org also uses your README file to populate the Details tab of your plugin or theme listing.

To translate it with PTC:

  1. In your PTC project dashboard, go to Translations → Paste to translate
  2. Paste sections of your readme.txt
  3. Select your target languages and click Translate

You can then copy the translations and bundle them with your theme or plugin. To learn how to make these translations appear on WordPress.org, check our WordPress internationalization guide.

Keeping Translations Up to Date

With Git integration, PTC automatically updates your .po and .mo files whenever the .pot file changes and sends the translations via merge request.

If you’re using the PTC API with your CI library, you canautomate translation updates by making the steps run as part of your CI/CD workflow.

If you uploaded files manually, you’ll need to upload the updated .pot file each time. For ongoing updates, consider switching to Git or API integration.

You’ll always need to manually update content translated through Paste to translate, like the readme.txt.

Start Translating POT Files with PTC

PTC makes it easy to localize your plugin, theme, or gettext-based software.
Try it free for 30 days.

Scroll to Top