0

私は I18n gem を使用していますが、haml ベースの simple_form を使用しているときに翻訳メソッドをどのように呼び出すことができるのか疑問に思っています。現在の私のコードは次のとおりです。

\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: "テナント管理 | 新しいテナントの作成" header: "新しいテナントの作成"

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

Railcasts のエピソード 138 で、これが次のように呼び出されることを見てきました。

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

これと同じ方法を haml マークアップに適用するにはどうすればよいですか? どんなヒントでも大歓迎です。

4

1 に答える 1

0

どうぞ。

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

i18n の省略形tを使用できない場合があります。そのような場合は、ショートカットの代わりにI18n.tを使用してください。幸運を。

于 2012-05-24T05:45:18.447 に答える