开发者

is 't' an old view helper method in rails 2.3.8?

I'm doing maintenance on an old rails app, and my rails wasn't that great to begin with. I'm seeing the following code all over in forms in views; this example is from a payment/billing screen, so the fields are common billing fields like address fields:

<%= t : "front.City" %>

This is used for the form field label. I can't figure out what either the 't' is, or the 'front'. I'm trying to copy this partial for a different payment method. When I changed the 'front.new-label', it broke something because it then displayed the label as

en, front, new-label

I'm wondering if the 't' is some kind of helper method, like <%=h is to sanitize output. This is used in a partial, so I looked in the layout that includes the partial to see if 'front' was defined anywhere in there but didn't find anything. This 't' and 'front' are used all over the app as labels, so I thought it just had something to do with s开发者_StackOverflow社区tyling. But it's used so often that I can't see all these front.variables being defined somewhere, but then why does it break when I change it?


You're correct, t is a short-cut for the i18n translation method:

http://railsapi.com/doc/rails-v2.3.8/classes/ActionController/Translation.html#M001880

Have a read of the internationalisation guide to get a feel for what's going on.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜