Best strategy for translations?

58 wyświetleń
Przejdź do pierwszej nieodczytanej wiadomości

Javier Poo

nieprzeczytany,
2 sie 2011, 16:35:392.08.2011
do 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

nieprzeczytany,
5 sie 2011, 04:25:355.08.2011
do 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
Odpowiedz wszystkim
Odpowiedz autorowi
Przekaż
Nowe wiadomości: 0