bin/crowdin-cli in crowdin-cli-0.0.15 vs bin/crowdin-cli in crowdin-cli-0.0.16

- old
+ new

@@ -54,11 +54,11 @@ file_name = File.basename(path, File.extname(path)) pattern = { '%language%' => lang['name'], '%two_letters_code%' => lang['iso_639_1'], - '%tree_letters_code%' => lang['iso_639_3'], + '%three_letters_code%' => lang['iso_639_3'], '%locale%' => lang['locale'], '%locale_with_underscore%' => lang['locale'].gsub('-', '_'), '%android_code%' => android_locale_code(lang['locale']), '%original_file_name%' => original_file_name, '%original_path%' => original_path, @@ -90,11 +90,11 @@ def get_invalid_placeholders(export_pattern) valid_placeholders = [ '%language%', '%two_letters_code%', - '%tree_letters_code%', + '%three_letters_code%', '%locale%', '%locale_with_underscore%', '%android_code%', '%original_file_name%', '%original_path%', @@ -122,19 +122,31 @@ def unzip_file(zip, dest, files_list) # overwrite files if they already exist inside of the extracted path Zip.options[:on_exists_proc] = true + unmatched_files = [] + Zip::ZipFile.open(zip) do |zip_file| - zip_file.select{|f| f.file?}.each do |f| + zip_file.select{ |f| f.file? }.each do |f| file = files_list[f.name] - f_path = File.join(dest, file) - FileUtils.mkdir_p(File.dirname(f_path)) - puts "Download: #{file}" - zip_file.extract(f, f_path) + if file + f_path = File.join(dest, file) + FileUtils.mkdir_p(File.dirname(f_path)) + puts "Download: #{file}" + zip_file.extract(f, f_path) + else + unmatched_files << f + end end end + + unless unmatched_files.empty? + puts "Warning: Downloaded translations does not match current project configuration. Some of the resulted files will be omitted." + unmatched_files.each{ |file| puts " - `#{file}'" } + puts "Crowdin has internal caching mechanisms that prevents us from overload. Please try to download translations later." + end end ### include GLI::App @@ -406,11 +418,11 @@ if File.exists?("#{@base_path}#{file['source']}") dest = file['source'].sub("#{@base_path}", '') translation_languages.each do |lang| - zipper_file = export_pattern_to_path(dest, file['translation'], lang) + zipped_file = export_pattern_to_path(dest, file['translation'], lang) local_file = export_pattern_to_path(dest, file['translation'], lang, languages_mapping) downloadable_files[zipped_file] = local_file end else @@ -433,13 +445,14 @@ end # if end # @config['files'] ## file = Tempfile.new(language) + path = file.path begin - @crowdin.download_translation(language, :output => file) - unzip_file(file, @base_path, downloadable_files) + @crowdin.download_translation(language, :output => path) + unzip_file(path, @base_path, downloadable_files) ensure file.close file.unlink # delete the temp file end end @@ -474,10 +487,10 @@ EOS end else exit_now! <<EOS -Can't find configuration file (default `crowdin.yml'). +Can't find configuration file (default `crowdin.yaml'). Type `crowdin-cli help` to know how to specify custom configuration file See http://crowdin.net/page/cli-client#configuration-file for more details EOS end