Question

I am working with the I18n gem and am just wondering how the translation method can be called while using a haml based simple_form. Current my code is as follows:

\users\new.html.haml - content_for :title, "Admin | Create New User" .page-header %h1 Create New User

/config/localses/en.yml en: new_tenant: title: "Tenant Administration | Create New Tenant" header: "Create New Tenant"

/config/localses/de.yml de: new_tenant: title: "Mieter Administration | Create New Mieter" header: "Erstellen Neuer Mieter"

I have seen in Railcasts episode 138 that this could be called as follows:

<% title t('new_tenant.title') %>
<h2><%= t 'new_tenant.header' %></h2>

How can I apply this same method to the haml markup? Any tips would be greatly appreciated.

Was it helpful?

Solution

Here you go.

%title=t 'new_tenant.title' 
%h2=t 'new_tenant.header'

Sometimes you can't use the i18n shorthand t, in those cases just use I18n.t instead of the shortcut. Good luck.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top