From a08215633c7e084c14fee6c2505e754853c94d3f Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Sat, 4 Jul 2009 21:35:09 +0000 Subject: [PATCH] When two users are <1 km apart display the distance between them in meters, not kilometers. Solves ticket:2028 --- app/views/user/view.html.erb | 20 ++++++++++++++++++-- config/locales/en.yml | 1 + config/locales/is.yml | 1 + 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/views/user/view.html.erb b/app/views/user/view.html.erb index 5fdea140f..1b582c0b9 100644 --- a/app/views/user/view.html.erb +++ b/app/views/user/view.html.erb @@ -71,7 +71,16 @@ <% end %> <%= link_to h(@friend.display_name), :controller => 'user', :action => 'view', :display_name => @friend.display_name %> - <% if @friend.home_lon and @friend.home_lat %><%= t 'user.view.km away', :count => @this_user.distance(@friend).round %><% end %> + + <% if @friend.home_lon and @friend.home_lat %> + <% distance = @this_user.distance(@friend) %> + <% if distance < 1 %> + <%= t 'user.view.m away', :count => (distance * 1000).round %> + <% else %> + <%= t 'user.view.km away', :count => distance.round %> + <% end %> + <% end %> + (<%= link_to t('user.view.send message'), :controller => 'message', :action => 'new', :user_id => @friend.id %>) <%end%> @@ -93,7 +102,14 @@ <% @this_user.nearby.each do |nearby| %> <%= link_to h(nearby.display_name), :controller => 'user', :action => 'view', :display_name => nearby.display_name %> - <%= t 'user.view.km away', :count => @this_user.distance(nearby).round %> + + <% distance = @this_user.distance(nearby) %> + <% if distance < 1 %> + <%= t 'user.view.m away', :count => (distance * 1000).round %> + <% else %> + <%= t 'user.view.km away', :count => distance.round %> + <% end %> + (<%= link_to t('user.view.send message'), :controller => 'message', :action => 'new', :user_id => nearby.id %>) <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index dee97ab91..c1a0d17f5 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -833,6 +833,7 @@ en: your friends: Your friends no friends: You have not added any friends yet. km away: "{{count}}km away" + m away: "{{count}}m away" nearby users: "Nearby users: " no nearby users: "There are no users who admit to mapping nearby yet." change your settings: change your settings diff --git a/config/locales/is.yml b/config/locales/is.yml index 350bca815..3860c5b01 100644 --- a/config/locales/is.yml +++ b/config/locales/is.yml @@ -827,6 +827,7 @@ is: your friends: Vinir þínir no friends: Þú átt enga vini km away: "í {{count}} km fjarlægð" + m away: "í {{count}} m fjarlægð" nearby users: "Nálægir notendur:" no nearby users: "Engir notendur hafa stillt staðsetningu sína nálægt þér." change your settings: "breyttu stillingunum þínum" -- 2.43.2