GNU gettext PO (Portable Object)

Il formato più usato per tradurre software libero.

Contextual info stored in the file is supported by adjusting its headers or linking to corresponding source files.

Visualizzazione della modifica della stringa di origine

Weblate can extract previous source strings from the PO files if present and show the string difference for strings needing editing based on that. To include these, msgmerge has to be executed with --previous and the resulting PO file then contains lines such as:

#, fuzzy
#| msgid "previous-untranslated-string"
msgid "untranslated-string"
msgstr "translated-string"

This is controlled by the po_keep_previous Parametri del formato file parameter. It does not affect obsolete entries marked with #~.

Obsolete strings

msgmerge keeps strings removed from the POT file as obsolete #~ entries by default. Enable the po_remove_obsolete Parametri del formato file parameter to remove obsolete entries when Weblate saves PO files.

PO file header

The header of the PO file is automatically maintained by Weblate. It can be configured to include the Language-Team, Last-Translator, X-Generator and Report-Msgid-Bugs-To headers using the Parametri del formato file.

Contributor comments

Use the po_contributor_comments Parametri del formato file parameter to add contributor names and years to PO header comments. Choose gettext for traditional comments or spdx for SPDX copyright entries. The default, none, disables contributor updates without removing existing comments. This setting works independently of the Last-Translator header setting.

With gettext, contributor comments look like this:

# Jane Doe <jane@example.com>, 2024, 2026.

With spdx, the same entry becomes:

# SPDX-FileCopyrightText: 2024, 2026 Jane Doe <jane@example.com>

On the next commit by an eligible contributor, SPDX mode converts all recognized contributor comments, preserves historical contribution years, and adds the current year for that contributor. Anonymous Weblate authors are skipped. Unrelated comments and copyright notices are preserved. Weblate does not infer copyright claims from translated credit strings or add project-specific notices or license identifiers; handle these in custom tooling.

Avvolgimento della linea

The line wrapping mostly matches GNU gettext behavior. Both the wrapping algorithm in the GNU gettext and the Unicode data the wrapping is based on evolve which might cause differences in some corner cases.

The wrapping width can be configured using the po_line_wrap parameter, see Parametri del formato file.

Generazione di file MO corrispondenti

In case MO files are kept in the repository together with PO files, Genera file MO can be used to keep them up-to-date with PO files.

Aggiornamento dei file PO dal file POT

Aggiorna i file PO per adeguarli al file POT (msgmerge) can be used to update PO files from the POT file, see Aggiornamento dei file della lingua di destinazione.

Monolingual gettext

Some projects decide to use gettext as monolingual formats—they code just the IDs in their source code and the string then needs to be translated to all languages, including English. This is supported, though you have to choose this file format explicitly when importing components into Weblate.

File di esempio

The bilingual gettext PO file typically looks like this:

#: weblate/media/js/bootstrap-datepicker.js:1421
msgid "Monday"
msgstr "Pondělí"

#: weblate/media/js/bootstrap-datepicker.js:1421
msgid "Tuesday"
msgstr "Úterý"

#: weblate/accounts/avatar.py:163
msgctxt "No known user"
msgid "None"
msgstr "Žádný"

The monolingual gettext PO file typically looks like this:

#: weblate/media/js/bootstrap-datepicker.js:1421
msgid "day-monday"
msgstr "Pondělí"

#: weblate/media/js/bootstrap-datepicker.js:1421
msgid "day-tuesday"
msgstr "Úterý"

#: weblate/accounts/avatar.py:163
msgid "none-user"
msgstr "Žádný"

While the base language file will be:

#: weblate/media/js/bootstrap-datepicker.js:1421
msgid "day-monday"
msgstr "Monday"

#: weblate/media/js/bootstrap-datepicker.js:1421
msgid "day-tuesday"
msgstr "Tuesday"

#: weblate/accounts/avatar.py:163
msgid "none-user"
msgstr "None"
Funzionalità supportate

Estensioni dei file

.po, .pot

Linguality

Monolingual

Supports plural

Yes

Supports descriptions

Yes

Supports explanation

No

Supports context

Yes

Supports location

Yes

Supports flags

Yes

Additional states

Needs editing

API identifier

po-mono

Supports read-only strings

No

Supports removing obsolete strings

Yes

Funzionalità supportate

Estensioni dei file

.po, .pot

Linguality

Bilingual

Supports plural

Yes

Supports descriptions

Yes

Supports explanation

No

Supports context

Yes

Supports location

Yes

Supports flags

Yes

Additional states

Needs editing

API identifier

po

Supports read-only strings

No

Supports removing obsolete strings

Yes

Configurazione Weblate

Typical Weblate Component configuration for bilingual gettext

Maschera del file

po/*.po

File di lingua a base monolingue

Empty

Modello per le nuove traduzioni

po/messages.pot

Formato file

Gettext PO file

Typical Weblate Component configuration for monolingual gettext

Maschera del file

po/*.po

File di lingua a base monolingue

po/en.po

Modello per le nuove traduzioni

po/messages.pot

Formato file

Gettext PO file (monolingual)

Parametri del formato file

Parametri del formato file with the pattern po_* can be used to configure the behavior of the gettext format.