1

yml ファイルを使用して Web サイトをローカライズする必要があります。しかし、次の点で問題があります。

<tr>
    <td><%= link_to author.name, :action => 'show', :id => author %></td>
    <td><%= link_to 'Edit', :action => 'edit', :id => author %></td>
    <td>
        <%= button_to t(:delete), {:action => 'destroy', :id => author},
        {:method => :delete,
        :confirm => "Are you sure you want to delete author #{author.name}?"} %>
        :confirm => t(:sure_delete_author, :authorname=>#{author.name}) } %>
    </td>
</tr>

t(:delete)正常に機能しますが、確認は機能しません。オリジナルと動作していないものを残しました。

4

1 に答える 1

1

問題は、文字列がないときに文字列補間を使用しようとしていることです (これは単純なコピー アンド ペーストの問題のようです)。

それ以外の

:authorname => #{author.name}

次のいずれかを試してください。

:authorname => "#{author.name}"
:authorname => author.name

もちろん、最後のものが優先されます:)

PS: 私の個人的な経験では、Ruby 1.9 の新しいハッシュ構文を使用すると、多くの視覚的な煩雑さがなくなり、このような問題を見つけやすくなります。

于 2013-05-14T08:03:42.697 に答える