41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/translate_client/cli/main.rb', line 41
def pull
config = ProjectConfig.new(
project_id: options[:project],
locale: options[:locale],
format: options[:format],
file: options[:out]
)
remote_locales = api.remote_locales(project_id: config.project_id)
config.locales.each do |locale|
if remote_locales.exclude?(locale)
raise PresentableError.new("Requested locale \"#{locale}\" is not available in the project, use one of: #{remote_locales.join(", ")}")
end
end
puts "Starting export of locales: #{config.locales.join(", ")}"
export_ids = config.locales.index_with do |locale|
export_id = api.create_export(
project_id: config.project_id,
locale:,
format: config.format
)
puts "Export #{export_id} created for locale #{locale}"
export_id
end
export_ids.each do |locale, export_id|
print "Pulling \"#{locale}\" ..."
tmp_file = Helpers.poll_until do
api.download_export(export_id:)
end
out = config.file(locale:)
File.rename(tmp_file.path, out)
puts "Pulled \"#{locale}\" to #{out}"
end
end
|