Skip to content

Commit 0a29aab

Browse files
committed
Merge branch 'master' of git://github.com/stefanoverna/activeadmin-globalize3
Conflicts: lib/active_admin/globalize3/form_builder_extension.rb
2 parents 7ca667e + 09edd0b commit 0a29aab

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,10 @@ If `switch_locale` is set, each tab will be rendered switching locale.
3838

3939
If you want to use Friendly ID together with Globalize3, please take a look
4040
at the `activeadmin-seo` gem.
41+
42+
## Hints
43+
44+
To use the dashed locale keys as 'pt-BR' or 'pt-PT' you need to convert a string to symbol (in application.rb)
45+
46+
config.i18n.available_locales = [:en, :it, :de, :es, :"pt-BR"]
47+

lib/active_admin/globalize3/form_builder_extension.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,18 @@ module FormBuilderExtension
66
def translated_inputs(name = "Translations", options = {}, &block)
77
options.symbolize_keys!
88
switch_locale = options.fetch(:switch_locale, false)
9+
auto_sort = options.fetch(:auto_sort, true)
910
form_buffers.last << template.content_tag(:div, class: "activeadmin-translations") do
1011
template.content_tag(:ul, class: "available-locales") do
11-
I18n.available_locales.sort.map do |locale|
12+
(auto_sort ? I18n.available_locales.sort : I18n.available_locales).map do |locale|
1213
template.content_tag(:li) do
1314
I18n.with_locale(switch_locale ? locale : I18n.locale) do
1415
template.content_tag(:a, I18n.t(:"active_admin.globalize3.language.#{locale}"), href:".locale-#{locale}")
1516
end
1617
end
1718
end.join.html_safe
1819
end <<
19-
I18n.available_locales.sort.map do |locale|
20+
(auto_sort ? I18n.available_locales.sort : I18n.available_locales).map do |locale|
2021
translation = object.translations.find { |t| t.locale.to_s == locale.to_s }
2122
translation ||= object.translations.build(locale: locale)
2223
fields = proc do |form|

0 commit comments

Comments
 (0)