Refactor: Use native error i18n lookup #1076

Merged
pedrocarmona merged 1 commits from use-native-error-i18n-lookup into main 2024-08-13 08:38:58 +08:00
pedrocarmona commented 2024-08-10 16:37:47 +08:00 (Migrated from github.com)

This pull request refactors the existing error handling system to implement native internationalization (i18n) for error messages.

Rails guides documents the lookup order for a validation of name is not empty on the user model:

activerecord.errors.models.user.attributes.name.blank
activerecord.errors.models.user.blank
activerecord.errors.messages.blank
errors.attributes.name.blank
errors.messages.blank

I had to add magic comment hints for i18n-tasks to recognized that this translations are used.
I have not perfomed changes in lib/money.rb because i18n-tasks would not peek into that file.

This pull request refactors the existing error handling system to implement native internationalization (i18n) for error messages. Rails [guides](https://guides.rubyonrails.org/i18n.html#error-message-scopes) documents the lookup order for a validation of name is not empty on the user model: ``` activerecord.errors.models.user.attributes.name.blank activerecord.errors.models.user.blank activerecord.errors.messages.blank errors.attributes.name.blank errors.messages.blank ``` I had to add magic comment hints for [i18n-tasks to recognized](https://github.com/glebm/i18n-tasks?tab=readme-ov-file#fine-tuning) that this translations are used. I have not perfomed changes in lib/money.rb because i18n-tasks would not peek into that file.
zachgoll (Migrated from github.com) approved these changes 2024-08-13 08:38:45 +08:00
zachgoll (Migrated from github.com) left a comment

Really nice work here, thanks for going through and updating this!

Really nice work here, thanks for going through and updating this!
Sign in to join this conversation.