Context in translations, Q_() and gettext



GLib offers the Q_() macro for adding context to translations, but 
the solution of embedding the context into the msgid is error-prone 
for translators and can lead to regular msgids being misinterpreted 
as having a context. 

When this was last discussed on this list 1 1/2 years ago, there
seemed to be consensus that a solution that keeps context and msgid
separate is preferable. Since then, GNU gettext has added support 
for this in the form of msgctxt, which has been available in gettext
0.15 for a year now. 

I'd like to add support for separate message context to the next 
GLib release (i.e. not 2.14, which is almost done), in the form of 
a C_(Context,Msgid) macro. An implementation of this can be found
in http://bugzilla.gnome.org/show_bug.cgi?id=142676 . The patch
also modifies the Q_() macro so that it can keep working even if
the contexts in .po files are converted to msgctxt (xgettext can
do this automatically)

There is a number of questions that I'd like to find answers for
before we decide to push for adoption of msgctxt:

- Have the translation tools caught up with msgctxt yet, or will
  msgctxt cause problems for translators ?

- Will it be a big problem for people using alternative gettext
  implementations if msgctxt starts to appear in .po files ? 
  Do we need to provide a script to "fold back" msgctxt into 
  msgid prefixes, for use with old msgfmt implementations, 
  or can we expect everybody to use GNU gettext for creating 
  .mo files ? 

- How can we handle existing translations when context moves
  from the msgid to msgctxt ? 
  Does msgmerge handle this intelligently, or do we need some 
  conversion script ?

- Can we make the transition from Q_() to C_() smoother ? 
  Unfortunately, xgettext does not provide a way to extract
  strings from a 2-argument macro like C_() to msgid-prefix
  form.

As a test balloon for this, I have added support for separate
context to the GtkBuilder xml format, in the following form:

<property name="foo" 
          translatable="yes"
          context="context">message</property>

A patch which makes intltool handle this format can be found
here http://bugzilla.gnome.org/show_bug.cgi?id=454894. The patch 
allows intltool to extract this as either

 pgettext ("context", "message")

or

 gettext ("context|message")

GtkBuilder will work with the resulting .mo files for both 
variants.


Comments ?


Matthias



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]