Permalink
Browse files

Merge pull request #601 from vairix-ssierra/master

Added Internationalization support to the breadcrumlinks
  • Loading branch information...
2 parents 5a47ac7 + 0d1f1e1 commit 75090a3980d6c994cc096e712ab3641c64f6bc09 @gregbell gregbell committed Oct 13, 2011
Showing with 25 additions and 21 deletions.
  1. +25 −21 lib/active_admin/view_helpers/breadcrumb_helper.rb
@@ -2,27 +2,31 @@ module ActiveAdmin
module ViewHelpers
module BreadcrumbHelper
- # Returns an array of links to use in a breadcrumb
- def breadcrumb_links(path = nil)
- path ||= request.fullpath
- parts = path.gsub(/^\//, '').split('/')
- parts.pop unless %w{ create update }.include?(params[:action])
- crumbs = []
- parts.each_with_index do |part, index|
- name = ""
- if part =~ /^\d/ && parent = parts[index - 1]
- begin
- parent_class = parent.singularize.camelcase.constantize
- obj = parent_class.find(part.to_i)
- name = obj.display_name if obj.respond_to?(:display_name)
- rescue
- end
- end
- name = part.titlecase if name == ""
- crumbs << link_to(name, "/" + parts[0..index].join('/'))
- end
- crumbs
- end
+ # Returns an array of links to use in a breadcrumb
+ def breadcrumb_links(path = nil)
+ path ||= request.fullpath
+ parts = path.gsub(/^\//, '').split('/')
+ parts.pop unless %w{ create update }.include?(params[:action])
+ crumbs = []
+ parts.each_with_index do |part, index|
+ name = ""
+ if part =~ /^\d/ && parent = parts[index - 1]
+ begin
+ parent_class = parent.singularize.camelcase.constantize
+ obj = parent_class.find(part.to_i)
+ name = obj.display_name if obj.respond_to?(:display_name)
+ rescue
+ end
+ end
+ name = part.titlecase if name == ""
+ begin
+ crumbs << link_to( I18n.translate!("activerecord.models.#{part.singularize}"), "/" + parts[0..index].join('/'))
+ rescue I18n::MissingTranslationData
+ crumbs << link_to( name, "/" + parts[0..index].join('/'))
+ end
+ end
+ crumbs
+ end
end
end

0 comments on commit 75090a3

Please sign in to comment.