X = _('some ${data}', mapping=dict(data=1))
zope.i18n.translate(X, context=self.request)
But indeed when you use X as a constant, you don't have necessary the mapping right away.
In this case, what I do is to create a new Message object:
from zope.i18nmessageid import Message
zope.i18n.translate(Message(X, mapping=dict(data=1)), context=self.request)
This is the preferred way to do it right now. You lose the domain and default message when you do unicode(X).
Indeed, it may be less verbose to write:
zope.i18n.translate(X, mapping=dict(data=1), context=self.request)
If somebody change the code of the translate function so you can override mapping like this, I think in this case you should be able to override domain and default as well.
I usually do:
X = _('some ${data}', mapping= dict(data= 1)) translate( X, context= self.request)
zope.i18n.
But indeed when you use X as a constant, you don't have necessary the mapping right away.
In this case, what I do is to create a new Message object:
from zope.i18nmessageid import Message translate( Message( X, mapping= dict(data= 1)), context= self.request)
zope.i18n.
This is the preferred way to do it right now. You lose the domain and default message when you do unicode(X).
Indeed, it may be less verbose to write: translate( X, mapping= dict(data= 1), context= self.request)
zope.i18n.
If somebody change the code of the translate function so you can override mapping like this, I think in this case you should be able to override domain and default as well.