mirror of
https://gh.wpcy.net/https://github.com/WeblateOrg/weblate.git
synced 2026-04-27 13:24:26 +08:00
* initial implementation suggestion * basic supported features snippets generation * Add API identifiers, read-only strings and common extensions to features table * generate doc features snippet files * autogenerated snippets cleanup * changelog update * delete one file to test auto-update * replace SUPPORTS_FUZZY with file format additional_states flag * docs: Documentation snippets update * fix include statetement typo * fix incorrect monolingual attributes * minor styling change * docs: Documentation snippets update * exclude snippets from being treated as standalone documents * Set YAMLFormat as both mono/bilingual * docs: Documentation snippets update * fix duplicate format IDs * only use backwards quotes for literals --------- Co-authored-by: gersona <6675010+gersona@users.noreply.github.com> Co-authored-by: Michal Čihař <michal@weblate.org>
172 lines
5.5 KiB
ReStructuredText
172 lines
5.5 KiB
ReStructuredText
.. _gettext:
|
|
|
|
GNU gettext PO (Portable Object)
|
|
--------------------------------
|
|
|
|
.. index::
|
|
pair: gettext; file format
|
|
pair: PO; file format
|
|
|
|
Most widely used format for translating libre software.
|
|
|
|
Contextual info stored in the file is supported by adjusting its
|
|
headers or linking to corresponding source files.
|
|
|
|
.. seealso::
|
|
|
|
* :doc:`../devel/gettext`
|
|
* :doc:`../devel/sphinx`
|
|
* `Gettext on Wikipedia <https://en.wikipedia.org/wiki/Gettext>`_
|
|
* :doc:`tt:formats/po`
|
|
* :ref:`addon-weblate.gettext.authors`
|
|
* :ref:`addon-weblate.gettext.configure`
|
|
* :ref:`addon-weblate.gettext.customize`
|
|
* :ref:`addon-weblate.gettext.linguas`
|
|
* :ref:`addon-weblate.gettext.mo`
|
|
* :ref:`addon-weblate.gettext.msgmerge`
|
|
|
|
Showing source string change
|
|
++++++++++++++++++++++++++++
|
|
|
|
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, :program:`msgmerge` has to be executed with ``--previous`` and
|
|
the resulting PO file then contains lines such as:
|
|
|
|
.. code-block:: po
|
|
|
|
#, fuzzy
|
|
#| msgid "previous-untranslated-string"
|
|
msgid "untranslated-string"
|
|
msgstr "translated-string"
|
|
|
|
PO file header
|
|
++++++++++++++
|
|
|
|
The header of the PO file is automatically maintained by Weblate. Optionally it
|
|
can include :ref:`component-report_source_bugs` and
|
|
:ref:`project-set_language_team`.
|
|
|
|
The header comments also can be updated to contain author names using :ref:`addon-weblate.gettext.authors`.
|
|
|
|
Line wrapping
|
|
+++++++++++++
|
|
|
|
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 :ref:`file_format_params`.
|
|
|
|
Generating matching MO files
|
|
++++++++++++++++++++++++++++
|
|
|
|
In case MO files are kept in the repository together with PO files,
|
|
:ref:`addon-weblate.gettext.mo` can be used to keep them up-to-date with PO
|
|
files.
|
|
|
|
Updating PO files from the POT file
|
|
+++++++++++++++++++++++++++++++++++
|
|
|
|
:ref:`addon-weblate.gettext.msgmerge` can be used to update PO files from the
|
|
POT file, see :ref:`updating-target-files`.
|
|
|
|
.. _mono_gettext:
|
|
|
|
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.
|
|
|
|
Example files
|
|
+++++++++++++
|
|
|
|
The bilingual gettext PO file typically looks like this:
|
|
|
|
.. code-block:: 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ý"
|
|
|
|
The monolingual gettext PO file typically looks like this:
|
|
|
|
.. code-block:: 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ý"
|
|
|
|
While the base language file will be:
|
|
|
|
.. code-block:: po
|
|
|
|
#: 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"
|
|
|
|
|
|
.. include:: /snippets/format-features/po-mono-features.rst
|
|
|
|
.. include:: /snippets/format-features/po-features.rst
|
|
|
|
Weblate configuration
|
|
+++++++++++++++++++++
|
|
|
|
+-------------------------------------------------------------------+
|
|
| Typical Weblate :ref:`component` for bilingual gettext |
|
|
+================================+==================================+
|
|
| File mask | ``po/*.po`` |
|
|
+--------------------------------+----------------------------------+
|
|
| Monolingual base language file | `Empty` |
|
|
+--------------------------------+----------------------------------+
|
|
| Template for new translations | ``po/messages.pot`` |
|
|
+--------------------------------+----------------------------------+
|
|
| File format | `Gettext PO file` |
|
|
+--------------------------------+----------------------------------+
|
|
|
|
+-------------------------------------------------------------------+
|
|
| Typical Weblate :ref:`component` for monolingual gettext |
|
|
+================================+==================================+
|
|
| File mask | ``po/*.po`` |
|
|
+--------------------------------+----------------------------------+
|
|
| Monolingual base language file | ``po/en.po`` |
|
|
+--------------------------------+----------------------------------+
|
|
| Template for new translations | ``po/messages.pot`` |
|
|
+--------------------------------+----------------------------------+
|
|
| File format | `Gettext PO file (monolingual)` |
|
|
+--------------------------------+----------------------------------+
|
|
|
|
|
|
File format parameters
|
|
++++++++++++++++++++++
|
|
|
|
:ref:`file_format_params` with the pattern `po_*` can be used to configure the behavior of the gettext format.
|