Module: SortingTableFor::I18n
- Defined in:
- lib/sorting_table_for/i18n.rb
Class Method Summary collapse
-
.set_options(params, model_name, i18n_active = true) ⇒ Object
Set options to create a default scope.
-
.translate(attribute, options = {}, type = nil) ⇒ Object
(also: t)
Add a default scope if option scope isn’t defined.
Class Method Details
.set_options(params, model_name, i18n_active = true) ⇒ Object
Set options to create a default scope
8 9 10 11 12 13 14 15 16 |
# File 'lib/sorting_table_for/i18n.rb', line 8 def (params, model_name, i18n_active = true) @model_name, @i18n_active = model_name, i18n_active @action = (params.has_key? :action) ? params[:action].downcase : '' @controller = (params.has_key? :controller) ? params[:controller].downcase : '' if @controller.include? '/' @namespace = @controller.split '/' @controller = @namespace.pop end end |
.translate(attribute, options = {}, type = nil) ⇒ Object Also known as: t
Add a default scope if option scope isn’t defined
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/sorting_table_for/i18n.rb', line 19 def translate(attribute, = {}, type = nil) unless @i18n_active return [:value] if .has_key? :value return attribute end unless .has_key? :scope [:scope] = create_scope [:scope] << TableBuilder.i18n_add_header_action_scope if type and type == :header [:scope] << TableBuilder. if type and type == :footer [:scope] << .delete(:add_scope) [:scope].flatten! end ::I18n.t(attribute, ) end |