Context for gettext messages

Some message ids in gettext system may be ambiguous and lead to wrong translations, specially those too short. I think that these message ids should be prefixed with some namespace giving context for the translator. For example, in pt-br, _('Move') can be translated as mover (verb, please move it) or movimento (noun, make the move), therefore a correct translation would need context. With namespaces, we would rather write _('verb:Move') or _('noum:Move'), depending on what exactly we want. The namespace would be removed from the translated message by i18n.getText, even if translation is defaulting to English, and msgstrs could avoid using the namespace to improve performance. The syntax for the namespaces here is just an example, of course.

Real examples from the source code

See line 71 of MoinMoin/search/Xapian/search.py. The word about can mean many things, but it was translated as sobre in pt-br, which was totally wrong according to the mentioned line. The correct translation is aproximadamente (approximately) in this case. However, some other code may really want to use _('about') in the sense of sobre (regarding something): that's why we need something like namespaces. In this case, they would give the possible solution of using something like _('approximately:about') or _('regarding:about'), depending on the context.

Discussion

This is the common problem of gettext system. The common solution is to use more verbose and distinct messages. -- EugeneSyromyatnikov 2010-01-21 03:05:50

RenatoSilva - Why isn't it easy, ReimarBauer? I believe you just need to add context to the message, and truncate it when translating with i18n.getText. Do you have examples too?


CategoryFeatureRequest CategoryForMoin2

MoinMoin: FeatureRequests/ContextForGettextMessages (last edited 2010-01-22 00:00:47 by RenatoSilva)