Module: Bisu

Extended by:
Bisu
Included in:
Bisu
Defined in:
lib/bisu.rb,
lib/bisu/config.rb,
lib/bisu/logger.rb,
lib/bisu/version.rb,
lib/bisu/localizer.rb,
lib/bisu/dictionary.rb,
lib/bisu/source/url.rb,
lib/bisu/source/one_sky.rb,
lib/bisu/source/google_sheet.rb

Defined Under Namespace

Modules: Logger, Source Classes: Config, Dictionary, Localizer

Constant Summary collapse

VERSION =
'1.10.0'
VERSION_UPDATED_AT =
'2021-08-30'

Instance Method Summary collapse

Instance Method Details

#run(options) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/bisu.rb', line 18

def run(options)
  options = command_line_options(options)

  if config_file = open_file("translatable.yml", "r", true)
    config       = Bisu::Config.new(hash: YAML::load(config_file))
    dictionary   = dictionary_for(config: config.dictionary, options: options)
    localizer    = Bisu::Localizer.new(dictionary, config.type)

    config.localize_files do |in_path, out_path, locale, language, fallback_language|
      unless dictionary.has_language?(language)
        Logger.error("Unknown language #{language}")
        return false
      end

      fallback_languages = ([fallback_language] + [options[:default_language]]).compact

      localize_file(localizer, locale, language, fallback_languages, in_path, out_path)
    end
  end

  Logger.print_summary

  if options[:strict] && Logger.summary[:warn] > 0
    Logger.error("Found a warning while in strict mode")
  end
end