【发布时间】:2014-10-03 19:18:09
【问题描述】:
我有一个名为 Variable 的模型,其名称和描述为变量。其索引视图如下:
<%- model_class = Variable -%>
<div class="page-header">
<h1><%=t '.title', :default => model_class.model_name.human.pluralize.titleize %></h1>
</div>
<table class="table table-striped">
<thead>
<tr>
<th><%= model_class.human_attribute_name(:id) %></th>
<th><%= model_class.human_attribute_name(:name) %></th>
<th><%= model_class.human_attribute_name(:description) %></th>
<th><%= model_class.human_attribute_name(:created_at) %></th>
<th><%=t '.actions', :default => t("helpers.actions") %></th>
</tr>
</thead>
<tbody>
<% @variables.each do |variable| %>
<tr>
<td><%= link_to variable.id, variable_path(variable) %></td>
<td><%= variable.name %></td>
<td><%= variable.description %></td>
<td><%=l variable.created_at %></td>
<td>
<%= link_to t('.edit', :default => t("helpers.links.edit")),
edit_variable_path(variable), :class => 'btn btn-default btn-xs' %>
<%= link_to t('.destroy', :default => t("helpers.links.destroy")),
variable_path(variable),
:method => :delete,
:data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) },
:class => 'btn btn-xs btn-danger' %>
</td>
</tr>
<% end %>
</tbody>
</table>
<%= link_to t('.new', :default => t("helpers.links.new")),
new_variable_path,
:class => 'btn btn-primary' %>
所以,它是一个标准的脚手架 + Twitter_Bootstrap,由 Simple_form 代码生成。
我想把它翻译成 pt-BR 和 es,但我真的不明白怎么做,因为它使用了 model_class.human_attribute_name(:name)。 simple_form 网站说(假设我要翻译成 en):
en:
simple_form:
options:
user:
gender:
male: 'Male'
female: 'Female
当我将“选项”更改为“属性”,将“用户”更改为“变量”等等时,这似乎不起作用......说实话,我什至不知道是否应该放置翻译在 simple_form.pt_BR.yml 或新的 pt-BR 文件中。
任何帮助,在类似情况下使用的 i18n 示例将不胜感激!
谢谢!
【问题讨论】:
标签: ruby-on-rails twitter-bootstrap internationalization simple-form rails-i18n