Main menu

Working with Gettext in Loco

Loco can import and export PO, POT and MO files. This page describes how the various features of GNU Gettext are supported.


The most basic components of a PO file are the string pairs. In Gettext terminology, each pair represents a "message". Most commonly the "msgid" value represents your source language text and the "msgstr" value represents a target language.

Loco has its own concept of a translatable asset which is roughly analogous to a Gettext message. In most cases you can just treat them as the same thing, but see more detail for a better understanding of the differences.


Gettext "msgctxt" strings are equivalent to Loco's own context property. You can inspect an asset's properties with Loco by clicking on its :cog icon:.

Note how context differs from the notes field, which just provides information. The context field can be used to keep your assets unique when you export multiple strings with the same source text.

Fuzzy flags

Loco's built-in translation flags include a Fuzzy flag for just this purpose. You can flag and unflag translations as Fuzzy within Loco and they will be exported to PO files using the #, fuzzy notation.

Translations can be automatically flagged as Fuzzy when the source text changes if you enable this in your project settings.

Extracted comments

Gettext extracted comments are equivalent to Loco's own "notes" property. These notes are shown to translators and can be modified by clicking an asset's :cog icon: to access its properties.

Note the difference between "extracted comments" and "translator comments" in Gettext. Loco has its own commenting system and does not export team member conversations to PO files. Asset notes are exported to PO files using the #. comment.. notation.


Gettext source code references using the #: reference... notation are imported into Loco, but they serve no purpose. They are simply preserved for when you export your PO files again.


Importing plural forms using the Gettext "msgid_plural" notation is fully supported, although Loco has its own platform agnostic approach to managing them in your dashboard. Exporting PO files from Loco returns plurals to their original Gettext notation.

Within the main project management view you will see each plural form represented as an individually manageable asset, but in the dedicated translation editor you will see them combined into a single "message" for the convenience of translators.

Gettext messages vs Loco assets

If you're well versed in Gettext you may find it confusing that Loco has unique Asset IDs which are not the same as your "msgid" strings. It must be stressed that these IDs are additional to your source texts; your strings are not being altered.

If you don't require this additional identifier you can disable Asset IDs in your project settings.

Working with msgid strings

The Gettext file format was designed to use a source language (usually English) to look up translations in other languages. This is the way Gettext is commonly used. Your PO files might have entries like this one for Spanish:

msgid "Hello World!"
msgstr "Hola Mundo!"

If you were to import this file into Loco you would have one asset with two translations. The asset would have the ID "Hello-World" automatically generated, but your original msgid would be untouched and would be editable as the English "translation". If you were to export your PO file now, you would get your original strings back exactly as they went in.

If you were to modify your English "translation", it would automatically update the msgid in all future language exports. That means no complex merge operations to match your translations up with new source text.

That's the default way of working with Gettext, but there is an alternative:

Working with asset IDs

An alternative way to do things is to index your PO files by a generic key instead of the source text. If you're doing things this way, you might have an English PO file with entries like this:

msgid "greeting"
msgstr "Hello World!"

And a separate Spanish file with entries like this:

msgid "greeting"
msgstr "Hola Mundo!"

To import these files into Loco you simply tell the importer to treat your source keys as asset IDs. Then, your "greeting" identifier will be imported as your asset ID. Then to export the same PO file back out of Loco, tell the exporter to use IDs as the alternative lookup key.