2

I'm trying to do something like this:

${_('Hello ${name}, welcome to...', mapping=dict(name='${name}'))}

Where _() is my Babel translation function, the first ${name} is string interpolation I'd like to be performed by Babel and the second ${name} I'd like to be replaced by Mako so the value is the value in the Python dictionary:

This is ultimately rendered as:

Hello ${name}, welcome to...

Not desirable. Problem seems to be that since the second ${name} is nested inside another ${}, it's not evaluated.

What I'm aiming for:

Hello Ryan, welcome to...

How can I achieve this?

4

1 回答 1

3

为什么不使用 Python 的字符串格式化?

${ _('Hello {name}, welcome to ...').format(name=name) }
于 2011-11-18T08:52:53.010 回答