Sha256: b00458dc4f5f76507e69eaef8cae0b57ccdc46cbe366fce6db6ff7b24f14c7f4

Contents?: true

Size: 1.59 KB

Versions: 12

Compression:

Stored size: 1.59 KB

Contents

require_dependency "translation_center/application_controller"

module TranslationCenter
  class CenterController < ApplicationController

    before_filter :can_admin?, only: [ :dashboard, :search_activity, :manage ]

    # set language user translating from
    def set_language_from
      session[:lang_from] = params[:lang].to_sym
      I18n.locale = session[:lang_from]
      render nothing: true
    end

    # set language user translating to
    def set_language_to
      session[:lang_to] = params[:lang].to_sym
      
      respond_to do |format|
        format.html { redirect_to root_url } 
        format.js { render nothing: true }
      end
    end

    def dashboard
      @stats = TranslationKey.langs_stats
      @langs = @stats.keys
      # to be used for meta search
      @search = Audited::Adapters::ActiveRecord::Audit.search(params[:search])
      #TODO perpage constant should be put somewhere else
      @translations_changes = Translation.recent_changes.paginate(:page => params[:page], :per_page => 5)
      
      respond_to do |format|
        format.html
        format.js { render 'search_activity' }
      end
    end

    def search_activity
      @translations_changes = Translation.recent_changes(params[:search]).paginate(:page => params[:page], :per_page => 5)
      
      respond_to do |format|
        format.js
      end
    end

    def manage
      # if locale is all then send no locale
      locale = params[:locale] == 'all' ? nil : params[:locale]
      TranslationCenter.send params[:manage_action], locale

      respond_to do |format|
        format.js
      end
    end

  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
translation_center-1.5.5 app/controllers/translation_center/center_controller.rb
translation_center-1.5.4 app/controllers/translation_center/center_controller.rb
translation_center-1.5.3 app/controllers/translation_center/center_controller.rb
translation_center-1.5.2 app/controllers/translation_center/center_controller.rb
translation_center-1.5.1 app/controllers/translation_center/center_controller.rb
translation_center-1.5.0 app/controllers/translation_center/center_controller.rb
translation_center-1.4.1 app/controllers/translation_center/center_controller.rb
translation_center-1.4.0 app/controllers/translation_center/center_controller.rb
translation_center-1.3.1 app/controllers/translation_center/center_controller.rb
translation_center-1.3.0 app/controllers/translation_center/center_controller.rb
translation_center-1.2.1 app/controllers/translation_center/center_controller.rb
translation_center-1.2.0 app/controllers/translation_center/center_controller.rb