我正在使用 twitter-bootstrap-rails
我的应用程序中的 gem 。它似乎带有一系列辅助方法,可以在主题 View 中创建例如编辑和删除按钮:
<%= link_to t('.destroy', :default => t("helpers.links.destroy")),
cohort_path(cohort),
:method => :delete,
:confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')),
:class => 'btn btn-mini btn-danger' %>
这些 t() 方法和助手在哪里定义的?我怎样才能改变它们?例如,如果我想将销毁按钮上的标签更改为“删除”,我可以将上述内容更改为:
<%= link_to t('.destroy', :default => "Delete"),
cohort_path(cohort),
:method => :delete,
:confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')),
:class => 'btn btn-mini btn-danger' %>
我真正想做的是改变
t("helpers.links.destroy")
在我的所有 View 中显示“删除”而不是“销毁”。我可以这样做吗?感谢你的帮助!
最佳答案
您所要做的就是将以下内容添加到您的 i18n Rails 文件中(在路径“config/locales/en.yml”中):
<pre>
en:
helpers:
links:
back: "Back Page"
destroy: "Delete"
</pre>
方法 t() 用于 i18n 一个 Rails 应用程序。
关于ruby-on-rails-3 - rails twitter bootstrap helper 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11224276/