Module: FlagHelper

Defined in:
lib/magic_locales/flag_helper.rb

Overview

encoding: utf-8

Instance Method Summary collapse

Instance Method Details

#country_flag(lcl = I18n.locale.to_s, format = "small") ⇒ Object



22
23
24
25
26
# File 'lib/magic_locales/flag_helper.rb', line 22

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

#flag(lcl = I18n.locale.to_s) ⇒ Object



11
12
13
14
# File 'lib/magic_locales/flag_helper.rb', line 11

def flag( lcl = I18n.locale.to_s )
  # raw( image_tag( "flags/flags_#{lcl}.png", class: "flag" ) )
  locale_flag( lcl, "small" )
end

#locale_flag(lcl = I18n.locale.to_s, format = "small") ⇒ Object



16
17
18
19
20
# File 'lib/magic_locales/flag_helper.rb', line 16

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

#magic_locaoles_admin_template(options = {}, &block) ⇒ Object



6
7
8
9
# File 'lib/magic_locales/flag_helper.rb', line 6

def magic_locaoles_admin_template(options = {}, &block)
  options.merge!(:body => capture(&block))
  render(:partial => "magic_locales/admin_template", :locals => options)
end