Sha256: 55cc59ff5982c2695bb63f1e59f28e2d1d052b2ffbbc3499862f2dbe47a91060

Contents?: true

Size: 978 Bytes

Versions: 3

Compression:

Stored size: 978 Bytes

Contents

class Interpret::ToolsController < Interpret::BaseController

  def dump
    Interpret::Translation.dump

    session.delete(:tree)
    Interpret.backend.reload! if Interpret.backend
    redirect_to interpret_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"
  end

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

    begin
      Interpret::Translation.import(params[:file])
    rescue Exception => e
      redirect_to interpret_tools_url, :alert => e
    end

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
interpret-0.1.3 app/controllers/interpret/tools_controller.rb
interpret-0.1.2 app/controllers/interpret/tools_controller.rb
interpret-0.1.1 app/controllers/interpret/tools_controller.rb