Sha256: ccd51769d2382a485bb30f7fc17e1e76a57e73657b284bd8adbcb89cb7ca5e08

Contents?: true

Size: 890 Bytes

Versions: 2

Compression:

Stored size: 890 Bytes

Contents

# frozen_string_literal: true

module Loaf
  module Translation
    # Returns translation lookup
    #
    # @return [String]
    #
    # @api private
    def translation_scope
      'loaf.breadcrumbs'
    end
    module_function :translation_scope

    # Translate breadcrumb title
    #
    # @param [String] :title
    # @param [Hash] options
    # @option options [String] :scope
    #   The translation scope
    # @option options [String] :default
    #   The default translation
    #
    # @return [String]
    #
    # @api public
    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
    module_function :find_title
  end # Translation
end # Loaf

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
loaf-0.8.1 lib/loaf/translation.rb
loaf-0.8.0 lib/loaf/translation.rb