lib/loaf/translation.rb in loaf-0.7.0 vs lib/loaf/translation.rb in loaf-0.8.0
- old
+ new
@@ -1,29 +1,37 @@
# frozen_string_literal: true
module Loaf
module Translation
- extend self
-
# Returns translation lookup
+ #
+ # @return [String]
+ #
+ # @api private
def translation_scope
- "loaf.breadcrumbs"
+ '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}", options)
+ I18n.t(title.to_s, options)
end
+ module_function :find_title
end # Translation
end # Loaf