Module: Loaf::Translation

Defined in:
lib/loaf/translation.rb

Class Method Summary collapse

Class Method Details

.find_title(title, options = {}) ⇒ String

Translate breadcrumb title

Parameters:

  • :title (String)
  • options (Hash) (defaults to: {})

Options Hash (options):

  • :scope (String)

    The translation scope

  • :default (String)

    The default translation

Returns:

  • (String)


27
28
29
30
31
32
33
34
# File 'lib/loaf/translation.rb', line 27

def find_title(title, options = {})
  return title if title.nil? || title.empty?

  options[:scope] ||= translation_scope
  options[:default] = Array(options[:default])
  options[:default] << title if options[:default].empty?
  I18n.t(title.to_s, **options)
end

.translation_scopeString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns translation lookup

Returns:

  • (String)


10
11
12
# File 'lib/loaf/translation.rb', line 10

def translation_scope
  'loaf.breadcrumbs'
end