Module: I18n::Processes::Command::Commands::Usages

Includes:
I18n::Processes::Command::Collection
Included in:
I18n::Processes::Commands
Defined in:
lib/i18n/processes/command/commands/usages.rb

Instance Method Summary collapse

Methods included from I18n::Processes::Command::Collection

included

Instance Method Details

#find(opt = {}) ⇒ Object



19
20
21
22
23
# File 'lib/i18n/processes/command/commands/usages.rb', line 19

def find(opt = {})
  opt[:filter] ||= opt.delete(:pattern) || opt[:arguments].try(:first)
  result = i18n.used_tree(strict: opt[:strict], key_filter: opt[:filter].presence, include_raw_references: true)
  print_forest result, opt, :used_keys
end

#remove_unused(opt = {}) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/i18n/processes/command/commands/usages.rb', line 41

def remove_unused(opt = {})
  unused_keys = i18n.unused_keys(opt.slice(:locales, :strict))
  if unused_keys.present?
    terminal_report.unused_keys(unused_keys)
    confirm_remove_unused!(unused_keys, opt)
    removed = i18n.data.remove_by_key!(unused_keys)
    log_stderr "Removed #{unused_keys.leaves.count} keys"
    print_forest removed, opt
  else
    log_stderr Rainbow("No unused keys to remove").green.bright
  end
end

#unused(opt = {}) ⇒ Object



30
31
32
33
34
# File 'lib/i18n/processes/command/commands/usages.rb', line 30

def unused(opt = {})
  forest = i18n.unused_keys(opt.slice(:locales, :strict))
  print_forest forest, opt, :unused_keys
  :exit_1 unless forest.empty?
end