Class: Linguist::Command::Translations

Inherits:
Base
  • Object
show all
Defined in:
lib/linguist_ruby/commands/translations.rb

Instance Attribute Summary

Attributes inherited from Base

#args, #autodetected_app

Instance Method Summary collapse

Methods inherited from Base

#app_urls, #escape, #extract_app_from_git_config, #extract_option, #extract_project_title_from_args, #extract_project_title_from_dir_name, #extract_project_title_from_git, #git_remotes, #git_url, #initialize, #linguist, #project, #project_title

Methods included from Helpers

#ask, #confirm, #confirm_command, #deprecate, #display, #error, #format_date, #git, #has_git?, #home_directory, #redisplay, #retry_on_exception, #run_command, #running_on_a_mac?, #running_on_windows?, #shell

Constructor Details

This class inherits a constructor from Linguist::Command::Base

Instance Method Details

#downObject

Raises:



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/linguist_ruby/commands/translations.rb', line 3

def down
  project #project validation

  directory = File.join(Dir.pwd, extract_directory_from_args || "")
  raise(CommandFailed, "Error downloading translations. Path #{directory} does not exist") unless File.directory?(directory)

  files_source = extract_all_from_args ? project.resources.keys : args
  files_source.each do |file_name|
    begin
      project.pull_resource(directory, file_name)
      display("#{file_name} downloaded")
    rescue
      display "Error downloading #{file_name}. Response: #{$!.message}"
    end
  end
end

#upObject



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/linguist_ruby/commands/translations.rb', line 20

def up
  project #project validation

  args.each do |file_name|
    begin
      path = File.expand_path(file_name, Dir.pwd)
      project.push_resource(path, extract_locale_from_args)
      display("#{file_name} uploaded")
    rescue
      display "Error uploading #{file_name}. Response: #{$!.response || $!.message}"
    end
  end
end