Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Rails mailer subject finding used keys #518

Open
mockdeep opened this issue Aug 21, 2023 · 1 comment
Open

Feature: Rails mailer subject finding used keys #518

mockdeep opened this issue Aug 21, 2023 · 1 comment

Comments

@mockdeep
Copy link

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} |
+--------+----------------------------------------------+----------------------------------------+
@davidwessman
Copy link
Collaborator

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 davidwessman changed the title unused violation for mailer subject Feature: Rails mailer subject finding used keys Oct 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants