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

Commit e4d934f

Browse files
committed
available_locales option in translated_inputs form builder function
1 parent ec73a8b commit e4d934f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/active_admin/globalize/form_builder_extension.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ module FormBuilderExtension
55

66
def translated_inputs(name = "Translations", options = {}, &block)
77
options.symbolize_keys!
8+
available_locales = options.fetch(:available_locales, I18n.available_locales.sort)
89
switch_locale = options.fetch(:switch_locale, false)
910
auto_sort = options.fetch(:auto_sort, true)
1011
template.content_tag(:div, class: "activeadmin-translations") do
1112
template.content_tag(:ul, class: "available-locales") do
12-
(auto_sort ? I18n.available_locales.sort : I18n.available_locales).map do |locale|
13+
(auto_sort ? available_locales.sort : available_locales).map do |locale|
1314
default = 'default' if locale == I18n.default_locale
1415
template.content_tag(:li) do
1516
I18n.with_locale(switch_locale ? locale : I18n.locale) do
@@ -18,7 +19,7 @@ def translated_inputs(name = "Translations", options = {}, &block)
1819
end
1920
end.join.html_safe
2021
end <<
21-
(auto_sort ? I18n.available_locales.sort : I18n.available_locales).map do |locale|
22+
(auto_sort ? available_locales.sort : available_locales).map do |locale|
2223
translation = object.translations.find { |t| t.locale.to_s == locale.to_s }
2324
translation ||= object.translations.build(locale: locale)
2425
fields = proc do |form|
@@ -42,4 +43,3 @@ module ClassMethods
4243
end
4344
end
4445
end
45-

0 commit comments

Comments
 (0)