Fwd: gettext and contexts
Stanislav Visnovsky
visnovsky at kde.org
Fri Oct 21 09:13:38 BST 2005
---------- Preposlaná správa ----------
Subject: gettext and contexts
Date: Štvrtok 20 Október 2005 20:08
From: Bruno Haible <bruno at clisp.org>
To: Thomas Diehl <thd at kde.org>
Cc: Chusslove Illich <caslav.ilic at gmx.net>, Stanislav Visnovsky
<visnovsky at kde.org>
Hi,
The following feature has been added in GNU gettext.
* GUI program support:
- PO files can now contain messages constrained to a certain context.
Most often such a context is a menu, dialog or panel identification.
The syntax in the PO file is
msgctxt "context"
msgid "original"
msgstr "translation"
- The xgettext program can be told through the --keyword flag which
function/macro argument has the role of a context.
- The (non-public) include file gettext.h defines macros pgettext,
dpgettext etc. that take a context argument.
For more information, see the node "Contexts" in the manual.
xgettext can now distinguish the uses of KDE's i18n function according
to the number of arguments:
// (KDE) The 1-argument i18n macro is a simple gettext without context.
print (i18n ("help"));
// (KDE) The 2-argument i18n macro has the context first.
print (i18n ("Help", "about"));
// (KDE) The 3-argument i18n macro is an ngettext without context.
print (i18n ("error", "errors", 7));
yields
-----------------------
msgid "help"
msgstr ""
msgctxt "Help"
msgid "about"
msgstr ""
msgid "error"
msgid_plural "errors"
msgstr[0] ""
msgstr[1] ""
------------------------
Do you find this useful? (I hope so! :-) You will be able to drop the
dependency on a patched xgettext.) If so, when would this be needed to be
in an official gettext release, if KDE 4 is going to make use of it?
Also I'd like to make a minimal support of this syntax in kbabel. Simply
changing the PO file import and export filters, to transform
msgctxt "Help"
into
#. Context: Help
for kbabel's internal use would be enough. (The export filter would have
to convert it back to msgctxt syntax.) Just to make sure kbabel doesn't
spit on the translator when such a PO file is encountered.
Bruno
-------------------------------------------------------
More information about the kde-core-devel
mailing list