made geocoder results translatable. It could probably be improved but am not sure how.
This commit is contained in:
parent
85f317b46e
commit
c4965a1700
3 changed files with 48 additions and 14 deletions
|
@ -162,14 +162,14 @@ private
|
||||||
prefix = ""
|
prefix = ""
|
||||||
name = type
|
name = type
|
||||||
else
|
else
|
||||||
prefix = "#{type} "
|
prefix = t "geocoder.results.namefinder.prefix", :type => type
|
||||||
end
|
end
|
||||||
|
|
||||||
if place
|
if place
|
||||||
distance = format_distance(place.attributes["approxdistance"].to_i)
|
distance = format_distance(place.attributes["approxdistance"].to_i)
|
||||||
direction = format_direction(place.attributes["direction"].to_i)
|
direction = format_direction(place.attributes["direction"].to_i)
|
||||||
placename = format_name(place.attributes["name"].to_s)
|
placename = format_name(place.attributes["name"].to_s)
|
||||||
suffix = ", #{distance} #{direction} of #{placename}"
|
suffix = t "geocoder.results.namefinder.suffix_place", :distance => distance, :direction => direction, :placename => placename
|
||||||
|
|
||||||
if place.attributes["rank"].to_i <= 30
|
if place.attributes["rank"].to_i <= 30
|
||||||
parent = nil
|
parent = nil
|
||||||
|
@ -193,11 +193,11 @@ private
|
||||||
parentname = format_name(parent.attributes["name"].to_s)
|
parentname = format_name(parent.attributes["name"].to_s)
|
||||||
|
|
||||||
if place.attributes["info"].to_s == "suburb"
|
if place.attributes["info"].to_s == "suburb"
|
||||||
suffix = "#{suffix}, #{parentname}"
|
suffix = t "geocoder.results.namefinder.suffix_suburb", :suffix => suffix, :parentname => parentname
|
||||||
else
|
else
|
||||||
parentdistance = format_distance(parent.attributes["approxdistance"].to_i)
|
parentdistance = format_distance(parent.attributes["approxdistance"].to_i)
|
||||||
parentdirection = format_direction(parent.attributes["direction"].to_i)
|
parentdirection = format_direction(parent.attributes["direction"].to_i)
|
||||||
suffix = "#{suffix} (#{parentdistance} #{parentdirection} of #{parentname})"
|
suffix = t "geocoder.results.namefinder.suffix_parent", :suffix => suffix, :parentdistance => parentdistance, :parentdirection => parentdirection, :parentname => parentname
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -293,19 +293,19 @@ private
|
||||||
end
|
end
|
||||||
|
|
||||||
def format_distance(distance)
|
def format_distance(distance)
|
||||||
return "less than 1km" if distance == 0
|
return t "geocoder.results.distance.less_than_1km" if distance == 0
|
||||||
return "about #{distance}km"
|
return t "geocoder.results.distance.about_distance_km", :distance => distance
|
||||||
end
|
end
|
||||||
|
|
||||||
def format_direction(bearing)
|
def format_direction(bearing)
|
||||||
return "south-west" if bearing >= 22.5 and bearing < 67.5
|
return t "geocoder.results.direction.south_west" if bearing >= 22.5 and bearing < 67.5
|
||||||
return "south" if bearing >= 67.5 and bearing < 112.5
|
return t "geocoder.results.direction.south" if bearing >= 67.5 and bearing < 112.5
|
||||||
return "south-east" if bearing >= 112.5 and bearing < 157.5
|
return t "geocoder.results.direction.south_east" if bearing >= 112.5 and bearing < 157.5
|
||||||
return "east" if bearing >= 157.5 and bearing < 202.5
|
return t "geocoder.results.direction.east" if bearing >= 157.5 and bearing < 202.5
|
||||||
return "north-east" if bearing >= 202.5 and bearing < 247.5
|
return t "geocoder.results.direction.north_east" if bearing >= 202.5 and bearing < 247.5
|
||||||
return "north" if bearing >= 247.5 and bearing < 292.5
|
return t "geocoder.results.direction.north" if bearing >= 247.5 and bearing < 292.5
|
||||||
return "north-west" if bearing >= 292.5 and bearing < 337.5
|
return t "geocoder.results.direction.north_west" if bearing >= 292.5 and bearing < 337.5
|
||||||
return "west"
|
return t "geocoder.results.direction.west"
|
||||||
end
|
end
|
||||||
|
|
||||||
def format_name(name)
|
def format_name(name)
|
||||||
|
|
|
@ -342,6 +342,23 @@ en:
|
||||||
results: "Results"
|
results: "Results"
|
||||||
type_from_source: "{{type}} from {{source_link}}"
|
type_from_source: "{{type}} from {{source_link}}"
|
||||||
no_results: "No results found"
|
no_results: "No results found"
|
||||||
|
namefinder:
|
||||||
|
prefix: "{{type}} "
|
||||||
|
suffix_place: ", {{distance}} {{direction}} of {{placename}}"
|
||||||
|
suffix_parent: "{{suffix}} ({{parentdistance}} {{parentdirection}} of {{parentname}})"
|
||||||
|
suffix_suburb: "{{suffix}}, {{parentname}}"
|
||||||
|
distance:
|
||||||
|
less_than_1km: "less than 1km"
|
||||||
|
about_distance_km: "about {{distance}}km"
|
||||||
|
direction:
|
||||||
|
south_west: "south-west"
|
||||||
|
south: "south"
|
||||||
|
south_east: "south-east"
|
||||||
|
east: "east"
|
||||||
|
north_east: "north-east"
|
||||||
|
north: "north"
|
||||||
|
north_west: "north-west"
|
||||||
|
west: "west"
|
||||||
layouts:
|
layouts:
|
||||||
project_name:
|
project_name:
|
||||||
# in <title>
|
# in <title>
|
||||||
|
|
|
@ -338,6 +338,23 @@ sl:
|
||||||
results: "Zadetki"
|
results: "Zadetki"
|
||||||
type_from_source: "{{type}} iz {{source_link}}"
|
type_from_source: "{{type}} iz {{source_link}}"
|
||||||
no_results: "Ni zadetkov"
|
no_results: "Ni zadetkov"
|
||||||
|
namefinder:
|
||||||
|
prefix: "{{type}} "
|
||||||
|
suffix_place: ", {{distance}} {{direction}} od {{placename}}"
|
||||||
|
suffix_parent: "{{suffix}} ({{parentdistance}} {{parentdirection}} od {{parentname}})"
|
||||||
|
suffix_suburb: "{{suffix}}, {{parentname}}"
|
||||||
|
distance:
|
||||||
|
less_than_1km: "manj kot 1 km"
|
||||||
|
about_distance_km: "približno {{distance}} km"
|
||||||
|
direction:
|
||||||
|
south_west: "jugozahodno"
|
||||||
|
south: "južno"
|
||||||
|
south_east: "jugovzhodno"
|
||||||
|
east: "vzhodno"
|
||||||
|
north_east: "severovzhodno"
|
||||||
|
north: "severno"
|
||||||
|
north_west: "severozahodno"
|
||||||
|
west: "zahodno"
|
||||||
layouts:
|
layouts:
|
||||||
project_name:
|
project_name:
|
||||||
# in <title>
|
# in <title>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue