Skip to content

Conversation

@jhang-jhe-wei
Copy link
Contributor

Field::HasMany i18n

How to Use?

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.

Example

The recipe has many recipe items.

app/dashboards/recipe_dashboard.rb

  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

zh-TW.yml

zh-TW:
  activerecord:
    models:
      recipe: 配方表
      recipe_item: 材料

Result

image

材料種類 is defined in helper.label.recipe.recipe_items, it's not the same, don't confuse.

Copy link
Collaborator

@pablobm pablobm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this :-) Just one thing that I think can be improved.

@pablobm
Copy link
Collaborator

pablobm commented Jan 27, 2022

@jhang-jhe-wei - Could you please rebase? The specs (I don't know why) are failing and I can't merge, but it looks like a rebase should fix it.

@nickcharlton nickcharlton force-pushed the main branch 2 times, most recently from 90815b2 to 2a1a6cf Compare February 2, 2022 13:11
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: 材料
```
@nickcharlton
Copy link
Member

Thanks for opening this PR! I rebased and tidied up the commit so we could get it merged.

@nickcharlton nickcharlton merged commit cfef37b into thoughtbot:main Feb 2, 2022
shadoath pushed a commit to rinsed-org/administrate that referenced this pull request Mar 12, 2025
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: 材料
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants