Sha256: aaf037cec825cbaff516c37e7861af6c4395fe1cd9c426e3cf82aa3c4861a080
Contents?: true
Size: 902 Bytes
Versions: 3
Compression:
Stored size: 902 Bytes
Contents
require "httparty" module WorldFlags module Geo def self.ip_json HTTParty.get('http://freegeoip.net/json/') end def self.ip_country_code @ip_country_code ||= ip_json.parsed_response['country_code'] end def ip_country_code WorldFlags::Geo.ip_country_code end end module Browser def self.browser_locale 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::Browser.browser_locale end end module All def self.included(base) base.send :include, Geo base.send :include, Browser end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
world-flags-0.1.5 | lib/world_flags/locale_helper.rb |
world-flags-0.1.4 | lib/world_flags/locale_helper.rb |
world-flags-0.1.3 | lib/world_flags/locale_helper.rb |