class TranslationIO::Client::BaseOperation::SaveNewYamlFilesStep
Public Class Methods
new(target_locales, yaml_locales_path, parsed_response)
click to toggle source
# File lib/translation_io/client/base_operation/save_new_yaml_files_step.rb, line 5 def initialize(target_locales, yaml_locales_path, parsed_response) @target_locales = target_locales @yaml_locales_path = yaml_locales_path @parsed_response = parsed_response end
Public Instance Methods
run()
click to toggle source
# File lib/translation_io/client/base_operation/save_new_yaml_files_step.rb, line 11 def run TranslationIO.info "Saving new translation YAML files." @target_locales.each do |target_locale| if @parsed_response.has_key?("yaml_po_data_#{target_locale}") FileUtils.mkdir_p(@yaml_locales_path) yaml_path = File.join(@yaml_locales_path, "translation.#{target_locale}.yml") TranslationIO.info yaml_path, 2, 2 yaml_data = YAMLConversion.get_yaml_data_from_po_data(@parsed_response["yaml_po_data_#{target_locale}"], target_locale) top_comment = <<-EOS # WARNING. THIS FILE WAS AUTO-GENERATED BY THE TRANSLATION GEM. # IF YOU UPDATE IT, YOUR CHANGES WILL BE LOST AT THE NEXT SYNC. # # To update this file, use this translation interface: # #{@parsed_response['project_url']}/#{target_locale} # EOS File.open(yaml_path, 'wb') do |file| file.write(top_comment) file.write(yaml_data) end end end end