i18n url based breadcrumbs in Rails
in application_helper.rb
# Generate URL-based Breadcrumbs.
# Based on http://rubysnips.com/url-based-breadcrumbs
# Modified and adapted for i18n by Claudio Poli (http://www.icoretech.org)
def show_breadcrumbs(wrapper = "p", separator = " » ")
r = []
r << link_to(I18n.t(:home), "/")
url = request.path.split('?')
segments = url[0].split('/')
segments.shift
segments.each_with_index do |segment, i|
title = segment.gsub(/-/, ' ').titleize
title = I18n.t(title.downcase.to_sym, :default => title)
r << link_to_unless_current(title, "/" + (0..(i)).collect{ |seg| segments[seg] }.join("/"))
end
content_tag(wrapper, "#{I18n.t(:path)}: " + r.join(separator), :class => "breadcrumbs")
end
Trackbacks
Use the following link to trackback from your own site:
http://www.icoretech.org/trackbacks?article_id=i18n-url-based-breadcrumbs-in-rails&day=13&month=09&year=2008
-
Acomplia. Acomplia mexico.