Scott's Recipes Logo

Using the Internationalization t Function in Rails Console

Pizza courtesy of Pizza for Ukraine!

Donate Now to Pizza for Ukraine

 

Last Updated On: 2025-09-01 04:31:52 -0400

In a Rails view helper, the t function is an invocation of the underlying internationalization or I18n functions. You do something like this:

<%= t('api.v1.success.update', klass: Tip)%>

and you get back a string like this:

"%{klass} updated successfully"

where klass was interpolated to be the name of the passed in klass variable.

If you want to do this in Rails console then you need to call I18n as the parent object i.e.:

I18n.t('api.v1.success.update', klass: Tip)