Skip to content

Commit 77f1dac

Browse files
authored
Merge pull request #25 from bys-control/master
Add I18n
2 parents 3191e5e + 92611b2 commit 77f1dac

File tree

5 files changed

+35
-10
lines changed

5 files changed

+35
-10
lines changed

config/locales/en.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
en:
2+
active_admin_scoped_collection_actions:
3+
sidebar_msg: 'This batch operations affect selected records. Or if none is selected, it will involve all records by current filters and scopes.'
4+
confirm_action_message: 'Are you sure?'
5+
actions:
6+
delete: 'Delete batch'
7+
update: 'Update batch'
8+
no_permissions_msg: 'Access denied'
9+
batch_update_status_msg: 'Batch update done'
10+
batch_destroy_status_msg: 'Batch destroy done'
11+
fail_on_destroy_msg: 'Cant be destroyed'

config/locales/es.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
es:
2+
active_admin_scoped_collection_actions:
3+
sidebar_msg: 'Estas operaciones afectan las filas seleccionadas o en caso que no halla seleccionado ninguna, afectará a todo los registros afectados por los filtros aplicados.'
4+
confirm_action_message: '¿Está seguro que quiere realizar esta acción?'
5+
actions:
6+
delete: 'Batch Borrado'
7+
update: 'Batch Actualizado'
8+
no_permissions_msg: 'Permiso denegado'
9+
batch_update_status_msg: 'Batch actualizado correctamente'
10+
batch_destroy_status_msg: 'Batch destruido correctamente'
11+
fail_on_destroy_msg: 'No se puede eliminar'

lib/active_admin_scoped_collection_actions/dsl.rb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ module DSL
33

44
def scoped_collection_action(name, options = {}, &block)
55
if name == :scoped_collection_destroy
6-
options[:title] = 'Delete batch' if options[:title].nil?
6+
7+
8+
9+
options[:title] = I18n.t('active_admin_scoped_collection_actions.actions.delete') if options[:title].nil?
710
add_scoped_collection_action_default_destroy(options, &block)
811
elsif name == :scoped_collection_update
9-
options[:title] = 'Update batch' if options[:title].nil?
12+
options[:title] = I18n.t('active_admin_scoped_collection_actions.actions.update') if options[:title].nil?
1013
add_scoped_collection_action_default_update(options, &block)
1114
else
1215
batch_action(name, if: proc { false }, &block)
@@ -19,7 +22,7 @@ def scoped_collection_action(name, options = {}, &block)
1922
def add_scoped_collection_action_default_update(options, &block)
2023
batch_action :scoped_collection_update, if: proc { false } do
2124
unless authorized?(:batch_edit, resource_class)
22-
flash[:error] = 'Access denied'
25+
flash[:error] = I18n.t('active_admin_scoped_collection_actions.actions.no_permissions_msg')
2326
render nothing: true, status: :no_content and next
2427
end
2528
if !params.has_key?(:changes) || params[:changes].empty?
@@ -36,7 +39,7 @@ def add_scoped_collection_action_default_update(options, &block)
3639
end
3740
end
3841
if errors.empty?
39-
flash[:notice] = 'Batch update done'
42+
flash[:notice] = I18n.t('active_admin_scoped_collection_actions.batch_update_status_msg')
4043
else
4144
flash[:error] = errors.join(". ")
4245
end
@@ -49,7 +52,7 @@ def add_scoped_collection_action_default_update(options, &block)
4952
def add_scoped_collection_action_default_destroy(_, &block)
5053
batch_action :scoped_collection_destroy, if: proc { false } do |_|
5154
unless authorized?(:batch_destroy, resource_class)
52-
flash[:error] = 'Access denied'
55+
flash[:error] = I18n.t('active_admin_scoped_collection_actions.actions.no_permissions_msg')
5356
render nothing: true, status: :no_content and next
5457
end
5558
if block_given?
@@ -58,11 +61,11 @@ def add_scoped_collection_action_default_destroy(_, &block)
5861
errors = []
5962
scoped_collection_records.find_each do |record|
6063
unless destroy_resource(record)
61-
errors << "#{record.attributes[resource_class.primary_key]} | Cant be destroyed}"
64+
errors << "#{record.attributes[resource_class.primary_key]} | #{I18n.t('active_admin_scoped_collection_actions.fail_on_destroy_msg')}}"
6265
end
6366
end
6467
if errors.empty?
65-
flash[:notice] = 'Batch destroy done'
68+
flash[:notice] = I18n.t('active_admin_scoped_collection_actions.batch_destroy_status_msg')
6669
else
6770
flash[:error] = errors.join(". ")
6871
end

lib/active_admin_scoped_collection_actions/resource_extension.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def scoped_collection_sidebar_condition
5151
def scoped_collection_actions_sidebar_section
5252
ActiveAdmin::SidebarSection.new :collection_actions, only: :index, if: scoped_collection_sidebar_condition do
5353

54-
div 'This batch operations affect selected records. Or if none is selected, it will involve all records by current filters and scopes.'
54+
div I18n.t('active_admin_scoped_collection_actions.sidebar_msg')
5555

5656
active_admin_config.scoped_collection_actions.each do |key, options={}|
5757
b_title = options.fetch(:title, ::ActiveSupport::Inflector.humanize(key))
@@ -64,7 +64,7 @@ def scoped_collection_actions_sidebar_section
6464
if options[:form].present?
6565
b_data[:inputs] = options[:form].is_a?(Proc) ? options[:form].call : options[:form]
6666
end
67-
b_data[:confirm] = options.fetch(:confirm, 'Are you sure?')
67+
b_data[:confirm] = options.fetch(:confirm, I18n.t('active_admin_scoped_collection_actions.confirm_action_message'))
6868
b_options[:data] = b_data.to_json
6969
button b_title, b_options
7070
end
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module ActiveAdminScopedCollectionActions
2-
VERSION = "0.3.0"
2+
VERSION = "0.3.2"
33
end

0 commit comments

Comments
 (0)