Skip to content
This repository was archived by the owner on Nov 30, 2018. It is now read-only.

Commit ac9b8bf

Browse files
committed
View helper for flag icons
1 parent 952aeb9 commit ac9b8bf

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

lib/active_admin/globalize.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
require 'active_admin/globalize/form_builder_extension'
77
require 'active_admin/globalize/active_record_extension'
88
require 'active_admin/globalize/index_table_for_extension'
9+
require 'active_admin/view_helpers/flag_helper'
910

1011
ActiveRecord::Base.send :extend, ActiveAdmin::Globalize::ActiveRecordExtension
1112

lib/active_admin/globalize/index_table_for_extension.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,9 @@ def translation_status
1212
end
1313
def translation_status_flags
1414
column I18n.t("active_admin.globalize.translations") do |obj|
15-
obj.translated_locales.map do |l|
16-
image_tag '%s.gif' % [ l.to_s ]
17-
end.join(" ").html_safe
15+
obj.translated_locales.map { |l| flag_icon(l) }.join(' ').html_safe
1816
end
1917
end
2018
end
2119
end
2220
end
23-
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
require 'active_admin/view_helpers'
2+
3+
module ActiveAdmin
4+
module ViewHelpers
5+
module FlagHelper
6+
7+
# Return an image tag with background of given locale
8+
def flag_icon(locale)
9+
image_tag('active_admin/transparent.gif', class: "flag flag-#{locale}")
10+
end
11+
12+
end
13+
14+
# Register as ActiveAdmin view helper
15+
include FlagHelper
16+
end
17+
end

0 commit comments

Comments
 (0)