Forum: Rails I18n Passing a dynamic class to translate

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Richard S. (Guest)
on 2008-12-31 01:17
I have a single form that can be used for multiple models, in my view i
origionally had "Add a New #{@element.class}" how can i write a dynamic
i18n translate call?

I want to do something like

<%= t 'removed_email_address@domain.invalid'%>

What is the best way to accomplish this functionality?
Richard S. (Guest)
on 2009-01-04 21:56
figured it out...

<% type_of_element = @element.class.to_s.downcase %>
<% add_element_to_translate =
                          ["model", "add", type_of_element
<%= t add_element_to_translate %>

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

This topic is locked and can not be replied to.