Forum: Rails I18n different view based on different model

Posted by Richard Schneeman (snowmaninthesun)
on 2009-01-03 18:55
I have a view that looks like this "Add a New #{@element.class}"
where my class can be "definition", "phrase", etc.

I want to do something like

<%= t 'new.form.@element.class'%>

so when @element is a "phrase" my view would show "Add New Phrase", When
my @element is a "definition" my view needs to be "Add New Definition"

Is this possible?
Posted by Richard Schneeman (snowmaninthesun)
on 2009-01-04 20:56
This forum must really not get much traffic. Anywhoo, I solved my own 
problem


<% type_of_element = @element.class.to_s.downcase %>
<% add_element_to_translate =
                          ["model", "add", type_of_element 
].compact.join('.')%>
<%= t add_element_to_translate %>

hopes this helps someone else, if you figure out a better way let me 
know!!

--
Richard
http://www.slangslang.com
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.