Sha256: fe0598a131f0ba79b1d41c6efe29636ba475bdea22cb7f318fedbf7418f52297

Contents?: true

Size: 901 Bytes

Versions: 2

Compression:

Stored size: 901 Bytes

Contents

class Lolita::I18nController < ApplicationController
  include Lolita::ControllerAdditions
  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
        error = false
        begin
          Lolita::I18n::Backend.set(params[:id],params[:translation])
        rescue Lolita::I18n::Exceptions::MissingInterpolationArgument => e
          error = e.to_s
        end
        render :nothing => true, :json => {error: error}
      end
    end
  end

  private
  
  def is_lolita_resource?
    true
  end

  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

2 entries across 2 versions & 1 rubygems

Version Path
lolita-i18n-0.3.2 app/controllers/lolita/i18n_controller.rb
lolita-i18n-0.3.1 app/controllers/lolita/i18n_controller.rb