How to Translate Gettext PO and POT Files with PTC

This guide walks you through translating PO files, working with POT and MO files, and automating localization with PTC.

PO files are a core component of software localization, commonly used in WordPress, Java applications, and projects that rely on the GNU gettext system. They store translations for a software’s user interface, allowing applications to support multiple languages.

As you work with PO files, you’ll also come across related formats like POT and MO files. This guide explains:

  • How PO, POT, and MO files work together in the localization process
  • How to prepare PO files for translation
  • How to automatically translate PO files using PTC

What Are POT, PO, and MO Files?

Before translating, it’s important to understand the role of POT, PO, and MO files:

.pot

POT (Portable Object Template) file

The Starting Point for Translations

Template for creating PO files

Doesn’t contain translations

Lists all the original text strings that need translation

Example:

msgid "Hello, World!"
msgstr ""
msgid "File not found"
msgstr ""
  • msgid entries contain the original strings in the source language
  • msgstr entries remain empty because the POT file serves as a template for the translations

.po

PO (Portable Object) file

Where You Store Translations

Stores the actual translations for your software’s user interface

Each entry in a PO file pairs an original string from your software with its translated version

Example:

#:path/to/source/file:23 
msgid "File not found" 
msgstr "Archivo no encontrado"
  • #: path/to/source/file:23 tells you where the original string is in your source code, making it easy to find and edit
  • msgid shows the original (source language) text
  • msgstr provides the translation

.mo

MO (Machine Object) file

Ready for Your Software to Use

A compiled, binary version of the PO file

Allows your software to access translations quickly and efficiently

Where Does an MO File Go?

WordPress: Place the MO file in the languages directory within your theme or plugin (e.g., wp-content/themes/your-theme/languages/).

GNU gettext: Place the MO file within a directory named after the locale (e.g., locale/es/LC_MESSAGES/ for Spanish).

Java: Store the MO file in a resource directory, often named resources or i18n, depending on your project’s structure.

Preparing for PO File Translation

Before translating PO files, take a moment to review your setup. This helps prevent missing translations, formatting issues, or problems when deploying multilingual content.

1. Make Sure Your PO and POT Files Are Set Up Correctly

PO and POT files work together in the localization process, so it’s important to check that they are properly structured. Before translating, confirm:

  • Your POT file includes all necessary text strings from your software
  • Each PO file is correctly generated from the POT file and isn’t missing key content
  • The files follow the standard gettext format, avoiding syntax errors that could cause issues later

If you’re translating a WordPress theme or plugin, you can make sure your product is translation-ready by checking our WordPress internationalization guide.

2. Decide Which Languages You Need

Define the target languages your software should support. This helps ensure:

  • Any language-specific formatting considerations (e.g., right-to-left text, pluralization rules) are accounted for
  • Your MO files will be placed in the correct locations for each language
  • The software can detect and load translations dynamically based on user preferences.

Translating PO Files

Once you prepare your PO files for localization, PTC makes translating them easy:

Code Repository Integration

Through a quick setup wizard, PTC connects to your software repository. PTC detects resource files in your repository, asks for additional details to provide context-aware translations, and lets you select target languages.

AI-Powered Translations

PTC uses advanced AI and machine learning technologies to deliver Better Than Human Translations. Your software’s localization will be fast and meet the highest standards, providing a better experience for your users.

Automatic Merge Requests for Translations

As you develop your software, PTC automatically detects changes to your PO files and translates new or updated strings. It then sends you merge requests with the translations, allowing you to review and merge them into your project.

Start Translating PO Files with PTC

Try PTC’s 30-day free trial and experience automated translations, easy Git integration, and faster localization.

Scroll to Top