From: Giuseppe Bilotta Date: Tue, 20 Jul 2010 08:21:56 +0000 (+0200) Subject: geoip: massage a few messages X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=41d45296886b4814744fc2d1422838d643399a61;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git geoip: massage a few messages Solve a few gettext issue, and re-introduce the commas around the region. --- diff --git a/data/rbot/plugins/geoip.rb b/data/rbot/plugins/geoip.rb index 3b7bf751..99ed71eb 100755 --- a/data/rbot/plugins/geoip.rb +++ b/data/rbot/plugins/geoip.rb @@ -183,32 +183,30 @@ class GeoIpPlugin < Plugin } rescue GeoIP::InvalidHostError, RuntimeError if nick - return _("#{nick}'s location could not be resolved") + return _("%{nick}'s location could not be resolved") % { :nick => nick } else - return _("#{host} could not be resolved") + return _("%{host} could not be resolved") % { :host => host } end rescue GeoIP::BadAPIError return _("The owner configured me to use an API that doesn't exist, bug them!") end - res = _("%{thing} is #{nick ? "from" : "located in"}") % { - :thing => (nick ? nick : Resolv::getaddress(host)), - :country => geo[:country] - } - - res << " %{city}" % { - :city => geo[:city] - } unless geo[:city].to_s.empty? + location = [] + location << geo[:city] unless geo[:city].nil_or_empty? + location << geo[:region] unless geo[:region].nil_or_empty? or geo[:region] == geo[:city] + location << geo[:country] unless geo[:country].nil_or_empty? - res << " %{region}," % { - :region => geo[:region] - } unless geo[:region].to_s.empty? || geo[:region] == geo[:city] + if nick + res = _("%{nick} is from %{location}") + else + res = _("%{host} is located in %{location}") + end - res << " %{country}" % { - :country => geo[:country] + return res % { + :nick => nick, + :host => host, + :location => location.join(', ') } - - return res end end