我有一个模型名为变量scaffolded与名称和说明作为变量。它的索引视图是如下:使用i18n与Bootstrap-Rails和Simple_Form
<%- 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:
simple_form:
options:
user:
gender:
male: 'Male'
female: 'Female
这并没有看到在工作的时候更改“选项”,“属性”,“用户”到“变量”等...说实话,我甚至不知道翻译是应该放在simple_form.pt_BR.yml还是新的pt-BR文件中。
任何帮助,在类似情况下使用i18n的例子将非常感激!
谢谢!
我无法使用simple_form的标签,但我遵循了您的建议并创建了另一个区域设置文件。下面的代码创建了我所需要的默认设置: 'PT-BR: 属性: 名称: “诺姆” 介绍: “Descrição” ID: “Código” '' – 2014-10-09 00:48:12