Sha256: 99eae2291f79b86dd0a9c29042c7bcb9925a2118f0343d2e5449da2fa53de9f6

Contents?: true

Size: 1.14 KB

Versions: 20

Compression:

Stored size: 1.14 KB

Contents

require "action_view/helpers/asset_tag_helper"

# encoding: utf-8
module FlagHelper
  
  def magic_locaoles_admin_template(options = {}, &block)
    options.merge!(:body => capture(&block))
    render(:partial => "magic_locales/admin_template", :locals => options)
  end
  
  def flag( lcl = I18n.locale.to_s )
    # raw( image_tag( "flags/flags_#{lcl}.png", class: "flag" ) )
    locale_flag( lcl, "small" )
  end
  
  def locale_flag( lcl = I18n.locale.to_s, format = "small" )
    format = "medium" unless %w(small medium large).include?(format)
    lcl = "xx" unless %w(en bg cs da de el es fi fr hr hu it nl pl pt ru sv uk).include?( lcl.to_s.downcase )
    raw( image_tag( "flags/locales/#{format}/flag-#{lcl.to_s.downcase}.png", class: "flag" ) )
  end
  
  def country_flag( lcl = I18n.locale.to_s, format = "small" )
    format = "medium" unless %w(small medium large).include?(format)
    lcl = "xx" unless %w(at by be ba bg ca hr cy cz dk fi fr de gr hu ie it lv li lt lu nl no pl pt ro ru rs sk si es se ch ua gb us).include?( lcl.to_s.downcase )
    raw( image_tag( "flags/countries/#{format}/flag-#{lcl.to_s.downcase}.png", class: "flag" ) )
  end
  
  
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
magic_locales-0.0.21 lib/magic_locales/flag_helper.rb
magic_locales-0.0.20 lib/magic_locales/flag_helper.rb
magic_locales-0.0.19 lib/magic_locales/flag_helper.rb
magic_locales-0.0.18 lib/magic_locales/flag_helper.rb
magic_locales-0.0.17 lib/magic_locales/flag_helper.rb
magic_locales-0.0.17.beta2 lib/magic_locales/flag_helper.rb
magic_locales-0.0.17.beta1 lib/magic_locales/flag_helper.rb
magic_locales-0.0.16 lib/magic_locales/flag_helper.rb
magic_locales-0.0.15 lib/magic_locales/flag_helper.rb
magic_locales-0.0.14 lib/magic_locales/flag_helper.rb
magic_locales-0.0.13 lib/magic_locales/flag_helper.rb
magic_locales-0.0.12 lib/magic_locales/flag_helper.rb
magic_locales-0.0.11 lib/magic_locales/flag_helper.rb
magic_locales-0.0.10 lib/magic_locales/flag_helper.rb
magic_locales-0.0.9 lib/magic_locales/flag_helper.rb
magic_locales-0.0.8 lib/magic_locales/flag_helper.rb
magic_locales-0.0.7 lib/magic_locales/flag_helper.rb
magic_locales-0.0.6 lib/magic_locales/flag_helper.rb
magic_locales-0.0.5 lib/magic_locales/flag_helper.rb
magic_locales-0.0.4 lib/magic_locales/flag_helper.rb