Sha256: 59726c78cf7c355e587d090333067e74dd15a490f813a67976e477f941225b7a

Contents?: true

Size: 1.79 KB

Versions: 3

Compression:

Stored size: 1.79 KB

Contents

# Ajax action for Languages Controller
class ExpressTranslate::Ajax::LanguagesController < ActionController::Base
  
  # Include and require Libraries  
  require 'redis'
  require 'json'
  require 'csv'
  include ExpressTranslate
  
  # Add language
  # Load html content when add Language
  def language_add
    load_content_language(params, Language.add(params))
  end
  
  # Update language
  # Load html content when update Language
  def language_update
    load_content_language(params, Language.update_by_id_packages(params[:old_id], params[:packages], params))
  end
  
  # Delete language
  # Load html content when delete Language
  def language_delete
    load_content_language(params, Language.delete_by_id_packages(params[:id], params[:packages]))
  end
  
  # Set origin language
  # Load html content when set origin Language for package
  def language_set_origin
    load_content_language(params, Language.set_origin(params[:id], params[:packages]))
  end
  
  private
  
  # Load language html content
  # The firstly: check status for action add, update, delete and set origin language
  # get origin language for know max count => percent complete
  # get max number language origin
  # render to html content
  def load_content_language(params, check)
    if check['success'] == true
      @selects = YAML.load_file("#{ExpressTranslate.root}/config/languages.yml")
      @origin = Language.get_origin(params[:packages])
      @origin_keys = @origin.present? ? LanguageDetail.info(@origin).all.collect{|x| x['code']} : []
      @languages = Package.find(params[:packages])['language']
      @max = @origin.nil? ? 1 : LanguageDetail.info(@origin).all.count
      @LanguageDetail = LanguageDetail
      @Package = Package
      render :action => :language_update
      return
    end
    render :json => check
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
express_translate-1.0.13 app/controllers/express_translate/ajax/languages_controller.rb
express_translate-1.0.12 app/controllers/express_translate/ajax/languages_controller.rb
express_translate-1.0.11 app/controllers/express_translate/ajax/languages_controller.rb