[Localization] Problem: 2 translations for 1 string

Pierre Métras genepi at sympatico.ca
Fri Apr 4 15:54:56 EDT 2008

On Thursday 20 March 2008 13:12, Markus Schlager wrote:
> Hi Alex,
> On Thu, 20 Mar 2008, Alexander Todorov wrote:
> > I understand that the German translation is dependent on context in this
> > particular case but that may not be the case with most of the
> > translations so
> Actually, I don't think so. A real problem is caused by the fact, that
> there are many words in English which can resemble a noun as well as a
> verb (e.g. 'copy' or 'batch' - and you even cannot distinguish wheter
> 'copy' means 'to copy' or 'copy!'). In all other languages, I know
> (German, Czech,Italian,French), you'd have to translate these differently
> depending on the context.
> Regards


This problem is generally not caused by the target language, but originates 
from the source language English, because a same short sentence to be 
translated can have multiple meanings, depending on the context.

Particularly with GUI application, this has to be tackled by *programmers* 
when they code, using the pgettext ("particular" gettext) family of 
functions. But few of them are aware of localization; just look how many 
times you find context comments in the source... This should not be the 
responsability of the translator to find in which context a term is used in a 
piece of software (Was "Start" used to go to the beginning of the video or to 
start it again after a pause?).

Python does not support pgettext() and others in the gettext module, and I 
have open a request to have them included in future versions of the language. 
We could have a specific version included in Sugar meanwhile. Here is the 
version I use in my Clock activity:
# pgettext(msgctxt, msgid) from gettext is not supported in Python 
# Meanwhile we get official support, we have to simulate it.
# See http://www.gnu.org/software/gettext/manual/gettext.html#Ambiguities for
# more information about pgettext.

# The separator between message context and message id.This value is the same 
# the one used in gettext.h, so PO files should be still valid when Python 
# module will include pgettext() function.

def pgettext(msgctxt, msgid):
    """A custom implementation of GNU pgettext().
    if msgctxt is not None and msgctxt is not "":
        prefix = msgctxt + GETTEXT_CONTEXT_GLUE
        msgstr = gettext(prefix + msgid)
        if msgstr.startswith(prefix):
            msgstr = msgstr[len(prefix):]
        msgstr = gettext(msgid)
    return msgstr

# Map our pgettext() custom function to _p()
_p = lambda msgctxt, msgid: pgettext(msgctxt, msgid)

-- Pierre Métras

More information about the Localization mailing list