Pylons/translationstring — Issue #4: translation can not define mapping
Author: wichert
Created: 2011-10-21 10:30:55+00:00
State: open

I have code that looks like this:

```!python
MAIL_BODY = _(
u'Hello ${name},\n'
u'\n'
u'Welcome to our service! Lorem ipsum etc. etc.')

def welcome(request):
translate = get_localizer(request).translate
user = get_user(request)
body = translate(MAIL_BODY, mapping={'name': user.title()})
```

This moves the (often quite large) texts outside of the code to another place, making the code easier to read. But this does not work: translationstring.translator ignores its mapping argument if the tstring already is a translationstring instance.

My gut feeling is that translator() should always use the domain and mapping arguments, possibly overriding those of an existing tstring. As far as I can see this will not break any existing code.