crowdin-cli 0.0.15 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/bin/crowdin-cli CHANGED
@@ -56,7 +56,7 @@ def export_pattern_to_path(path, export_pattern, lang, languages_mapping = nil)
56
56
  pattern = {
57
57
  '%language%' => lang['name'],
58
58
  '%two_letters_code%' => lang['iso_639_1'],
59
- '%tree_letters_code%' => lang['iso_639_3'],
59
+ '%three_letters_code%' => lang['iso_639_3'],
60
60
  '%locale%' => lang['locale'],
61
61
  '%locale_with_underscore%' => lang['locale'].gsub('-', '_'),
62
62
  '%android_code%' => android_locale_code(lang['locale']),
@@ -92,7 +92,7 @@ def get_invalid_placeholders(export_pattern)
92
92
  valid_placeholders = [
93
93
  '%language%',
94
94
  '%two_letters_code%',
95
- '%tree_letters_code%',
95
+ '%three_letters_code%',
96
96
  '%locale%',
97
97
  '%locale_with_underscore%',
98
98
  '%android_code%',
@@ -124,15 +124,27 @@ def unzip_file(zip, dest, files_list)
124
124
  # overwrite files if they already exist inside of the extracted path
125
125
  Zip.options[:on_exists_proc] = true
126
126
 
127
+ unmatched_files = []
128
+
127
129
  Zip::ZipFile.open(zip) do |zip_file|
128
- zip_file.select{|f| f.file?}.each do |f|
130
+ zip_file.select{ |f| f.file? }.each do |f|
129
131
  file = files_list[f.name]
130
- f_path = File.join(dest, file)
131
- FileUtils.mkdir_p(File.dirname(f_path))
132
- puts "Download: #{file}"
133
- zip_file.extract(f, f_path)
132
+ if file
133
+ f_path = File.join(dest, file)
134
+ FileUtils.mkdir_p(File.dirname(f_path))
135
+ puts "Download: #{file}"
136
+ zip_file.extract(f, f_path)
137
+ else
138
+ unmatched_files << f
139
+ end
134
140
  end
135
141
  end
142
+
143
+ unless unmatched_files.empty?
144
+ puts "Warning: Downloaded translations does not match current project configuration. Some of the resulted files will be omitted."
145
+ unmatched_files.each{ |file| puts " - `#{file}'" }
146
+ puts "Crowdin has internal caching mechanisms that prevents us from overload. Please try to download translations later."
147
+ end
136
148
  end
137
149
 
138
150
  ###
@@ -408,7 +420,7 @@ command :download do |c|
408
420
  dest = file['source'].sub("#{@base_path}", '')
409
421
 
410
422
  translation_languages.each do |lang|
411
- zipper_file = export_pattern_to_path(dest, file['translation'], lang)
423
+ zipped_file = export_pattern_to_path(dest, file['translation'], lang)
412
424
  local_file = export_pattern_to_path(dest, file['translation'], lang, languages_mapping)
413
425
 
414
426
  downloadable_files[zipped_file] = local_file
@@ -435,9 +447,10 @@ command :download do |c|
435
447
 
436
448
  ##
437
449
  file = Tempfile.new(language)
450
+ path = file.path
438
451
  begin
439
- @crowdin.download_translation(language, :output => file)
440
- unzip_file(file, @base_path, downloadable_files)
452
+ @crowdin.download_translation(language, :output => path)
453
+ unzip_file(path, @base_path, downloadable_files)
441
454
  ensure
442
455
  file.close
443
456
  file.unlink # delete the temp file
@@ -476,7 +489,7 @@ EOS
476
489
 
477
490
  else
478
491
  exit_now! <<EOS
479
- Can't find configuration file (default `crowdin.yml').
492
+ Can't find configuration file (default `crowdin.yaml').
480
493
  Type `crowdin-cli help` to know how to specify custom configuration file
481
494
 
482
495
  See http://crowdin.net/page/cli-client#configuration-file for more details
@@ -1,5 +1,5 @@
1
1
  module Crowdin
2
2
  module CLI
3
- VERSION = '0.0.15'
3
+ VERSION = '0.0.16'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crowdin-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-27 00:00:00.000000000 Z
12
+ date: 2012-10-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake