Skip to content

Enhance i18n support for nested attributes and update documentation#15

Merged
Syati merged 15 commits intomainfrom
feature/nest_i18n
Apr 9, 2026
Merged

Enhance i18n support for nested attributes and update documentation#15
Syati merged 15 commits intomainfrom
feature/nest_i18n

Conversation

@Syati
Copy link
Copy Markdown
Owner

@Syati Syati commented Apr 9, 2026

This pull request makes significant improvements to the documentation for StructuredParams, focusing on clarity, organization, and enhanced guidance for users. The main changes include removing the gem comparison document, expanding and restructuring guides for basic usage, error handling, and form objects, and updating both English and Japanese README files to reflect these changes.

Documentation Restructuring and Enhancements:

  • docs/comparison.md: Removed the gem comparison document, as its content is now referenced or integrated elsewhere.
  • README.md, README_ja.md: Updated the documentation links to add a new section for Form Objects and removed the Gem Comparison section. The Japanese README also updates its usage example to better illustrate primitive array handling. [1] [2] [3]

Basic Usage Guide Improvements:

  • docs/basic-usage.md: Expanded with a table of contents and clearer explanations for defining parameter classes, nested objects, and array handling. Added explicit sections for arrays of primitives and nested objects. [1] [2] [3] [4]

Error Handling Documentation Updates:

  • docs/error-handling.md: Added a table of contents, clarified the explanation of structured errors, improved section organization, and provided distinct examples for flat and JSON:API error formats. [1] [2] [3] [4] [5] [6] [7]

Form Object Pattern Documentation Expansion:

  • docs/form-objects.md: Completely restructured and expanded with a table of contents, new sections for best practices, i18n support (including customizing nested attribute labels), API integration, and more detailed controller/view usage examples. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]

These changes make the documentation more comprehensive, easier to navigate, and more useful for both new and experienced users.

@Syati Syati self-assigned this Apr 9, 2026
Copilot AI review requested due to automatic review settings April 9, 2026 20:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds nested-attribute i18n support to StructuredParams (notably human_attribute_name for dot-notation paths) and refreshes documentation to better cover usage patterns (including form objects), with expanded spec coverage.

Changes:

  • Introduces StructuredParams::I18n and includes it in StructuredParams::Params to resolve nested dot-notation attribute labels using each nested class’ i18n context.
  • Adjusts structured error importing and updates/expands specs + test helpers/locales for nested i18n/error-message behavior.
  • Restructures and expands documentation/READMEs (adds Form Objects guide, removes comparison doc, adds TOCs and clearer examples).

Reviewed changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
spec/support/test_classes/params_classes.rb Consolidates params test classes used across multiple specs.
spec/support/test_classes/form_object_classes.rb Clarifies intended spec usage; removes duplicated helper class definitions.
spec/support/shared_contexts/ja_locale.rb Adds shared context to load JA translations and run examples under :ja.
spec/support/locales/ja.yml Adds Japanese attribute translations for nested label tests.
spec/params_spec.rb Adds coverage for nested human_attribute_name and JA formatting + full_message behavior.
spec/i18n_spec.rb Adds focused tests for dot-notation i18n formatting and format-key behavior.
spec/form_object_spec.rb Simplifies/condenses model_name tests (removes some redundant assertions).
spec/factories/user_parameters.rb Removes inline class definition now provided by shared test classes.
spec/factories/hobby_parameters.rb Removes inline class definition now provided by shared test classes.
spec/factories/address_parameters.rb Removes inline class definition now provided by shared test classes.
spec/errors_spec.rb Updates expectations to reflect new nested attribute label capitalization/format.
sig/structured_params/params.rbs Updates generated RBS to reflect inclusion of I18n.
sig/structured_params/i18n.rbs Adds generated RBS for the new StructuredParams::I18n module.
README.md Updates docs navigation (adds Form Objects link; removes comparison link).
README_ja.md Updates docs links and replaces example section with primitive-array guidance.
lib/structured_params/params.rb Includes I18n and imports nested errors with child-resolved messages.
lib/structured_params/i18n.rb Adds nested dot-notation human_attribute_name resolution with configurable i18n formats.
lib/structured_params.rb Requires the new i18n module.
docs/validation.md Adds TOC and expands/clarifies validation + validates_raw guidance.
docs/strong-parameters.md Restructures guide with TOC, clearer patterns, and guidance by use case.
docs/serialization.md Adds TOC and clarifies serialization behavior/examples.
docs/installation.md Adds TOC and clarifies installation/setup wording and examples.
docs/form-objects.md Major expansion/restructure; adds i18n nested-label customization guidance and best practices.
docs/error-handling.md Adds TOC; clarifies structured errors and improves JSON:API example.
docs/comparison.md Removes comparison document.
docs/basic-usage.md Adds TOC and clarifies nested objects/arrays (primitive vs object arrays).

Comment thread spec/support/shared_contexts/ja_locale.rb Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a18b895377

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/structured_params/i18n.rb Outdated
@Syati Syati merged commit e0beea3 into main Apr 9, 2026
10 checks passed
@Syati Syati deleted the feature/nest_i18n branch April 9, 2026 21:13
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.

2 participants