-
Notifications
You must be signed in to change notification settings - Fork 264
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add default_i18n_subject AST matcher
- Loading branch information
Showing
4 changed files
with
60 additions
and
4 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
lib/i18n/tasks/scanners/ast_matchers/default_i18n_subject_matcher.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'i18n/tasks/scanners/results/occurrence' | ||
|
||
module I18n::Tasks::Scanners::AstMatchers | ||
class DefaultI18nSubjectMatcher < BaseMatcher | ||
def convert_to_key_occurrences(send_node, method_name, location: send_node.loc) | ||
children = Array(send_node&.children) | ||
return unless children[1] == :default_i18n_subject | ||
|
||
key = @scanner.absolute_key( | ||
'.subject', | ||
location.expression.source_buffer.name, | ||
calling_method: method_name | ||
) | ||
[ | ||
key, | ||
I18n::Tasks::Scanners::Results::Occurrence.from_range( | ||
raw_key: key, | ||
range: location.expression | ||
) | ||
] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class UserMailer < ApplicationMailer | ||
def welcome_notification | ||
I18n.with_locale(:en) do | ||
mail subject: default_i18n_subject | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters