简体   繁体   中英

i18n missing interpolation argument

i've developed a small website in rails 2.3.5 but when i wanted to deploy it on a server i started to get some issues. One of those issues is an interpolation problem. Whenever i want to format a date using i18n i'm getting this exception: ActionView::TemplateError (missing interpolation argument in "%{count} %B %Y, %H:%M" ({:object=>Fri, 08 Oct 2010 20:18:17 UTC +00:00} given)) on line #10 of app/views/contact/archive.html.erb:

This is the code that throws this exception: <strong><%= t :created_at %>:</strong> <%=l contact.created_at, :format => :long %> <br />

I've looked on google and found this has something to do with an update of the i18n plugin (0.4.0) and this version was indeed installed on the server. Any idea how i can fix this issue? Because i couldn't find an answer anywhere.

kind regards,

Daan

if you're using i18n 0.4.0, you should upgrade Rails to the 2.3.6+ version. Take a look at http://github.com/svenfuchs/i18n/issues/issue/20 for more information.

This issue appears to happen only when you want to have day in formated string. If you cannot update rails the only way to bypass this is to create your own format without getting day and insert day from ruby Time object by calling .day method on Date object. So in this case it would be for example:

contact.created_at.day.to_s + " " + l (contact.created_at, :format => "%b %H:%M" )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM