How to Translate Gettext PO and POT Files with PTC

PTC delivers Better Than Human AI translations for WordPress themes and plugins. Start with a .pot file and get translated .po and .mo files. Learn how to integrate .pot file translation into 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, connect your repo to PTC, and provide context about your software. After that, PTC delivers .po and .mo files with translations and automatically handles translation updates whenever your code changes.

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—it gets filled later 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: Connect Your Git Repository

PTC works by connecting to your GitHub, GitLab, or Bitbucket repository. This allows it to:

  • Detect .pot files
  • Send merge requests with translations in .po and .mo files directly to your repository

You don’t need to upload or download anything manually.

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

During the initial set up, PTC asks you to:

  • Select the languages you want to translate into. You can choose from 33 supported languages
  • Provide a short description of your plugin or theme, including what it does and who it’s for

PTC uses this information to generate Better Than Human Translations that are tailored to your project’s purpose and audience.

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

After PTC finishes translating, it sends a merge request to your repository. Use this chance to check that you see the correct translation files in the right place before merging.

You should see:

  • A .po (Portable Object) file for each language, with entries like:
msgid "Read more"
msgstr "Leer más"
  • A .mo (Machine Object) file for each .po. This is a compiled version that WordPress uses to load translations at runtime.
  • The files added to the correct folder in your repository.

If something looks incorrect, like a missing file or an unexpected folder path, go to Settings → Monitored Files in your PTC project and update the resource file settings.

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

PTC automatically keeps your PO and MO files updated. When the .pot file changes, PTC detects new or modified strings, translates them, and sends a merge request with the updates.

The only thing you need to update manually is content translated through Paste to translate, like the readme.txt. Just paste the updated text into PTC again if it changes.

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