开发者

How can I have attributes that get extracted for i18n in ZPT macros?

I'm using Pyramid with ZPT templates to make a web app. I'm attempting to make a form template macro library to make life easier for things like setting current values of form fields, etc. I'm also using the lingua message extractors to automatically pick up strings for localization. I can't figure out how to make the extractors work with attributes on macro tags though. For example, say I have a macro that looks like this:

<tal:block metal:define-macro="text">
    <input type="text" name="${field}" value="${request.params.get(field) or default_value}"/>
</tal:block>

And I use it in a page template like this:

<tal:block tal:define="field 'fred'; default_value _('initial value')" metal:use-macro="form.macros['text']"/>

The text "initial value" won't get picked up by the message extractor. Is there a way to make this happen? I'd like to keep the strings inside开发者_如何学运维 the template if possible, I know I could work around this by having all the strings for default values generated in the view callable. Maybe there is there a better way of passing values to macros for use in attributes?


You need to use [lingua] to version 2 (or later) to extract messages from templates for this to work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜