Sha256: ee81c654fdc1f11f7acc4012cd7a49a5c34613154bfeec89656906f4b825580c

Contents?: true

Size: 588 Bytes

Versions: 31

Compression:

Stored size: 588 Bytes

Contents

module WorldFlags
  module Helper
    module Browser
      def self.browser_locale request
        return @browser_locale if @browser_locale
        if lang = request.env["HTTP_ACCEPT_LANGUAGE"]
          lang = lang.split(",").map { |l|
            l += ';q=1.0' unless l =~ /;q=\d+\.\d+$/
            l.split(';q=')
          }.first
          @browser_locale = lang.first.split("-").first
        else
          @browser_locale = I18n.default_locale
        end
      end

      def browser_locale
        WorldFlags::Helper::Browser.browser_locale(request)
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
world-flags-0.6.6 lib/world_flags/helper/browser.rb
world-flags-0.6.5 lib/world_flags/helper/browser.rb
world-flags-0.6.4 lib/world_flags/helper/browser.rb
world-flags-0.6.3.1 lib/world_flags/helper/browser.rb
world-flags-0.6.3 lib/world_flags/helper/browser.rb
world-flags-0.6.2.1 lib/world_flags/helper/browser.rb
world-flags-0.6.2 lib/world_flags/helper/browser.rb
world-flags-0.6.1.1 lib/world_flags/helper/browser.rb
world-flags-0.6.1 lib/world_flags/helper/browser.rb
world-flags-0.6.0 lib/world_flags/helper/browser.rb
world-flags-0.5.1 lib/world_flags/helper/browser.rb
world-flags-0.5.0 lib/world_flags/helper/browser.rb
world-flags-0.4.9 lib/world_flags/helper/browser.rb
world-flags-0.4.8.3 lib/world_flags/helper/browser.rb
world-flags-0.4.8.2 lib/world_flags/helper/browser.rb
world-flags-0.4.7 lib/world_flags/helper/browser.rb
world-flags-0.4.5 lib/world_flags/helper/browser.rb
world-flags-0.4.4 lib/world_flags/helper/browser.rb
world-flags-0.4.3 lib/world_flags/helper/browser.rb
world-flags-0.4.2 lib/world_flags/helper/browser.rb