Sha256: 83df5e2379af12c7f903e30199907e4b2286a2c143261a3405865bda8a9a7d00

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

class Lolita::I18nController < ApplicationController
  include Lolita::Controllers::UserHelpers
  before_filter :authenticate_lolita_user!, :set_current_locale

  layout "lolita/application"

  def index
    @translation_keys=Lolita::I18n.flatten_keys
  end

  def update
    respond_to do |format|
      format.json do
        render :nothing => true, :json => {error: !Lolita::I18n::Backend.set(params[:id],params[:translation])}
      end
    end
  end

  def translate_untranslated
    respond_to do |format|
      format.json do
        google_translate = Lolita::I18n::GoogleTranslate.new @active_locale
        google_translate.run
        render :nothing => true, :status => 200, :json => {errors: google_translate.errors, :translated => google_translate.untranslated}
      end
    end    
  end

  private

  def next_locale
    ::I18n::available_locales.collect{|locale| locale if locale != ::I18n.default_locale}.compact.first
  end

  def set_current_locale
    @active_locale = (params[:active_locale] || next_locale).to_sym
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lolita-i18n-0.1.4 app/controllers/lolita/i18n_controller.rb