Format · gettext

PO files (gettext)

The format of WordPress themes and plugins, most open-source projects and a great many PHP, Python and C programs. Open one here, translate it in the same grid as an XLIFF file, and export a .po in which only the strings you changed are different. The file never leaves your browser.

What you see

One row per string. A plural entry becomes one row per form the file has — form 0 shows the singular source, the others the plural — so a Russian file with three forms gives three rows. The context (msgctxt), the developer's comments, your own translator comments and the source references are in the Details panel beside the row.

The header entry and old, obsolete entries (the ones marked #~) are not rows. They are kept in the file exactly as they are.

Fuzzy is Draft

An empty msgstr opens as Empty, a fuzzy entry as Draft, anything else as Translated. The export keeps that link in both directions: when you confirm a fuzzy entry, the fuzzy flag goes, and so do the #| lines that said what the string used to be. Other flags stay.

#. Main window title
#: src/menu.c:41
#, fuzzy, c-format
#| msgid "Close %s"
msgid "Close %s now"
msgstr "%s schließen"
#. Main window title
#: src/menu.c:41
#, c-format
msgid "Close %s now"
msgstr "%s jetzt schließen"

A string you leave as Draft — your own unconfirmed work, or a translation AI filled in — is exported fuzzy. msgfmt leaves fuzzy entries out of the compiled catalogue, so nothing unconfirmed reaches your users until somebody confirms it. An entry you did not touch is not touched in the file either, fuzzy or not.

Only your strings change

The export is not a rewrite. It starts from the file you opened and replaces only the msgstr lines of the entries you changed (and their fuzzy flag). Comments, references, the header, line wrapping, line endings and a byte order mark are the original file's. Open a file, change nothing, export it, and the two files are identical byte for byte; the round trip on How it works shows it on a file of yours.

A translation with line breaks in it is written the way msgmerge writes one: an empty msgstr line, then one quoted line per line.

Plurals

msgid "%d file"
msgid_plural "%d files"
msgstr[0] "%d файл"
msgstr[1] "%d файла"
msgstr[2] "%d файлов"

Each msgstr[n] in the file is a row of its own. Forms can be translated, not added: if a file has two forms and its Plural-Forms header asks for three (a template that was never merged for the language), File notices in the editor's ⋯ menu says so. Run msgmerge, or let your PO tool update the file from its template, and open it again.

Before you start

  • The file must be UTF-8. A file whose header names another character set is refused with a sentence saying so, rather than opened with the wrong characters.
  • gettext has no source-language field, so the source is taken as English unless the header carries X-Source-Language.
  • A .pot template opens with every row Empty. Export it, and rename the result to .po for your language.
  • A translated .po from an earlier release can be loaded in the Memory panel as a translation memory, so its strings are offered as matches.