summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaine Virta <rane@kapsi.fi>2009-03-02 03:34:54 +0200
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2009-03-03 20:52:11 +0100
commite7123500b4fb7bb59b9e26072af95624062e85f1 (patch)
treec2c1d26448ef4dbfd709b7d4b605a9f8998a667c
parent5003770d20adf80446581024e861450c93e1585f (diff)
lastfm: make replies more compatible with gettext
_() returns frozen strings in 1.92.0. This patch not only addresses that, but also makes some of the replies more flexible.
-rw-r--r--data/rbot/plugins/lastfm.rb40
1 files changed, 21 insertions, 19 deletions
diff --git a/data/rbot/plugins/lastfm.rb b/data/rbot/plugins/lastfm.rb
index c2883248..58f0c249 100644
--- a/data/rbot/plugins/lastfm.rb
+++ b/data/rbot/plugins/lastfm.rb
@@ -269,18 +269,20 @@ class LastFmPlugin < Plugin
rating = _("Very Low")
end
- reply = _("%{a}'s and %{b}'s musical compatibility rating is %{bold}%{r}%{bold}") % {
+ common_artists = unless artists.empty?
+ _(" and music they have in common includes: %{artists}") % {
+ :artists => artists.join(", ") }
+ else
+ nil
+ end
+
+ m.reply _("%{a}'s and %{b}'s musical compatibility rating is %{bold}%{r}%{bold}%{common}") % {
:a => user1,
:b => user2,
:r => rating.downcase,
- :bold => Bold
+ :bold => Bold,
+ :common => common_artists
}
-
- reply << _(" and music they have in common includes: %{artists}") % {
- :artists => artists.join(", ")
- } unless artists.empty?
-
- m.reply reply
end
def now_playing(m, params)
@@ -583,14 +585,14 @@ class LastFmPlugin < Plugin
elsif friends.length <= num
reply = _("%{user} has %{total} friends: %{friends}")
else
- reply = _("%{user} has %{total} friends, including %{friends}")
- reply << seemore
+ reply = _("%{user} has %{total} friends, including %{friends}%{seemore}")
end
m.reply reply % {
:user => user,
:total => friends.size,
:friends => friends.shuffle[0, num].join(", "),
- :uri => "http://www.last.fm/user/#{CGI.escape user}/friends"
+ :uri => "http://www.last.fm/user/#{CGI.escape user}/friends",
+ :seemore => seemore
}
when :lovedtracks
loved = doc.root.get_elements("lovedtracks/track").map do |track|
@@ -603,14 +605,14 @@ class LastFmPlugin < Plugin
elsif loved.length <= num
reply = _("%{user} has loved %{total} tracks: %{tracks}")
else
- reply = _("%{user} has loved %{total} tracks, including %{tracks}")
- reply << seemore
+ reply = _("%{user} has loved %{total} tracks, including %{tracks}%{seemore}")
end
m.reply reply % {
:user => user,
:total => loved.size,
:tracks => loved_prep.join(", "),
- :uri => "http://www.last.fm/user/#{CGI.escape user}/library/loved"
+ :uri => "http://www.last.fm/user/#{CGI.escape user}/library/loved",
+ :seemore => seemore
}
when :neighbours
nbrs = doc.root.get_elements("neighbours/user").map do |u|
@@ -622,13 +624,13 @@ class LastFmPlugin < Plugin
elsif nbrs.length <= num
reply = _("%{user}'s musical neighbours are %{nbrs}")
else
- reply = _("%{user}'s musical neighbours include %{nbrs}")
- reply << seemore
+ reply = _("%{user}'s musical neighbours include %{nbrs}%{seemore}")
end
m.reply reply % {
- :user => user,
- :nbrs => nbrs.shuffle[0, num].join(", "),
- :uri => "http://www.last.fm/user/#{CGI.escape user}/neighbours"
+ :user => user,
+ :nbrs => nbrs.shuffle[0, num].join(", "),
+ :uri => "http://www.last.fm/user/#{CGI.escape user}/neighbours",
+ :seemore => seemore
}
when :recenttracks
tracks = doc.root.get_elements("recenttracks/track").map do |track|