Class: Interpret::ToolsController

Inherits:
BaseController show all
Defined in:
app/controllers/interpret/tools_controller.rb

Instance Method Summary collapse

Instance Method Details

#dumpObject



4
5
6
7
8
9
10
# File 'app/controllers/interpret/tools_controller.rb', line 4

def dump
  Interpret::Translation.dump

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

#exportObject



12
13
14
15
16
17
18
19
20
# File 'app/controllers/interpret/tools_controller.rb', line 12

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

#importObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/interpret/tools_controller.rb', line 28

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

#run_updateObject



22
23
24
25
26
# File 'app/controllers/interpret/tools_controller.rb', line 22

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