On Saturday 12 May 2012 11:53 Thomas Tanghus wrote:
> Hi
>
> I started playing around with phptal this week because I wanted to see if it
> was possible to use as a templating system in ownCloud (
> http://owncloud.org ).
> It turned out to be very easy to integrate, and I've only stumbled over one
> problem, and that doesn't have anything to do with the integration.
>
> I have a div where I wan't to translate the title dialog which contains a
> variable assign from my template class with PHPTAL::set().
>
> Using the code below shows ${uploadMaxHumanFilesize} as text.
>
> <div i18n:attributes="title" title="Drop photo to upload (max
> ${uploadMaxHumanFilesize} MB)"></div>
>
> Using:
>
> <div i18n:name="humansize" i18n:attributes="title" title="Drop photo to
> upload (max ${humansize} MB)">${uploadMaxHumanFilesize}</div>
>
> Gives the error "Unable to find variable 'humansize' in current scope in
> /path/to/template"
>
> as does:
>
> <div i18n:name="humansize" i18n:attributes="title string:photo to upload
> (max ${humansize} MB)">${uploadMaxHumanFilesize}</div>
>
> What is actually worse is that simply using i18n:name removes the entire
> div!?!
>
> I have read through the mailing list archives, but haven't found a solution
> that solves my problem. Is it possible at all, or will I have to hack to my
> way around it?
I found a way around this, in case anybody is interested. It's kind of a hack
though.
I assign an instance of my PHPTAL_TranslationService subclass to the template,
which lets me do this:
<div tal:define="tooltip php:i18n->translate('Drop photo to upload') . ' (max '
. uploadMaxHumanFilesize . ')'"
tal:attributes="title tooltip"></div>
It would be nice to be able to do it more elegantly though.
--
Med venlig hilsen / Best Regards
Thomas Tanghus
_______________________________________________
PHPTAL mailing list
[email protected]
http://lists.motion-twin.com/mailman/listinfo/phptal