Skip to content

Commit

Permalink
Use grouped_options_for_select to display already translated and not-…
Browse files Browse the repository at this point in the history
…yet-translated locales
  • Loading branch information
benhutton committed Nov 15, 2014
1 parent 88e20cc commit 4478b98
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/views/rails_admin/main/globalize.html.haml
Expand Up @@ -21,7 +21,7 @@
%p= raw I18n.translate("admin.actions.globalize.subtitle", :locale_name => "<strong>#{I18n.locale}</strong>".upcase)

= rails_admin_form_for @object, :url => rails_admin.globalize_path(@abstract_model, @object.id), :as => @abstract_model.param_key, :html => {:multipart => true, :class => 'globalize-form'} do |form|
= select_tag 'target_locale', options_for_select( @available_locales, @target_locale ), :id => "target_locale_select", :"data-target-url" => rails_admin.globalize_path(@object.class.to_s.split("::").map(&:underscore).join("~"), @object.id)
= select_tag 'target_locale', grouped_options_for_select([["Already Translated", @already_translated_locales], ["Not-Yet-Translated", @not_yet_translated_locales]], @target_locale), :id => "target_locale_select", :"data-target-url" => rails_admin.globalize_path(@object.class.to_s.split("::").map(&:underscore).join("~"), @object.id)
- rails_admin_fields.keys.each do |t|
%h5 #{@object.class.human_attribute_name(t.to_sym)}:
.row-fluid
Expand Down
3 changes: 3 additions & 0 deletions lib/rails_admin_globalize.rb
Expand Up @@ -40,6 +40,9 @@ class Globalize < Base
Proc.new do
@available_locales = (I18n.available_locales - [I18n.locale])
@available_locales = @object.available_locales if @object.respond_to?("available_locales")
@already_translated_locales = []
@already_translated_locales = @object.translated_locales.map(&:to_s) if @object.respond_to?("translated_locales")
@not_yet_translated_locales = @available_locales - @already_translated_locales

if request.get?
@target_locale = params[:target_locale] || @available_locales.first || I18n.locale
Expand Down

0 comments on commit 4478b98

Please sign in to comment.