lib/i18n/tasks/scanners/pattern_scanner.rb in i18n-tasks-0.8.3 vs lib/i18n/tasks/scanners/pattern_scanner.rb in i18n-tasks-0.8.4

- old
+ new

@@ -45,11 +45,11 @@ absolute_key(key, path, location) end def absolute_key(key, path, location) if key.start_with?('.') - if controller_file?(path) + if controller_file?(path) || mailer_file?(path) absolutize_key(key, path, relative_roots, closest_method(location)) else absolutize_key(key, path) end else @@ -57,9 +57,13 @@ end end def controller_file?(path) /controllers/.match(path) + end + + def mailer_file?(path) + /mailers/.match(path) end def closest_method(location) method = File.readlines(location[:src_path], encoding: 'UTF-8').first(location[:line_num] - 1).reverse_each.find { |x| x=~ /\bdef\b/ } method &&= method.strip.sub(/^def\s*/, '').sub(/[\(\s;].*$/, '')