i18n-tasks icon indicating copy to clipboard operation
i18n-tasks copied to clipboard

Feature: Rails mailer subject finding used keys

Open mockdeep opened this issue 2 years ago • 1 comments
trafficstars

Rails automatically grabs email the email subject from I18n files without needing to be explicitly referenced in code. However, i18n-tasks reports it as an unused translation:

Unused keys (1) | i18n-tasks v1.0.12
+--------+----------------------------------------------+----------------------------------------+
| Locale | Key                                          | Value                                  |
+--------+----------------------------------------------+----------------------------------------+
|   en   | campaign_mailer.verification_message.subject | Verification Code for %{campaign_name} |
+--------+----------------------------------------------+----------------------------------------+

mockdeep avatar Aug 21 '23 03:08 mockdeep

We would need to write a custom scanner or matcher, something like: https://github.com/glebm/i18n-tasks/blob/main/lib/i18n/tasks/scanners/ast_matchers/rails_model_matcher.rb

and add it only for certain files, like:

I18n::Tasks.add_scanner "MailerScanner", only: %w[*_mailer.rb]

davidwessman avatar Aug 21 '23 05:08 davidwessman