Sha256: 5a1982185d192fa7c7a76a3cf168e252c4bb66a6ea8e37f65be15d240ba70c1a

Contents?: true

Size: 1.21 KB

Versions: 6

Compression:

Stored size: 1.21 KB

Contents

class Interpret::ToolsController < Interpret::BaseController
  before_filter { authorize! :use, :tools }

  def dump
    Interpret::Translation.dump

    session.delete(:tree)
    Interpret.backend.reload! if Interpret.backend
    redirect_to tools_url, :notice => "Dump done."
  end

  def export
    require 'ya2yaml'

    translations = Interpret::Translation.locale(I18n.locale).all
    hash = Interpret::Translation.export(translations)
    text = hash.ya2yaml

    send_data text[5..text.length], :filename => "#{I18n.locale}.yml", :type => "text/plain", :disposition => "attachment"
  end

  def run_update
    Interpret::Translation.update
    Interpret.backend.reload! if Interpret.backend
    redirect_to tools_url, :notice => "Update done"
  end

  def import
    unless params.has_key? :file
      redirect_to tools_url, :alert => "You have to select a file to import."
      return
    end

    begin
      Interpret::Translation.import(params[:file])
    rescue Exception => e
      redirect_to tools_url, :alert => "Error when importing: #{e.message}"
      return
    end

    session.delete(:tree)
    Interpret.backend.reload! if Interpret.backend

    redirect_to tools_url, :notice => "Import successfully done."
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
interpret-1.1.2 app/controllers/interpret/tools_controller.rb
interpret-1.1.1 app/controllers/interpret/tools_controller.rb
interpret-1.1.0 app/controllers/interpret/tools_controller.rb
interpret-1.0.2 app/controllers/interpret/tools_controller.rb
interpret-1.0.1 app/controllers/interpret/tools_controller.rb
interpret-1.0.0 app/controllers/interpret/tools_controller.rb