Forum: Rails I18n Why is this t() call failing?

Posted by Max Williams (max-williams)
on 2010-05-13 16:15
Can anyone see why this is failing?  It's probably something dumb on my
part but i'm stumped :/

ActionView::TemplateError (interpolation argument :date_string missing
in "Created on {{:date_string}} at {{:time_string}}") on line #51 of
app/views/quizzes/edit_step_0.html.haml:
48:             %p
49:               = quiz.name
50:               %br/
51:               = t('general.created_on', :date_string =>
quiz.created_at.strftime('%d/%m/%y'), :time_string =>
quiz.created_at.strftime('%H:%M'))
52:             = link_to "Edit", edit_quiz_path(quiz), :title => "Edit
quiz", :class => "Button"
53:

As far as i can see this error doesn't make sense as i'm passing
date_string through in my t call.  Here's the t call line by itself:

              = t('general.created_on', :date_string =>
quiz.created_at.strftime('%d/%m/%y'), :time_string =>
quiz.created_at.strftime('%H:%M'))

here's my en.yml file, with some lines removed for clarity:

en:
  hello_world: Hello
  general:
    created_on: "Created on {{:date_string}} at {{:time_string}}"

It's nothing to do with the actual values i'm passing through, ie all
the created_at.strftime stuff.  If i swap those out for 'foo' and 'bar'
i get the same problem.  Can anyone see what i'm doing wrong?

thanks, max
Posted by Henrik --- (malesca)
on 2010-05-13 16:18
(Received via mailing list)
On Thu, May 13, 2010 at 16:15, Max Williams <lists@ruby-forum.com> 
wrote:
> Can anyone see why this is failing?  It's probably something dumb on my
> part but i'm stumped :/
>
> ActionView::TemplateError (interpolation argument :date_string missing
> in "Created on {{:date_string}} at {{:time_string}}") on line #51 of
> app/views/quizzes/edit_step_0.html.haml:

>    created_on: "Created on {{:date_string}} at {{:time_string}}"

I think you need to lose the colons there, so:

created_on: "Created on {{date_string}} at {{time_string}}"
Posted by Max Williams (max-williams)
on 2010-05-13 16:19
SOLVED: Je suis un idiot:  it should be

    created_on: "Created on {{date_string}} at {{time_string}}"

not

    created_on: "Created on {{:date_string}} at {{:time_string}}"

Thanks for reading.  max
Posted by Krzysztof Knapik (Guest)
on 2010-05-13 16:27
(Received via mailing list)
If you use the latest version of i18n {{}} syntax is depracated, and
%{} introduced.

Regards,
KK

2010/5/13 Max Williams <lists@ruby-forum.com>:
Posted by Max Williams (max-williams)
on 2010-05-13 16:49
Krzysztof Knapik wrote:
> If you use the latest version of i18n {{}} syntax is depracated, and
> %{} introduced.
> 
> Regards,
> KK
> 
> 2010/5/13 Max Williams <lists@ruby-forum.com>:

ah, cool, thanks Krzysztof, i'll check that out.  It's not the first 
time i've slipped up with the {{ }} syntax.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.