trans a variable

32 views
Skip to first unread message

Seven Du

unread,
Sep 22, 2012, 10:41:01 PM9/22/12
to erlydt...@googlegroups.com
Hi,

Thank you for the great code and I have some questions when using erlydtl. I use the latest code on github.


1) to trans a variable, I tried many ways but only the second works:

code:

when edit = Edit


<br> 1 {{ edit }}
<br> 2 {% trans "Edit" %}
<br> 3 {% trans edit %}
<br> 4 {{ _( edit ) }}
<br> 5 {% blocktrans with e = edit %} {{ edit }} {% endblocktrans %}

output:

1 Edit 
2 编辑 
3 Edit 
4 Edit 
5 Edit


2) Is it possible to use extends and include with variables?


Thanks.

Evan Miller

unread,
Oct 15, 2012, 12:23:25 AM10/15/12
to erlydt...@googlegroups.com
Hello,

On Sat, Sep 22, 2012 at 9:41 PM, Seven Du <duji...@gmail.com> wrote:
> Hi,
>
> Thank you for the great code and I have some questions when using erlydtl. I
> use the latest code on github.
>
>
> 1) to trans a variable, I tried many ways but only the second works:

Are you passing the data in as a string? If it is a binary it might
not get translated with the default machinery.

>
> code:
>
> when edit = Edit
>
>
> <br> 1 {{ edit }}
> <br> 2 {% trans "Edit" %}
> <br> 3 {% trans edit %}
> <br> 4 {{ _( edit ) }}
> <br> 5 {% blocktrans with e = edit %} {{ edit }} {% endblocktrans %}
>
> output:
>
> 1 Edit
> 2 编辑
> 3 Edit
> 4 Edit
> 5 Edit
>
>
> 2) Is it possible to use extends and include with variables?

No -- extends and include are evaluated at compile-time so you can't
use variables here.

Evan

>
>
> Thanks.



--
Evan Miller
http://www.evanmiller.org/

Seven Du

unread,
Oct 15, 2012, 1:04:51 AM10/15/12
to erlydt...@googlegroups.com
Evan,

Thanks for looking this, I tried both string and binary, nothing is translated.

And if we can make it work, it would be great to also working with binary.

Do you have more suggestion where can I look/debug or you have time to try a bit?

Thanks.

-- 
Seven Du
Sent with Sparrow

Evan Miller

unread,
Jan 17, 2013, 3:57:42 PM1/17/13
to erlydt...@googlegroups.com
Did you ever get this working?

Seven Du

unread,
Jan 17, 2013, 8:23:17 PM1/17/13
to erlydt...@googlegroups.com

Evan Miller

unread,
Jan 20, 2013, 6:17:02 PM1/20/13
to erlydt...@googlegroups.com
I love the PO changes and the UTF-8 compatible truncatechars. Please issue a pull request with them!

I won't merge non-standard filters, however, and I'm not sure about the NULL stuff.

Evan
Reply all
Reply to author
Forward
0 new messages