Sha256: 411b89477db1b627acc403d30906aa420ee632ad948f21818a4d792dca1d2566

Contents?: true

Size: 1.22 KB

Versions: 2

Compression:

Stored size: 1.22 KB

Contents

desc 'Build and download last exported translation resources from Crowdin'
command :'download:translations' do |c|
  c.desc 'Directory of resource files'
  c.long_desc <<-EOS.strip_heredoc
    This is the directory where the project's files will be store.
  EOS
  c.default_value 'resources'
  c.arg_name 'dir'
  c.flag [:resources_dir]

  c.desc 'Resources config file'
  c.long_desc <<-EOS.strip_heredoc
    This is the config file where the information about project's files will be store.
  EOS
  c.default_value 'resources/.resources.yml'
  c.arg_name 'file'
  c.flag [:resources_config]

  c.action do |global_options, options, args|
    resources_dir = File.join(File.dirname(global_options[:config]), options[:resources_dir])
    resources_config_file = File.join(File.dirname(global_options[:config]), options[:resources_config])

    language = 'all'
    tempfile = Tempfile.new(language)
    zipfile_name = tempfile.path

    begin
      export_translations!(@crowdin)

      puts 'Downloading translations'
      @crowdin.download_translation(language, output: zipfile_name)

      unzip_file_with_translations(zipfile_name, resources_dir)
    ensure
      tempfile.close
      tempfile.unlink # delete the tempfile
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fci-0.0.4 lib/fci/commands/03_download.rb
fci-0.0.3 lib/fci/commands/03_download.rb