Sha256: 898ff51e2b181ae9afc6a6d19384e76cd080c61bace1db378e96b7404163b5ff

Contents?: true

Size: 892 Bytes

Versions: 2

Compression:

Stored size: 892 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.10.0 lib/loaf/translation.rb
loaf-0.9.0 lib/loaf/translation.rb