Maybe I've missed something but my interpretation of your problem is that you 
want to add variable content into a translation string for an attribute.

How about something like:

<div i18n:attributes="title" title="titleTranslationKey">
        <tal:block i18n:name="maxFilesize" tal:content="uploadMaxHumanFilesize" 

with a po file (assuming you are using gettext) of:

msgid "titleTranslationKey"
msgstr "Drop photo to upload (max ${maxFilesize} MB)"

I am assuming here that the i18n:name key/value pairs are available for 
attribute translation in the same way they would be for content translation but 
I haven't seen why that wouldn't be the case.

Robert Goldsmith

On 16 May 2012, at 12:46, Thomas Tanghus wrote:

> 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 (
>> ).
>> 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

PHPTAL mailing list

Reply via email to