bin/crowdin-cli in crowdin-cli-0.0.17 vs bin/crowdin-cli in crowdin-cli-0.0.18

- old
+ new

@@ -97,11 +97,11 @@ '%locale_with_underscore%', '%android_code%', '%original_file_name%', '%original_path%', '%file_extension%', - '%file_name%' + '%file_name%', ] all_placeholders = export_pattern.scan(/%[a-z0-9_]*?%/) invalid_placeholders = all_placeholders - valid_placeholders end @@ -214,14 +214,14 @@ export_pattern = file['translation'].sub('**', diff) local_files << { dest: dest, source: source, export_pattern: export_pattern } end - end - end + end # if + end # @config['files'] - if local_files.empty? + if dest_files.empty? exit_now!("Warning: nothing to upload. See http://crowdin.net/page/cli-client#configuration-file for more details.") end common_dir = find_common_directory_path(dest_files) @@ -292,10 +292,15 @@ c.desc 'Automatically approve uploaded translations' c.switch ['auto-approve-imported'] c.action do |global_options, options, args| + params = {} + params[:import_duplicates] = options['import-dublicates'] ? 1 : 0 + params[:import_eq_suggestions] = options['import-eq-suggestions'] ? 1 : 0 + params[:auto_approve_imported] = options['auto-approve-imported'] ? 1 : 0 + language = options[:language] project_info = @crowdin.project_info remote_project_tree = get_remote_files_hierarchy(project_info['files']) @@ -351,20 +356,16 @@ if dest_files.empty? exit_now!("Warning: nothing to upload. See http://crowdin.net/page/cli-client#configuration-file for more details.") end - params = {} - params[:import_duplicates] = options['import-dublicates'] ? 1 : 0 - params[:import_eq_suggestions] = options['import-eq-suggestions'] ? 1 : 0 - params[:auto_approve_imported] = options['auto-approve-imported'] ? 1 : 0 - common_dir = find_common_directory_path(dest_files) translated_files.each do |language, files| files.each do |file| file[:dest].sub!(common_dir, '') + if remote_project_tree[:files].include?(file[:dest]) if File.exist?(file[:source]) print "Uploading `#{file[:source].sub(@base_path, '')}'" @crowdin.upload_translation([] << file, language, params) puts "\rUploading `#{file[:source].sub(@base_path, '')}' - OK" @@ -373,10 +374,11 @@ end else # if source file not exist, don't upload translation puts "Warning: Skip `#{file[:source].sub(@base_path, '')}'" end + end end end # action end # command @@ -511,15 +513,22 @@ else @base_path = Dir.pwd + '/' + @config['base_path'] end else @base_path = Dir.pwd + puts <<EOS +Warning: Configuration file misses optional section `base_path`. +Set the working directory - `#{@base_path}` + +EOS end Crowdin::API.log = Logger.new($stderr) if global[:v] @crowdin = Crowdin::API.new(api_key: @config['api_key'], project_id: @config['project_identifier'], base_url: @config['base_url'] || 'http://api.crowdin.net') begin @crowdin.project_info + rescue Crowdin::API::Errors::Error => err + raise err rescue exit_now!("Seems Crowdin server API URL is not valid. Please check the `base_url` parameter in the configuration file.") end #puts "Executing #{command.name}" if global[:v]