From kde-core-devel Fri Oct 21 08:13:38 2005 From: Stanislav Visnovsky Date: Fri, 21 Oct 2005 08:13:38 +0000 To: kde-core-devel Subject: Fwd: gettext and contexts Message-Id: <200510211013.38381.visnovsky () kde ! org> X-MARC-Message: https://marc.info/?l=kde-core-devel&m=112988205624564 ---------- Preposlaná správa ---------- Subject: gettext and contexts Date: Štvrtok 20 Október 2005 20:08 From: Bruno Haible To: Thomas Diehl Cc: Chusslove Illich , Stanislav Visnovsky 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 -------------------------------------------------------