Module: StructuredParams::I18n

Extended by:
ActiveSupport::Concern
Included in:
Params
Defined in:
lib/structured_params/i18n.rb

Overview

Provides i18n-aware human_attribute_name resolution for nested dot-notation attributes (e.g. “hobbies.0.name”).

When included in a Params subclass, overrides human_attribute_name so that each segment of the path is resolved by the corresponding nested model class, ensuring that child-model translations are respected instead of falling back to the parent model’s i18n context.

i18n keys

You can customize how array indices and object nesting are rendered by defining the following keys in your locale file:

ja:
  activemodel:
    errors:
      nested_attribute:
        array:  "%{parent} %{index} 番目の%{child}"
        object: "%{parent}の%{child}"

Without these keys the defaults are (with array_index_base: 0):

array  → "<parent> <index> <child>"   (e.g. "Hobbies 0 Name")
object → "<parent> <child>"           (e.g. "Address Postal code")

With array_index_base: 1 (human-friendly):

array   "Hobbies 1 Name"