From c699634ad1e3e45fa7bb8babae2e0b547f59a0b3 Mon Sep 17 00:00:00 2001 From: Tomoya Chiba Date: Wed, 13 May 2015 11:22:56 +0900 Subject: [PATCH 01/10] Support ActionMailer The `translate` method in ActionMailer does not lookup . but ... --- lib/i18n/tasks/scanners/pattern_scanner.rb | 6 +++- spec/fixtures/config/i18n-tasks.yml | 1 + spec/relative_keys_spec.rb | 39 ++++++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/lib/i18n/tasks/scanners/pattern_scanner.rb b/lib/i18n/tasks/scanners/pattern_scanner.rb index c32c60f3..d10080e1 100644 --- a/lib/i18n/tasks/scanners/pattern_scanner.rb +++ b/lib/i18n/tasks/scanners/pattern_scanner.rb @@ -47,7 +47,7 @@ def match_to_key(match, path, location) 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) @@ -61,6 +61,10 @@ 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;].*$/, '') diff --git a/spec/fixtures/config/i18n-tasks.yml b/spec/fixtures/config/i18n-tasks.yml index 8370869b..41bb0ce3 100644 --- a/spec/fixtures/config/i18n-tasks.yml +++ b/spec/fixtures/config/i18n-tasks.yml @@ -36,6 +36,7 @@ search: relative_roots: - app/views - app/controllers + - app/mailers # do not report these keys ever diff --git a/spec/relative_keys_spec.rb b/spec/relative_keys_spec.rb index c4b97af1..e50b90cb 100644 --- a/spec/relative_keys_spec.rb +++ b/spec/relative_keys_spec.rb @@ -55,5 +55,44 @@ end end end + + context 'relative key in mailer' do + it 'works' do + key = scanner.absolutize_key( + '.subject', + 'app/mailers/user_mailer.rb', + %w(app/mailers), + 'welcome' + ) + + expect(key).to eq('user_mailer.welcome.subject') + end + + context 'multiple words in mailer name' do + it 'works' do + key = scanner.absolutize_key( + '.subject', + 'app/mailers/admin_user_mailer.rb', + %w(app/mailers), + 'welcome' + ) + + expect(key).to eq('admin_user_mailer.welcome.subject') + end + end + + context 'nested in module' do + it 'works' do + key = scanner.absolutize_key( + '.subject', + 'app/mailers/nested/user_mailer.rb', + %w(app/mailers), + 'welcome' + ) + + expect(key).to eq('nested.user_mailer.welcome.subject') + end + end + end end end From 3f963c505bb386c64f24d90503cbbc009207a5cb Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Mon, 18 May 2015 19:29:31 +0100 Subject: [PATCH 02/10] Reduce ActiveSupport dependencies, compat with 2.3 --- lib/i18n/tasks.rb | 11 +++++++++-- lib/i18n/tasks/command/collection.rb | 1 + lib/i18n/tasks/command/commands/missing.rb | 2 ++ lib/i18n/tasks/command/dsl.rb | 4 +--- lib/i18n/tasks/command/options/common.rb | 1 + lib/i18n/tasks/data.rb | 6 +++--- lib/i18n/tasks/data/file_system_base.rb | 11 +++++++---- lib/i18n/tasks/data/tree/traversal.rb | 2 +- lib/i18n/tasks/split_key.rb | 2 +- lib/i18n/tasks/used_keys.rb | 2 +- spec/support/capture_std.rb | 1 + 11 files changed, 28 insertions(+), 15 deletions(-) diff --git a/lib/i18n/tasks.rb b/lib/i18n/tasks.rb index ed768c85..41116cc1 100644 --- a/lib/i18n/tasks.rb +++ b/lib/i18n/tasks.rb @@ -24,12 +24,19 @@ module Data end +require 'active_support/inflector' require 'active_support/core_ext/hash' -require 'active_support/core_ext/string' require 'active_support/core_ext/array/access' +require 'active_support/core_ext/array/extract_options' require 'active_support/core_ext/module/delegation' -require 'active_support/core_ext/object/try' require 'active_support/core_ext/object/blank' +begin + # activesupport >= 3 + require 'active_support/core_ext/object/try' +rescue LoadError => _e + # activesupport ~> 2.3.2 + require 'active_support/core_ext/try' +end require 'term/ansicolor' require 'erubis' diff --git a/lib/i18n/tasks/command/collection.rb b/lib/i18n/tasks/command/collection.rb index b284cf5a..3989cc5f 100644 --- a/lib/i18n/tasks/command/collection.rb +++ b/lib/i18n/tasks/command/collection.rb @@ -1,3 +1,4 @@ +require 'i18n/tasks/command/dsl' require 'i18n/tasks/command/options/common' require 'i18n/tasks/command/options/locales' require 'i18n/tasks/command/options/data' diff --git a/lib/i18n/tasks/command/commands/missing.rb b/lib/i18n/tasks/command/commands/missing.rb index 0b0f219d..a2403751 100644 --- a/lib/i18n/tasks/command/commands/missing.rb +++ b/lib/i18n/tasks/command/commands/missing.rb @@ -1,3 +1,5 @@ +require 'i18n/tasks/command/collection' + module I18n::Tasks module Command module Commands diff --git a/lib/i18n/tasks/command/dsl.rb b/lib/i18n/tasks/command/dsl.rb index 05ff267e..48d2a211 100644 --- a/lib/i18n/tasks/command/dsl.rb +++ b/lib/i18n/tasks/command/dsl.rb @@ -3,9 +3,7 @@ module Command module DSL def self.included(base) base.module_eval do - @dsl = HashWithIndifferentAccess.new { |h, k| - h[k] = HashWithIndifferentAccess.new - } + @dsl = Hash.new { |h, k| h[k] = {} } extend ClassMethods end end diff --git a/lib/i18n/tasks/command/options/common.rb b/lib/i18n/tasks/command/options/common.rb index 57c41c98..7e5790ab 100644 --- a/lib/i18n/tasks/command/options/common.rb +++ b/lib/i18n/tasks/command/options/common.rb @@ -1,3 +1,4 @@ +require 'i18n/tasks/command/dsl' module I18n::Tasks module Command diff --git a/lib/i18n/tasks/data.rb b/lib/i18n/tasks/data.rb index d66f4c6a..296767d4 100644 --- a/lib/i18n/tasks/data.rb +++ b/lib/i18n/tasks/data.rb @@ -10,11 +10,11 @@ def data @data ||= begin data_config = (config[:data] || {}).with_indifferent_access data_config.merge!(base_locale: base_locale, locales: config[:locales]) - adapter_class = data_config[:adapter].presence || data_config[:class].presence || :file_system + adapter_class = data_config[:adapter].presence || data_config[:class].presence || 'file_system' adapter_class = adapter_class.to_s - adapter_class = "I18n::Tasks::Data::#{adapter_class.camelize}" if adapter_class !~ /[A-Z]/ + adapter_class = 'I18n::Tasks::Data::FileSystem' if adapter_class == 'file_system' data_config.except!(:adapter, :class) - adapter_class.constantize.new data_config + Object.const_get(adapter_class).new data_config end end diff --git a/lib/i18n/tasks/data/file_system_base.rb b/lib/i18n/tasks/data/file_system_base.rb index 4ac174fb..55586189 100644 --- a/lib/i18n/tasks/data/file_system_base.rb +++ b/lib/i18n/tasks/data/file_system_base.rb @@ -122,13 +122,16 @@ def with_router(router) self.router = router_was end + + ROUTER_NAME_ALIASES = { + 'conservative_router' => 'I18n::Tasks::Data::Router::ConservativeRouter', + 'pattern_router' => 'I18n::Tasks::Data::Router::PatternRouter' + } def router @router ||= begin name = @config[:router].presence || 'conservative_router' - if name[0] != name[0].upcase - name = "I18n::Tasks::Data::Router::#{name.classify}" - end - name.constantize.new(self, @config.merge(base_locale: base_locale, locales: locales)) + name = ROUTER_NAME_ALIASES[name] || name + Object.const_get(name).new(self, @config.merge(base_locale: base_locale, locales: locales)) end end attr_writer :router diff --git a/lib/i18n/tasks/data/tree/traversal.rb b/lib/i18n/tasks/data/tree/traversal.rb index b0e5e17b..48afb947 100644 --- a/lib/i18n/tasks/data/tree/traversal.rb +++ b/lib/i18n/tasks/data/tree/traversal.rb @@ -128,7 +128,7 @@ def grep_keys(match, opts = {}) def set_each_value!(val_pattern, key_pattern = nil, &value_proc) value_proc ||= proc { |node| node_value = node.value - human_key = node.key.to_s.humanize + human_key = ActiveSupport::Inflector.humanize(node.key.to_s) StringInterpolation.interpolate_soft( val_pattern, value: node_value, diff --git a/lib/i18n/tasks/split_key.rb b/lib/i18n/tasks/split_key.rb index 96bd4a78..20652eac 100644 --- a/lib/i18n/tasks/split_key.rb +++ b/lib/i18n/tasks/split_key.rb @@ -17,7 +17,7 @@ def split_key(key, max = Float::INFINITY) parts << part pos += part.length + 1 if parts.length + 1 >= max - parts << key.from(pos) unless pos == key.length + parts << key[pos..-1] unless pos == key.length break end end diff --git a/lib/i18n/tasks/used_keys.rb b/lib/i18n/tasks/used_keys.rb index 4a286410..914fa464 100644 --- a/lib/i18n/tasks/used_keys.rb +++ b/lib/i18n/tasks/used_keys.rb @@ -22,7 +22,7 @@ def scanner @scanner ||= begin search_config = (config[:search] || {}).with_indifferent_access class_name = search_config[:scanner] || '::I18n::Tasks::Scanners::PatternWithScopeScanner' - class_name.constantize.new search_config + Object.const_get(class_name).new search_config end end diff --git a/spec/support/capture_std.rb b/spec/support/capture_std.rb index d40193f3..ea072fe6 100644 --- a/spec/support/capture_std.rb +++ b/spec/support/capture_std.rb @@ -1,4 +1,5 @@ # coding: utf-8 +require 'active_support/core_ext/kernel/reporting' module CaptureStd def capture_stderr err, $stderr = $stderr, StringIO.new From a5db8f964fcc8f3449b9baf606d651e4e34e31e9 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Mon, 18 May 2015 22:06:37 +0100 Subject: [PATCH 03/10] Use ActiveSupport::Inflector.constantize instead of const_get for ruby 1.9 support --- lib/i18n/tasks/data.rb | 2 +- lib/i18n/tasks/data/file_system_base.rb | 2 +- lib/i18n/tasks/used_keys.rb | 2 +- spec/i18n_tasks_spec.rb | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/i18n/tasks/data.rb b/lib/i18n/tasks/data.rb index 296767d4..a9789b34 100644 --- a/lib/i18n/tasks/data.rb +++ b/lib/i18n/tasks/data.rb @@ -14,7 +14,7 @@ def data adapter_class = adapter_class.to_s adapter_class = 'I18n::Tasks::Data::FileSystem' if adapter_class == 'file_system' data_config.except!(:adapter, :class) - Object.const_get(adapter_class).new data_config + ActiveSupport::Inflector.constantize(adapter_class).new data_config end end diff --git a/lib/i18n/tasks/data/file_system_base.rb b/lib/i18n/tasks/data/file_system_base.rb index 55586189..952fa4e0 100644 --- a/lib/i18n/tasks/data/file_system_base.rb +++ b/lib/i18n/tasks/data/file_system_base.rb @@ -131,7 +131,7 @@ def router @router ||= begin name = @config[:router].presence || 'conservative_router' name = ROUTER_NAME_ALIASES[name] || name - Object.const_get(name).new(self, @config.merge(base_locale: base_locale, locales: locales)) + ActiveSupport::Inflector.constantize(name).new(self, @config.merge(base_locale: base_locale, locales: locales)) end end attr_writer :router diff --git a/lib/i18n/tasks/used_keys.rb b/lib/i18n/tasks/used_keys.rb index 914fa464..8522a1b4 100644 --- a/lib/i18n/tasks/used_keys.rb +++ b/lib/i18n/tasks/used_keys.rb @@ -22,7 +22,7 @@ def scanner @scanner ||= begin search_config = (config[:search] || {}).with_indifferent_access class_name = search_config[:scanner] || '::I18n::Tasks::Scanners::PatternWithScopeScanner' - Object.const_get(class_name).new search_config + ActiveSupport::Inflector.constantize(class_name).new search_config end end diff --git a/spec/i18n_tasks_spec.rb b/spec/i18n_tasks_spec.rb index 25e8538e..77c7eeb6 100644 --- a/spec/i18n_tasks_spec.rb +++ b/spec/i18n_tasks_spec.rb @@ -158,7 +158,7 @@ } run_cmd 'add-missing', 'base' in_test_app_dir { - expect(YAML.load_file('config/locales/en.yml')['en']['used_but_missing']['key']).to eq I18n.t('i18n_tasks.common.key') + expect(YAML.load_file('config/locales/en.yml')['en']['used_but_missing']['key']).to eq 'Key' expect(YAML.load_file('config/locales/en.yml')['en']['present_in_es_but_not_en']['a']).to eq 'ES_TEXT' } end From b03f972fb021b4c0c76534a085d9de2bf1984d27 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Sat, 27 Jun 2015 12:28:56 +0100 Subject: [PATCH 04/10] changelog --- CHANGES.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index ba7e0978..25ec30ce 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,7 @@ +## 0.8.4 (unreleased) + +* Support relative keys in mailers [#155](https://github.com/glebm/i18n-tasks/issues/155). + ## 0.8.3 * Fix regression: ActiveSupport < 4 support [#143](https://github.com/glebm/i18n-tasks/issues/143). From dd3455aea323ce99e97d659ffac5d697284a1c3d Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Sat, 27 Jun 2015 12:36:04 +0100 Subject: [PATCH 05/10] Lock terminal-table to 1.4.5 due to https://github.com/tj/terminal-table/issues/55 --- i18n-tasks.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18n-tasks.gemspec b/i18n-tasks.gemspec index c5fbd50d..74286c0f 100644 --- a/i18n-tasks.gemspec +++ b/i18n-tasks.gemspec @@ -37,7 +37,7 @@ TEXT s.add_dependency 'activesupport' s.add_dependency 'easy_translate', '>= 0.5.0' s.add_dependency 'term-ansicolor' - s.add_dependency 'terminal-table' + s.add_dependency 'terminal-table', '~> 1.4.5' s.add_dependency 'highline' s.add_dependency 'i18n' s.add_development_dependency 'axlsx', '~> 2.0' From 38ee77c81d7bb65a2daf34a98baa2262efd187ef Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Sat, 27 Jun 2015 13:05:52 +0100 Subject: [PATCH 06/10] Bump to 0.8.4 --- lib/i18n/tasks/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/i18n/tasks/version.rb b/lib/i18n/tasks/version.rb index ebedeb8b..310c7785 100644 --- a/lib/i18n/tasks/version.rb +++ b/lib/i18n/tasks/version.rb @@ -1,6 +1,6 @@ # coding: utf-8 module I18n module Tasks - VERSION = '0.8.3' + VERSION = '0.8.4' end end From fee8190513099ebb975fabafd225a155face1801 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Sat, 27 Jun 2015 13:06:06 +0100 Subject: [PATCH 07/10] changelog --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 25ec30ce..3a9691f1 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,4 @@ -## 0.8.4 (unreleased) +## 0.8.4 * Support relative keys in mailers [#155](https://github.com/glebm/i18n-tasks/issues/155). From 1fe7a442c18a7b76d91ce8cd400225eb3e5d88b2 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Sun, 28 Jun 2015 13:55:02 +0100 Subject: [PATCH 08/10] Fix plugins support #153 --- Rakefile | 2 +- lib/i18n/tasks/cli.rb | 8 +++++++- lib/i18n/tasks/command/commander.rb | 10 +++++----- spec/fixtures/config/i18n-tasks.yml | 3 +++ spec/fixtures/lib/test_i18n_plugin.rb | 12 ++++++++++++ spec/i18n_tasks_spec.rb | 28 +++++++++++++++------------ 6 files changed, 44 insertions(+), 19 deletions(-) create mode 100644 spec/fixtures/lib/test_i18n_plugin.rb diff --git a/Rakefile b/Rakefile index 0b8e7585..12067436 100644 --- a/Rakefile +++ b/Rakefile @@ -7,5 +7,5 @@ task :irb do # $: << File.expand_path('lib', __FILE__) require 'i18n/tasks' require 'i18n/tasks/commands' - ::I18n::Tasks::Commands.new.irb + ::I18n::Tasks::Commands.new(::I18n::Tasks::BaseTask.new).irb end diff --git a/lib/i18n/tasks/cli.rb b/lib/i18n/tasks/cli.rb index fdae685c..e4e10fb5 100644 --- a/lib/i18n/tasks/cli.rb +++ b/lib/i18n/tasks/cli.rb @@ -40,10 +40,12 @@ def run(argv) end def context - @context ||= ::I18n::Tasks::Commands.new.tap(&:set_internal_locale!) + @context ||= ::I18n::Tasks::Commands.new(base_task).tap(&:set_internal_locale!) end def commands + # load base task to initialize plugins + base_task @commands ||= ::I18n::Tasks::Commands.cmds.dup.tap do |cmds| # Hash#transform_keys is only available since activesupport v4.0.0 cmds.keys.each { |k| cmds[k.to_s.tr('_', '-')] = cmds.delete(k) } @@ -52,6 +54,10 @@ def commands private + def base_task + @base_task ||= I18n::Tasks::BaseTask.new + end + def parse!(argv) command = parse_command! argv options = optparse! command, argv diff --git a/lib/i18n/tasks/command/commander.rb b/lib/i18n/tasks/command/commander.rb index dbba92bf..6e9c1107 100644 --- a/lib/i18n/tasks/command/commander.rb +++ b/lib/i18n/tasks/command/commander.rb @@ -8,7 +8,11 @@ module Command class Commander include ::I18n::Tasks::Logging - def initialize(i18n = nil) + attr_reader :i18n + + + # @param [I18n::Tasks::BaseTask] i18n + def initialize(i18n) @i18n = i18n end @@ -37,10 +41,6 @@ def spreadsheet_report @spreadsheet_report ||= I18n::Tasks::Reports::Spreadsheet.new(i18n) end - def i18n - @i18n ||= I18n::Tasks::BaseTask.new - end - delegate :base_locale, :locales, :t, to: :i18n end end diff --git a/spec/fixtures/config/i18n-tasks.yml b/spec/fixtures/config/i18n-tasks.yml index 41bb0ce3..e9db2861 100644 --- a/spec/fixtures/config/i18n-tasks.yml +++ b/spec/fixtures/config/i18n-tasks.yml @@ -1,3 +1,6 @@ +<% require './lib/test_i18n_plugin' + ::I18n::Tasks::Commands.send :include, TestI18nPlugin %> + base_locale: en locales: [es] diff --git a/spec/fixtures/lib/test_i18n_plugin.rb b/spec/fixtures/lib/test_i18n_plugin.rb new file mode 100644 index 00000000..42423ae0 --- /dev/null +++ b/spec/fixtures/lib/test_i18n_plugin.rb @@ -0,0 +1,12 @@ +# An i18n-tasks plugin to test that the plugin system works. +module TestI18nPlugin + include ::I18n::Tasks::Command::Collection + + cmd :greet, + desc: 'print "Hello, %{name}"', + args: [['-n', '--name NAME', 'name']] + + def greet(opts = {}) + puts "Hello, #{opts[:name]}" + end +end diff --git a/spec/i18n_tasks_spec.rb b/spec/i18n_tasks_spec.rb index 77c7eeb6..02d5e968 100644 --- a/spec/i18n_tasks_spec.rb +++ b/spec/i18n_tasks_spec.rb @@ -10,18 +10,22 @@ describe 'bin/i18n-tasks' do it 'shows help when invoked with no arguments, shows version on --version' do # These bin/i18n-tasks tests are executed in parallel for performance - [ - proc { - out, err, status = Open3.capture3('bin/i18n-tasks') - expect(status).to be_success - expect(out).to be_empty - expect(err).to start_with('Usage: i18n-tasks [command] [options]') - expect(err).to include('Available commands', 'add-missing') - }, - proc { - expect(%x[bin/i18n-tasks --version].chomp).to eq(I18n::Tasks::VERSION) - } - ].map { |test| Thread.start(&test) }.each(&:join) + in_test_app_dir do + [ + proc { + out, err, status = Open3.capture3('../../bin/i18n-tasks') + expect(status).to be_success + expect(out).to be_empty + expect(err).to start_with('Usage: i18n-tasks [command] [options]') + expect(err).to include('Available commands', 'add-missing') + # a task from a plugin + expect(err).to include('greet') + }, + proc { + expect(%x[../../bin/i18n-tasks --version].chomp).to eq(I18n::Tasks::VERSION) + } + ].map { |test| Thread.start(&test) }.each(&:join) + end end end From 126272ca6459d9898464308de3401954283d0a34 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Sun, 28 Jun 2015 14:04:36 +0100 Subject: [PATCH 09/10] Bump to 0.8.5 --- CHANGES.md | 4 ++++ i18n-tasks.gemspec | 2 +- lib/i18n/tasks/version.rb | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 3a9691f1..0f6e2155 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,7 @@ +## 0.8.5 + +* Fix regression: Plugin support [#153](https://github.com/glebm/i18n-tasks/issues/153). + ## 0.8.4 * Support relative keys in mailers [#155](https://github.com/glebm/i18n-tasks/issues/155). diff --git a/i18n-tasks.gemspec b/i18n-tasks.gemspec index 74286c0f..75dcbb93 100644 --- a/i18n-tasks.gemspec +++ b/i18n-tasks.gemspec @@ -37,7 +37,7 @@ TEXT s.add_dependency 'activesupport' s.add_dependency 'easy_translate', '>= 0.5.0' s.add_dependency 'term-ansicolor' - s.add_dependency 'terminal-table', '~> 1.4.5' + s.add_dependency 'terminal-table', '>= 1.5.1' s.add_dependency 'highline' s.add_dependency 'i18n' s.add_development_dependency 'axlsx', '~> 2.0' diff --git a/lib/i18n/tasks/version.rb b/lib/i18n/tasks/version.rb index 310c7785..3a50d686 100644 --- a/lib/i18n/tasks/version.rb +++ b/lib/i18n/tasks/version.rb @@ -1,6 +1,6 @@ # coding: utf-8 module I18n module Tasks - VERSION = '0.8.4' + VERSION = '0.8.5' end end From 9cd47aa2473182d5c75463e019fea9554e23c54b Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Sun, 28 Jun 2015 14:16:34 +0100 Subject: [PATCH 10/10] add app/mailers to default search.relative_roots --- lib/i18n/tasks/scanners/base_scanner.rb | 4 +++- templates/config/i18n-tasks.yml | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/i18n/tasks/scanners/base_scanner.rb b/lib/i18n/tasks/scanners/base_scanner.rb index 1c2122b3..ce8ca98b 100644 --- a/lib/i18n/tasks/scanners/base_scanner.rb +++ b/lib/i18n/tasks/scanners/base_scanner.rb @@ -15,7 +15,9 @@ class BaseScanner def initialize(config = {}) @config = config.dup.with_indifferent_access.tap do |conf| - conf[:relative_roots] = %w(app/views app/controllers app/helpers app/presenters) if conf[:relative_roots].blank? + if conf[:relative_roots].blank? + conf[:relative_roots] = %w(app/controllers app/helpers app/mailers app/presenters app/views) + end conf[:paths] = %w(app/) if conf[:paths].blank? conf[:include] = Array(conf[:include]) if conf[:include].present? conf[:exclude] = Array(conf[:exclude]) + ALWAYS_EXCLUDE diff --git a/templates/config/i18n-tasks.yml b/templates/config/i18n-tasks.yml index 137483b0..1df29d81 100644 --- a/templates/config/i18n-tasks.yml +++ b/templates/config/i18n-tasks.yml @@ -54,10 +54,11 @@ search: ## Root directories for relative keys resolution. # relative_roots: - # - app/views # - app/controllers # - app/helpers + # - app/mailers # - app/presenters + # - app/views ## Files or `File.fnmatch` patterns to exclude from search. Some files are always excluded regardless of this setting: ## %w(*.jpg *.png *.gif *.svg *.ico *.eot *.otf *.ttf *.woff *.woff2 *.pdf *.css *.sass *.scss *.less *.yml *.json)