GNU gettext PO (Portable Object)

Most widely used format for translating libre software.

通過調整文件頭或連結到相應的來源文件,可以支援儲存在文件中的語境資訊。

顯示來源字串變更

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"

PO 檔案標頭

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 檔案格式參數.

The header comments also can be updated to contain author names using 評論中的貢獻者紀錄.

換行

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 檔案格式參數.

Generating matching MO files

In case MO files are kept in the repository together with PO files, 產生 MO 檔案 can be used to keep them up-to-date with PO files.

Updating PO files from the POT file

更新 PO 檔案以符合 POT (msgmerge) can be used to update PO files from the POT file, see 更新目標語言檔案.

單語言 gettext

一些專案決定使用 gettext 作為單語言格式 —— 它們僅在原始碼中編碼 ID,然後將字串翻譯成所有語言,包括英語。支援此功能,儘管在將組件匯入 Weblate 時必須明確選擇此檔案格式。

範例檔案

雙語言 gettext PO 檔案通常如下所示:

#: 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ý"

單語言的 gettext PO 檔案通常如下所示:

#: 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ý"

基本語言文件將是:

#: 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"
支援的功能

副檔名

.po, .pot

語言能力

單語言

支援複數

Yes

支援描述

Yes

支援解釋

No

Supports context

Yes

Supports location

Yes

Supports flags

Yes

Additional states

Needs editing

API 識別碼

po-mono

支援唯讀字串

No

支援的功能

副檔名

.po, .pot

語言能力

雙語言

支援複數

Yes

支援描述

Yes

支援解釋

No

Supports context

Yes

Supports location

Yes

Supports flags

Yes

Additional states

Needs editing

API 識別碼

po

支援唯讀字串

No

Weblate 配置

Typical Weblate 組件配置 for bilingual gettext

檔案遮罩

po/*.po

單語言基底語言檔案

空白

新翻譯的範本

po/messages.pot

檔案格式

Gettext PO 檔案

Typical Weblate 組件配置 for monolingual gettext

檔案遮罩

po/*.po

單語言基底語言檔案

po/en.po

新翻譯的範本

po/messages.pot

檔案格式

Gettext PO 檔案(單語言)

檔案格式參數

檔案格式參數 with the pattern po_* can be used to configure the behavior of the gettext format.