module I18n::Processes::Command::Commands::Missing

Public Instance Methods

missing(opt = {}) click to toggle source
# File lib/i18n/processes/command/commands/missing.rb, line 30
def missing(opt = {})
  translated_locales = opt[:locales].reject{|x| x == base_locale}
  translated_locales.each do |locale|
    $stderr.puts Rainbow("#{base_locale} to #{locale}\n").green
    preprocessing({:locales => [locale] })
    changed_keys(locale)
    missing_keys = spreadsheet_report.find_missing(locale)
    missing_count = missing_keys.count
    if missing_count.zero?
      spreadsheet_report.translated_files(locale)
      spreadsheet_report.origin_dic(locale)
    else
      $stderr.puts Rainbow("#{missing_count} keys need to be translated to #{locale}").red.bright
      spreadsheet_report.missing_report(locale)
    end
  end
end
translate_missing(opt = {}) click to toggle source
# File lib/i18n/processes/command/commands/missing.rb, line 53
def translate_missing(opt = {})
  missing    = i18n.missing_diff_forest opt[:locales], opt[:from]
  translated = i18n.google_translate_forest missing, opt[:from]
  i18n.data.merge! translated
  log_stderr "Translated #{translated.leaves.count} keys"
  print_forest translated, opt
end