Sha256: 4b31832ed540a9084d71280dd654af0386140a59737fce970ea3ae1774a970d2

Contents?: true

Size: 933 Bytes

Versions: 2

Compression:

Stored size: 933 Bytes

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.action do |global_options, options, args|
    language = 'all'
    tempfile = Tempfile.new(language)
    zipfile_name = tempfile.path
    resources_dir = options[:resources_dir]

    base_path = File.join(Dir.pwd, resources_dir)
    begin
      export_translations!(@crowdin)

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

      base_path = File.join(Dir.pwd, resources_dir)
      unzip_file_with_translations(zipfile_name, base_path)
    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.2 lib/fci/commands/03_download.rb
fci-0.0.1 lib/fci/commands/03_download.rb