Best strategy for translations?

58 views
Skip to first unread message

Javier Poo

unread,
Aug 2, 2011, 4:35:39 PM8/2/11
to liquid-t...@googlegroups.com
Hi all,

I'm working on moving a products frontend from ERB to Liquid Markup. One of the problems we are facing is to implement internationalization, the problem is half solved with a filter, but I need to sometimes pass named parameters to the filter, I've been unable to do that, parameters got evaluated and only the actual value gets to the filter. It would be helpful if someone has experience in solving this problem and share his/her experience.

Some context for better understanding.
Suppose I have this site.yml file:
en:
    site:
          welcome: "Hi %{name} your status is %{status}"

I'd like to do something like this in the views:
....
<li>{{ 'site.welcome' | translate name:member.name, status:member.status }}</li>
.....

I can do that now, but I'll only get the member.name and member.status in the filter, but I'm not getting name: and status: as variable names.

This is the filter:
  def translate(value, *args)
    ...
  end
What I get in args is an array containing ["member_name_value","member_status_value"]

did

unread,
Aug 5, 2011, 4:25:35 AM8/5/11
to Liquid Templates
Hi Javier,

Did you try this: {{ 'site.welcome' | translate: name:member.name,
status:member.status }} ? (note: I just added a comma after
'translate')
thanks,

Did
Reply all
Reply to author
Forward
0 new messages