Ačiū Dalius for help. This I already made.
But we found how to make it. The problem was tw middleware do genshi
render itself, so it doesn't touch pylons config of genshi.
The result (in middleware.py):
app = make_tw_middleware(app,
{
'toscawidgets.framework':
'pylons',
'toscawidgets.framework.default_view':
'genshi',
'toscawidgets.framework.translator': lazify
(translate),
'toscawidgets.framework.engine_options':
{'genshi.loader_callback':
template_loaded},
'toscawidgets.middleware.inject_resources': True})
there "translate" is my own translator and template_loaded is appended
filter to genshi:
def template_loaded(template):
"""Genshi TemplateLoader callback. Inserts the translator filter.
"""
template.filters.insert(0, Translator(translate))
May be it will help to somebody
Arns
On Feb 4, 7:46 am, Dalius Dobravolskas <[email protected]>
wrote:
> On Wed, Feb 4, 2009 at 4:06 AM, zordsdavini <[email protected]> wrote:
>
> > Hi all,
>
> > How to append genshi translator during init of toskawidgets? This
> > problem comes from custom tw.forms templates. They are not
> > translating. I feel there should be some simple step.
>
> > I'm not sure what you mean by genshi translator but my guess is that you
>
> must use lazystring:
>
> Something like that:
>
> 23
> <http://hg.sandbox.lt/pekla/file/012a56a06089/pekla/lib/forms.py#l23>class
> CommentForm(forms.ListForm):
> 24 <http://hg.sandbox.lt/pekla/file/012a56a06089/pekla/lib/forms.py#l24>
> 25 <http://hg.sandbox.lt/pekla/file/012a56a06089/pekla/lib/forms.py#l25>
> class fields(WidgetsList):
> 26 <http://hg.sandbox.lt/pekla/file/012a56a06089/pekla/lib/forms.py#l26>
> name = forms.TextField(label_text = lazystring(_('Name')),
> help_text = lazystring(_('Required')),
> 27 <http://hg.sandbox.lt/pekla/file/012a56a06089/pekla/lib/forms.py#l27>
> validator = UnicodeString(not_empty=True)
> 28 <http://hg.sandbox.lt/pekla/file/012a56a06089/pekla/lib/forms.py#l28>
> )
>
> More code here:http://hg.sandbox.lt/pekla/file/012a56a06089/pekla/lib/forms.py
>
> If that does not help maybe other person will help you here ;-)
>
> --
> Daliushttp://blog.sandbox.lt
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---