glebm / i18n-tasks

Manage translation and localization with static analysis, for Ruby i18n
http://glebm.github.io/i18n-tasks
MIT License
2.07k stars 264 forks source link

Feature: Find usage of rails model validation messages #599

Open mmd-osm opened 3 weeks ago

mmd-osm commented 3 weeks ago

In https://github.com/openstreetmap/openstreetmap-website/pull/5242, we were wondering why i18n-tasks is reporting a model validation message as unused, although it is being referenced from a model:

 validates :subject, :uniqueness => { :scope => :owner_id, :message => :is_already_muted }

At the moment, we need to add the error string to the i18n-tasks.yml file to ignore the warning:

ignore_unused:
  'activerecord.errors.models.user_mute.is_already_muted'

I'm not sure if we're missing something here. Is this the recommended approach to address model validation messages?

davidwessman commented 3 weeks ago

This is not currently supported and would require a special parser. It would be a nice addition to the Prism-parser I have been working on.

mmd-osm commented 3 weeks ago

Thanks a lot for the quick reply. I think for the time being, our best option would be to go ahead with the "ignore_unused" setting. I agree that supporting this use case would be a nice addition.

davidwessman commented 3 weeks ago

Realized we have this as well: https://github.com/glebm/i18n-tasks/blob/main/lib/i18n/tasks/scanners/ast_matchers/rails_model_matcher.rb

and then the more contextual parser I have been working on: https://github.com/glebm/i18n-tasks/blob/main/lib/i18n/tasks/scanners/prism_scanner.rb