Gettext PO-Files

PO files for use with Gettext.

File Extensions .po
API Extension gettext
Format Options No
Import Yes
Export Yes
Pluralization supported? Yes
Descriptions/Comments supported? Yes

Example

msgid ""
msgstr ""
"Language: en\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"
"X-Generator: PhraseApp (phraseapp.com)\n"

# This is the title of our app
msgid "app_title"
msgstr "My Software Project"

msgid "new_messages"
msgid_plural ""
msgstr[0] "You have a new message"
msgstr[1] "You have %{count} new messages"

#, fuzzy
msgid "Lorem"
msgstr "Ipsum"

A typical Gettext entry looks something like this:

# comment (Optional)
msgid "key-name"
msgstr "My Translation"

Gettext Header

The header of a Gettext file might contain a locale name and data for pluralization that PhraseApp will extract during import:

msgid ""
msgstr ""
"Language: en\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"
"X-Generator: PhraseApp (phraseapp.com)\n"

Comments

If you provide comments in your Gettext file we will add them as key descriptions during import:

# This is my description
msgid "app_title"
msgstr "My Software Project"

Context

Gettext uses the msgctxt notation to distinguish different contexts for the same msgid. In PhraseApp every key name must be unique thus we will add the msgctxt as the first part of the key name, separated by two pipe symbols (   ):
msgctxt "menu"
msgid "Open"
msgstr "some translation"

msgctxt "forum"
msgid "Open"
msgstr "some other translation"

In order to add the msgctxt to a new key, simply prepend it to the key name:

my_context||my_key_name

This will result in the following Gettext output:

...
msgctxt "my_context"
msgid "my_key_name"
...

Pluralization

Gettext supports plural forms for a translation:

msgid "new_messages"
msgid_plural ""
msgstr[0] "You have a new message"
msgstr[1] "You have %{count} new messages"

Fuzzy

The fuzzy keyword is used for translators verification. Thus fuzzy will automatically invoke the unverification process within your app. If you’re unfamiliar with verifications please have a look at the documentation on verification.

#, fuzzy
msgid "app_title"
msgstr "My Software Project"

Further Reading

  • Introduction to Gettext
  • Gettext Manual