lib/loaf/translation.rb in loaf-0.1.1 vs lib/loaf/translation.rb in loaf-0.2.0

- old
+ new

@@ -1,15 +1,24 @@ module Loaf module Translation - - def set_title! - namespace = controller.controller_path.gsub("/", ".") - action = controller.action_name - - i18n_options = { + extend self - } + # Returns translation lookup + def i18n_scope + :breadcrumbs + end - I18n.t(title, i18n_options) + # Accepts <tt>:scope</tt> parameter. + def breadcrumb_title(title, options={}) + defaults = [] + parts = title.to_s.split('.', 2) + actions = parts.pop + namespace = parts.pop + + defaults << :"#{self.i18n_scope}.#{title}" + defaults << options.delete(:default) if options[:default] + + options.reverse_merge! :count => 1, :default => defaults + I18n.t(title, options) end - end + end # Translation end # Loaf