]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
hangman: make replies more compatible with gettext
authorRaine Virta <rane@kapsi.fi>
Mon, 2 Mar 2009 02:01:38 +0000 (04:01 +0200)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Tue, 3 Mar 2009 19:52:11 +0000 (20:52 +0100)
_() returns frozen strings in 1.92.0. This patch not only addresses
that, but also makes some of the replies more flexible.

data/rbot/plugins/games/hangman.rb

index d571fd782d4fc204a10feceb0aff7a32b74c8625..dbabb72c6fbb98520c5c4a6a552ae81d17b2756a 100644 (file)
@@ -365,16 +365,17 @@ class HangmanPlugin < Plugin
       end
 
       if game.over?
-        str = if game.won?
+        sentence = if game.won?
           _("you nailed it!")
         elsif game.lost?
           _("you've killed the poor guy :(")
         end
 
-        str << _(" go #{Bold}again#{Bold}?")
+        again = _("go #{Bold}again#{Bold}?")
 
+        scores = []
         game.scores.each do |user, score|
-          str << " #{user.nick}: "
+          str = "#{user.nick}: "
           str << if score > 0
             Irc.color(:green)+'+'
           elsif score < 0
@@ -383,9 +384,13 @@ class HangmanPlugin < Plugin
 
           str << score.round.to_s
           str << Irc.color
+
+          scores << str
         end
 
-        m.reply str, :nick => true
+        m.reply _("%{sentence} %{again} %{scores}") % {
+          :sentence => sentence, :again => again, :scores => scores
+        }, :nick => true
 
         if rand(5).zero?
           m.reply _("wondering what that means? try ´%{prefix}define´") % {