@@ -5,20 +5,21 @@ module FormBuilderExtension
5
5
6
6
def translated_inputs ( name = "Translations" , options = { } , &block )
7
7
options . symbolize_keys!
8
+ available_locales = options . fetch ( :available_locales , I18n . available_locales )
8
9
switch_locale = options . fetch ( :switch_locale , false )
9
- auto_sort = options . fetch ( :auto_sort , true )
10
+ default_locale = options . fetch ( :default_locale , I18n . default_locale )
10
11
template . content_tag ( :div , class : "activeadmin-translations" ) do
11
12
template . content_tag ( :ul , class : "available-locales" ) do
12
- ( auto_sort ? I18n . available_locales . sort : I18n . available_locales ) . map do |locale |
13
- default = 'default' if locale == I18n . default_locale
13
+ available_locales . map do |locale |
14
+ default = 'default' if locale == default_locale
14
15
template . content_tag ( :li ) do
15
16
I18n . with_locale ( switch_locale ? locale : I18n . locale ) do
16
17
template . content_tag ( :a , I18n . t ( :"active_admin.globalize.language.#{ locale } " ) , href :".locale-#{ locale } " , :class => default )
17
18
end
18
19
end
19
20
end . join . html_safe
20
21
end <<
21
- ( auto_sort ? I18n . available_locales . sort : I18n . available_locales ) . map do |locale |
22
+ available_locales . map do |locale |
22
23
translation = object . translations . find { |t | t . locale . to_s == locale . to_s }
23
24
translation ||= object . translations . build ( locale : locale )
24
25
fields = proc do |form |
@@ -42,4 +43,3 @@ module ClassMethods
42
43
end
43
44
end
44
45
end
45
-
0 commit comments