Sha256: 22235d9b92d584a44748466d0ac7403c80bf4d7894ce3f0661401b7ba795c97a

Contents?: true

Size: 422 Bytes

Versions: 29

Compression:

Stored size: 422 Bytes

Contents

class Object
  def as_(key, options = {})
    if key.present?
      scope = [:active_scaffold, *options.delete(:scope)]
      options = options.reverse_merge(:scope => scope, :default => key.is_a?(String) ? key : key.to_s.titleize)
      text = I18n.translate(key.to_s, **options).html_safe # rubocop:disable Rails/OutputSafety
      # text = nil if text.include?('translation missing:')
    end
    text || key
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
active_scaffold-3.7.11 lib/active_scaffold/extensions/localize.rb
active_scaffold-3.7.10 lib/active_scaffold/extensions/localize.rb
active_scaffold-3.7.8 lib/active_scaffold/extensions/localize.rb
active_scaffold-3.7.7 lib/active_scaffold/extensions/localize.rb
active_scaffold-3.7.6 lib/active_scaffold/extensions/localize.rb
active_scaffold-3.7.5 lib/active_scaffold/extensions/localize.rb
active_scaffold-3.7.2 lib/active_scaffold/extensions/localize.rb
active_scaffold-3.7.1 lib/active_scaffold/extensions/localize.rb
active_scaffold-3.7.0 lib/active_scaffold/extensions/localize.rb
active_scaffold-3.6.20 lib/active_scaffold/extensions/localize.rb
active_scaffold-3.6.19 lib/active_scaffold/extensions/localize.rb
active_scaffold-3.6.17 lib/active_scaffold/extensions/localize.rb
active_scaffold-3.6.15 lib/active_scaffold/extensions/localize.rb
active_scaffold-3.6.14 lib/active_scaffold/extensions/localize.rb
active_scaffold-3.6.13 lib/active_scaffold/extensions/localize.rb
active_scaffold-3.6.12 lib/active_scaffold/extensions/localize.rb
active_scaffold-3.6.11.1 lib/active_scaffold/extensions/localize.rb
active_scaffold-3.6.11 lib/active_scaffold/extensions/localize.rb
active_scaffold-3.6.10 lib/active_scaffold/extensions/localize.rb
active_scaffold-3.6.9 lib/active_scaffold/extensions/localize.rb