Gettext PO Import / Export for Mobile

Using the gettext PO file format to import/export content in your apps

Within the Localize dashboard we provide you with an ability to import and export phrases and translations in various file formats.

You can also import/export Glossary terms.

Importing / Exporting

To see a general explanation of how importing and exporting works in Localize, click here. Be sure to adhere to the file requirements below so that Localize will be able to successfully read your files.

The gettext PO file format is used in Django apps, among others.


Import First!

gettext PO files for the source language must first be imported into the Localize dashboard so that the msgid is established for each phrase. Then upon subsequent exports, the msgid will be maintained.

Exporting phrases for which there is no msgid will result in an unusable gettext PO file!!!

File Requirements


UTF-8 Character Encoding

Be sure that you are using the UTF-8 character encoding when working with the external files you are creating for importing purposes, so that special characters like accents are encoded properly.

The following are the requirements for the gettext PO file format.

You can have as many comment lines and info lines as you want at the start of the file. Data will only start to be processed once the msgid and msgstr pairs start.

The following header data is optional:

  • Project-Id-Version: 1\n
  • MIME-Version: 1.0\n
  • Content-Type: text/plain; charset=UTF-8\n
  • Content-Transfer-Encoding: 8bit\n

The following data is required for each phrase:

  • msgid "PhraseKey": this is the key of the phrase as defined in your app
  • msgstr "source phrase | target language translation": this is the source phrase in an imported file, or a target language translation in an exported file
    • Optionally you could have multiple msgstr lines for one msgid.

The following data is optional for each phrase:

  • # A comment: a comment string


Django PO Files

Typically in a gettext PO file that is used in a Django application, there will be an empty msgid and a msgstr at the start of the file.

Example of an imported file for the source language.

# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <[email protected]>, YEAR.
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-09-04 20:27+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <[email protected]>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#: templates/localize.html:1
msgid "welcomeHeading"
msgstr "Welcome to a sample "
msgstr "Django application!"

#: templates/localize.html:2
msgid "subHeading"
msgstr "This is some generic copy to be translated"

#: templates/localize.html:3
msgid "mainText"
msgstr "We hope it helps with your localization process."

Example of an exported file for the target language of Spanish.

msgid ""
msgstr ""
"Project-Id-Version: 1\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

msgid "mainText"
msgstr "Esperamos que le ayude con su proceso de localización."

msgid "subHeading"
msgstr "Esta es una copia genérica para traducir"

msgid "welcomeHeading"
msgstr "¡Bienvenido a una aplicación de muestra de Django!"


If your import fails an error message will be displayed. Later, you can also view the error here under Import History.

Did this page help you?