Skip to content

Commit ffccbc7

Browse files
jhang-jhe-weinickcharlton
authored andcommitted
Add i18n support for Field::HasMany
If you have ActiveRecord i18n translation of the model you don't need to do anything extra, if not, make an ActiveRecord i18n translation of the model. e.g.: The recipe has many recipe items. ```ruby ATTRIBUTE_TYPES = { recipe_items: Field::HasMany, id: Field::Number, name: Field::String, package_spec: Field::String, remark: Field::String, created_at: Field::DateTime, updated_at: Field::DateTime, }.freeze ``` ```yaml zh-TW: activerecord: models: recipe: 配方表 recipe_item: 材料 ```
1 parent b49efe4 commit ffccbc7

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

app/views/fields/has_many/_index.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ as a count of how many objects are associated through the relationship.
1616
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/HasMany
1717
%>
1818

19-
<%= pluralize(field.data.size, field.attribute.to_s.humanize.downcase.singularize) %>
19+
<%= pluralize(field.data.size, t("activerecord.models.#{field.attribute.to_s.singularize}", default: field.attribute.to_s.humanize.downcase.singularize, count: field.data.size)) %>

0 commit comments

Comments
 (0)