Sha256: 140a96dba3f7f0f23327b61ad406ee53ee986c9cea5ac563ca0ce134f14b26ad

Contents?: true

Size: 652 Bytes

Versions: 10

Compression:

Stored size: 652 Bytes

Contents

module Globalize2
  module SiteControllerExtensions
    def self.included(base)
      base.send(:include, InstanceMethods)
      base.class_eval do
        alias_method_chain :find_page, :globalize
        before_filter :set_locale
      end
    end


    module InstanceMethods
      def set_locale
        @locale = params[:locale] || Globalize2Extension.default_language
        Globalize2Extension.content_locale = I18n.locale = @locale.to_sym
      end
    end
    
    def find_page_with_globalize(url)
      url = '/' + I18n.locale.to_s + '/' + url if Globalize2Extension.locales.size > 1
      find_page_without_globalize(url)
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
radiant-globalize2-extension-0.3.0 lib/globalize2/site_controller_extensions.rb
radiant-globalize2-extension-0.2.8 lib/globalize2/site_controller_extensions.rb
radiant-globalize2-extension-0.2.7 lib/globalize2/site_controller_extensions.rb
radiant-globalize2-extension-0.2.6 lib/globalize2/site_controller_extensions.rb
radiant-globalize2-extension-0.2.5 lib/globalize2/site_controller_extensions.rb
radiant-globalize2-extension-0.2.4 lib/globalize2/site_controller_extensions.rb
radiant-globalize2-extension-0.2.3 lib/globalize2/site_controller_extensions.rb
radiant-globalize2-extension-0.2.2 lib/globalize2/site_controller_extensions.rb
radiant-globalize2-extension-0.2.1 lib/globalize2/site_controller_extensions.rb
radiant-globalize2-extension-0.2.0 lib/globalize2/site_controller_extensions.rb