Sha256: a312d9b212a3c4ada973449b28cd103da06bfeca073db7c97e9d98b7049823c0

Contents?: true

Size: 959 Bytes

Versions: 1

Compression:

Stored size: 959 Bytes

Contents

class GlobalizeTranslationsController < ApplicationController

  before_filter :globalize_translations_authenticator, :except => [:index]

  # get :index as JSON should not require authentication
  before_filter(:only => :index) do |controller|
    globalize_translations_authenticator unless controller.request.format.json?
  end

  layout false

  respond_to :html, :json

  def index
    # returns {"default_locale":"en","pl":{"hello.world":"Witaj \u015bwiecie","hello.earth":"Witaj ziemio"},"en":{"hello.world":"Hello world","hello.earth":"Hello Earth"}}
    @translations = I18n.backend.available_translations.merge({ :default_locale => I18n.default_locale })
    respond_with @translations
  end

  private

  def globalize_translations_authenticator
    if I18n::Backend::GlobalizeStore.authenticator && I18n::Backend::GlobalizeStore.authenticator.respond_to?(:call)
      I18n::Backend::GlobalizeStore.authenticator.bind(self).call
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
exvo_globalize-0.0.2 app/controllers/globalize_translations_controller.rb