2 def printable_name(object, version = false)
3 id = if object.id.is_a?(Array)
8 name = t "printable_name.with_id", :id => id.to_s
9 name = t "printable_name.with_version", :id => name, :version => object.version.to_s if version
11 # don't look at object tags if redacted, so as to avoid giving
12 # away redacted version tag information.
13 unless object.redacted?
14 available_locales = Locale::List.new(name_locales(object))
16 Rails.logger.info "available_locales = #{available_locales.map(&:to_s)}"
18 preferred_locales = if current_user
19 current_user.preferred_languages
21 Locale.new(I18n.locale).candidates
24 Rails.logger.info "preferred_locales = #{preferred_locales.expand.map(&:to_s)}"
26 locale = available_locales.preferred(preferred_locales)
28 Rails.logger.info "locale = #{locale}"
30 if object.tags.include? "name:#{locale}"
31 name = t "printable_name.with_name_html", :name => content_tag(:bdi, object.tags["name:#{locale}"].to_s), :id => content_tag(:bdi, name)
32 elsif object.tags.include? "name"
33 name = t "printable_name.with_name_html", :name => content_tag(:bdi, object.tags["name"].to_s), :id => content_tag(:bdi, name)
34 elsif object.tags.include? "ref"
35 name = t "printable_name.with_name_html", :name => content_tag(:bdi, object.tags["ref"].to_s), :id => content_tag(:bdi, name)
42 def link_class(type, object)
48 classes += icon_tags(object).flatten.map { |t| h(t) }
49 classes << "deleted" unless object.visible?
55 def link_title(object)
59 h(icon_tags(object).map { |k, v| k + "=" + v }.to_sentence)
63 def link_follow(object)
64 "nofollow" if object.tags.empty?
67 def type_and_paginated_count(type, pages)
68 if pages.page_count == 1
69 t "browse.changeset.#{type}",
70 :count => pages.item_count
72 t "browse.changeset.#{type}_paginated",
73 :x => pages.current_page.first_item,
74 :y => pages.current_page.last_item,
75 :count => pages.item_count
81 ICON_TAGS = %w[aeroway amenity barrier building highway historic landuse leisure man_made natural railway shop tourism waterway].freeze
84 object.tags.find_all { |k, _v| ICON_TAGS.include? k }.sort
87 def name_locales(object)
88 object.tags.keys.map { |k| Regexp.last_match(1) if k =~ /^name:(.*)$/ }.flatten