Sha256: 6f0a6b89f985f58f0c3e80259933be3d49de8c476be33c18f68640579d0cdb6a

Contents?: true

Size: 506 Bytes

Versions: 2

Compression:

Stored size: 506 Bytes

Contents

module WorldFlags
  module Helper
    module Locale
      def set_locale    
        I18n.locale = locales.select_first_in(valid_locales.downcase)
      end  

      def valid_locales
        if I18n.respond_to?(:available_locales) && I18n.available_locales.present?
          I18n.available_locales 
        else
          WorldFlags.valid_locales
        end
      end

      def locales
        [params[:locale], browser_locale, ip_country_code, I18n.default_locale].downcase
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
world-flags-0.3.0 lib/world_flags/helper/locale.rb
world-flags-0.2.7 lib/world_flags/helper/locale.rb