Trivia: internationalize
parent
14f4d2d97b
commit
dda0f36804
|
@ -31,7 +31,8 @@
|
|||
|
||||
import supybot.conf as conf
|
||||
import supybot.registry as registry
|
||||
|
||||
from supybot.i18n import PluginInternationalization, internationalizeDocstring
|
||||
_ = PluginInternationalization('Admin')
|
||||
def configure(advanced):
|
||||
# This will be called by supybot to configure this module. advanced is
|
||||
# a bool that specifies whether the user identified himself as an advanced
|
||||
|
@ -47,47 +48,47 @@ Trivia = conf.registerPlugin('Trivia')
|
|||
# registry.Boolean(False, """Help for someConfigVariableName."""))
|
||||
|
||||
conf.registerChannelValue(Trivia, 'blankChar',
|
||||
registry.String('*', """The character used for a blank when
|
||||
displaying hints"""))
|
||||
registry.String('*', _("""The character used for a blank when
|
||||
displaying hints""")))
|
||||
|
||||
conf.registerChannelValue(Trivia, 'numHints',
|
||||
registry.PositiveInteger(3, """The number of hints to be given for
|
||||
each question"""))
|
||||
registry.PositiveInteger(3, _("""The number of hints to be given for
|
||||
each question""")))
|
||||
|
||||
conf.registerChannelValue(Trivia, 'timeout',
|
||||
registry.PositiveInteger(90, """The number of seconds to allow for
|
||||
each question"""))
|
||||
registry.PositiveInteger(90, _("""The number of seconds to allow for
|
||||
each question""")))
|
||||
|
||||
conf.registerChannelValue(Trivia, 'hintPercentage',
|
||||
registry.Probability(0.25, """The fraction of the answer that
|
||||
should be revealed with each hint"""))
|
||||
registry.Probability(0.25, _("""The fraction of the answer that
|
||||
should be revealed with each hint""")))
|
||||
|
||||
conf.registerChannelValue(Trivia, 'flexibility',
|
||||
registry.PositiveInteger(8, """The flexibility of the trivia answer
|
||||
checker. One typo will be allowed for every __ characters."""))
|
||||
registry.PositiveInteger(8, _("""The flexibility of the trivia answer
|
||||
checker. One typo will be allowed for every __ characters.""")))
|
||||
|
||||
conf.registerChannelValue(Trivia, 'color',
|
||||
registry.PositiveInteger(10, """The mIRC color to use for trivia
|
||||
questions"""))
|
||||
registry.PositiveInteger(10, _("""The mIRC color to use for trivia
|
||||
questions""")))
|
||||
|
||||
conf.registerChannelValue(Trivia, 'inactiveShutoff',
|
||||
registry.Integer(6, """The number of questions that can go
|
||||
unanswered before the trivia stops automatically."""))
|
||||
registry.Integer(6, _("""The number of questions that can go
|
||||
unanswered before the trivia stops automatically.""")))
|
||||
|
||||
conf.registerGlobalValue(Trivia, 'scoreFile',
|
||||
registry.String('scores.txt', """The path to the scores file.
|
||||
If it doesn't exist, it will be created."""))
|
||||
registry.String('scores.txt', _("""The path to the scores file.
|
||||
If it doesn't exist, it will be created.""")))
|
||||
|
||||
conf.registerGlobalValue(Trivia, 'questionFile',
|
||||
registry.String('questions.txt', """The path to the questions file.
|
||||
If it doesn't exist, it will be created."""))
|
||||
registry.String('questions.txt', _("""The path to the questions file.
|
||||
If it doesn't exist, it will be created.""")))
|
||||
|
||||
conf.registerChannelValue(Trivia, 'defaultRoundLength',
|
||||
registry.PositiveInteger(10, """The default number of questions to
|
||||
be asked in a round of trivia."""))
|
||||
registry.PositiveInteger(10, _("""The default number of questions to
|
||||
be asked in a round of trivia.""")))
|
||||
|
||||
conf.registerGlobalValue(Trivia, 'questionFileSeparator',
|
||||
registry.String('*', """The separator used between the questions
|
||||
and answers in your trivia file."""))
|
||||
registry.String('*', _("""The separator used between the questions
|
||||
and answers in your trivia file.""")))
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
||||
|
|
|
@ -0,0 +1,160 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR ORGANIZATION
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2011-11-01 19:21+CET\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=CHARSET\n"
|
||||
"Content-Transfer-Encoding: ENCODING\n"
|
||||
"Generated-By: pygettext.py 1.5\n"
|
||||
|
||||
|
||||
#: config.py:51
|
||||
msgid ""
|
||||
"The character used for a blank when\n"
|
||||
" displaying hints"
|
||||
msgstr ""
|
||||
|
||||
#: config.py:55
|
||||
msgid ""
|
||||
"The number of hints to be given for\n"
|
||||
" each question"
|
||||
msgstr ""
|
||||
|
||||
#: config.py:59
|
||||
msgid ""
|
||||
"The number of seconds to allow for\n"
|
||||
" each question"
|
||||
msgstr ""
|
||||
|
||||
#: config.py:63
|
||||
msgid ""
|
||||
"The fraction of the answer that\n"
|
||||
" should be revealed with each hint"
|
||||
msgstr ""
|
||||
|
||||
#: config.py:67
|
||||
msgid ""
|
||||
"The flexibility of the trivia answer\n"
|
||||
" checker. One typo will be allowed for every __ characters."
|
||||
msgstr ""
|
||||
|
||||
#: config.py:71
|
||||
msgid ""
|
||||
"The mIRC color to use for trivia\n"
|
||||
" questions"
|
||||
msgstr ""
|
||||
|
||||
#: config.py:75
|
||||
msgid ""
|
||||
"The number of questions that can go\n"
|
||||
" unanswered before the trivia stops automatically."
|
||||
msgstr ""
|
||||
|
||||
#: config.py:79
|
||||
msgid ""
|
||||
"The path to the scores file.\n"
|
||||
" If it doesn't exist, it will be created."
|
||||
msgstr ""
|
||||
|
||||
#: config.py:83
|
||||
msgid ""
|
||||
"The path to the questions file.\n"
|
||||
" If it doesn't exist, it will be created."
|
||||
msgstr ""
|
||||
|
||||
#: config.py:87
|
||||
msgid ""
|
||||
"The default number of questions to\n"
|
||||
" be asked in a round of trivia."
|
||||
msgstr ""
|
||||
|
||||
#: config.py:91
|
||||
msgid ""
|
||||
"The separator used between the questions\n"
|
||||
" and answers in your trivia file."
|
||||
msgstr ""
|
||||
|
||||
#: plugin.py:50
|
||||
#, docstring
|
||||
msgid ""
|
||||
"Add the help for \"@plugin help Trivia\" here\n"
|
||||
" This should describe *how* to use this plugin."
|
||||
msgstr ""
|
||||
|
||||
#: plugin.py:130
|
||||
msgid "Seems like no one's playing any more."
|
||||
msgstr ""
|
||||
|
||||
#: plugin.py:133
|
||||
msgid "Oops! I ran out of questions!"
|
||||
msgstr ""
|
||||
|
||||
#: plugin.py:147
|
||||
msgid "\003%s#%d of %d: %s"
|
||||
msgstr ""
|
||||
|
||||
#: plugin.py:159
|
||||
msgid "Trivia stopping."
|
||||
msgstr ""
|
||||
|
||||
#: plugin.py:177
|
||||
msgid "Top finishers: "
|
||||
msgstr ""
|
||||
|
||||
#: plugin.py:183
|
||||
msgid "%s %s %s."
|
||||
msgstr ""
|
||||
|
||||
#: plugin.py:190
|
||||
msgid "No one got the answer! It was: %s"
|
||||
msgstr ""
|
||||
|
||||
#: plugin.py:208
|
||||
msgid "HINT: %s%s"
|
||||
msgstr ""
|
||||
|
||||
#: plugin.py:235
|
||||
msgid "%s got it! The full answer was: %s. Points: %d"
|
||||
msgstr ""
|
||||
|
||||
#: plugin.py:276
|
||||
#, docstring
|
||||
msgid ""
|
||||
"[<channel>] [<number of questions>]\n"
|
||||
"\n"
|
||||
" Starts a game of trivia. <channel> is only necessary if the message\n"
|
||||
" isn't sent in the channel itself."
|
||||
msgstr ""
|
||||
|
||||
#: plugin.py:294
|
||||
msgid "Orphaned trivia game found and removed."
|
||||
msgstr ""
|
||||
|
||||
#: plugin.py:298
|
||||
msgid "%d questions added to active game!"
|
||||
msgstr ""
|
||||
|
||||
#: plugin.py:306
|
||||
#, docstring
|
||||
msgid ""
|
||||
"[<channel>]\n"
|
||||
"\n"
|
||||
" Stops a running game of trivia. <channel> is only necessary if the\n"
|
||||
" message isn't sent in the channel itself."
|
||||
msgstr ""
|
||||
|
||||
#: plugin.py:314
|
||||
msgid "No trivia started"
|
||||
msgstr ""
|
||||
|
||||
#: plugin.py:320
|
||||
msgid "Trivia stopped"
|
||||
msgstr ""
|
||||
|
|
@ -43,7 +43,8 @@ import supybot.ircmsgs as ircmsgs
|
|||
import supybot.ircutils as ircutils
|
||||
import supybot.schedule as schedule
|
||||
import supybot.callbacks as callbacks
|
||||
|
||||
from supybot.i18n import PluginInternationalization, internationalizeDocstring
|
||||
_ = PluginInternationalization('Trivia')
|
||||
|
||||
class Trivia(callbacks.Plugin):
|
||||
"""Add the help for "@plugin help Trivia" here
|
||||
|
@ -126,10 +127,10 @@ class Trivia(callbacks.Plugin):
|
|||
if self.num == 0:
|
||||
self.active = False
|
||||
elif self.unanswered > inactiveShutoff and inactiveShutoff >= 0:
|
||||
self.reply('Seems like no one\'s playing any more.')
|
||||
self.reply(_('Seems like no one\'s playing any more.'))
|
||||
self.active = False
|
||||
elif len(self.questions) == 0:
|
||||
self.reply('Oops! I ran out of questions!')
|
||||
self.reply(_('Oops! I ran out of questions!'))
|
||||
self.active = False
|
||||
if not self.active:
|
||||
self.stop()
|
||||
|
@ -143,7 +144,7 @@ class Trivia(callbacks.Plugin):
|
|||
self.q = q[:q.find(sep)]
|
||||
self.a = q[q.find(sep)+len(sep):].split(sep)
|
||||
color = self.registryValue('color', self.channel)
|
||||
self.reply('\x03%s#%d of %d: %s' % (color, self.numAsked,
|
||||
self.reply(_('\x03%s#%d of %d: %s') % (color, self.numAsked,
|
||||
self.total, self.q))
|
||||
def event():
|
||||
self.timedEvent()
|
||||
|
@ -155,7 +156,7 @@ class Trivia(callbacks.Plugin):
|
|||
|
||||
|
||||
def stop(self):
|
||||
self.reply('Trivia stopping.')
|
||||
self.reply(_('Trivia stopping.'))
|
||||
self.active = False
|
||||
try:
|
||||
schedule.removeEvent('next_%s' % self.channel)
|
||||
|
@ -173,20 +174,20 @@ class Trivia(callbacks.Plugin):
|
|||
if len(sorted) < max:
|
||||
max = len(sorted)
|
||||
#self.reply('max: %d. len: %d' % (max, len(sorted)))
|
||||
s = 'Top finishers: '
|
||||
s = _('Top finishers: ')
|
||||
if max > 0:
|
||||
recipients = []
|
||||
maxp = sorted[0][1]
|
||||
for i in range(0, max):
|
||||
item = sorted[i]
|
||||
s = '%s %s %s.' % (s, item[0], item[1])
|
||||
s = _('%s %s %s.') % (s, item[0], item[1])
|
||||
self.reply(s)
|
||||
del self.games[self.channel]
|
||||
|
||||
|
||||
def timedEvent(self):
|
||||
if self.hints >= self.registryValue('numHints', self.channel):
|
||||
self.reply('No one got the answer! It was: %s' % self.a[0])
|
||||
self.reply(_('No one got the answer! It was: %s') % self.a[0])
|
||||
self.unanswered += 1
|
||||
self.newquestion()
|
||||
else:
|
||||
|
@ -204,7 +205,7 @@ class Trivia(callbacks.Plugin):
|
|||
blank = ans[divider : ]
|
||||
blankChar = self.registryValue('blankChar', self.channel)
|
||||
blank = re.sub('\w', blankChar, blank)
|
||||
self.reply('HINT: %s%s' % (show, blank))
|
||||
self.reply(_('HINT: %s%s') % (show, blank))
|
||||
def event():
|
||||
self.timedEvent()
|
||||
timeout = self.registryValue('timeout', self.channel)
|
||||
|
@ -231,7 +232,7 @@ class Trivia(callbacks.Plugin):
|
|||
self.roundscores[msg.nick] = 0
|
||||
self.roundscores[msg.nick] += 1
|
||||
self.unanswered = 0
|
||||
self.reply('%s got it! The full answer was: %s. Points: %d' %
|
||||
self.reply(_('%s got it! The full answer was: %s. Points: %d') %
|
||||
(msg.nick, self.a[0], self.scores[msg.nick]))
|
||||
schedule.removeEvent('next_%s' % self.channel)
|
||||
self.writeScores()
|
||||
|
@ -270,7 +271,7 @@ class Trivia(callbacks.Plugin):
|
|||
thisrow[y] = min(thisrow[y], twoago[y - 2] + 1)
|
||||
return thisrow[len(seq2) - 1]
|
||||
|
||||
|
||||
@internationalizeDocstring
|
||||
def start(self, irc, msg, args, channel, num):
|
||||
"""[<channel>] [<number of questions>]
|
||||
|
||||
|
@ -290,17 +291,17 @@ class Trivia(callbacks.Plugin):
|
|||
schedule.removeEvent('next_%s' % channel)
|
||||
except KeyError:
|
||||
pass
|
||||
irc.reply('Orphaned trivia game found and removed.')
|
||||
irc.reply(_('Orphaned trivia game found and removed.'))
|
||||
else:
|
||||
self.games[channel].num += num
|
||||
self.games[channel].total += num
|
||||
irc.reply('%d questions added to active game!' % num)
|
||||
irc.reply(_('%d questions added to active game!') % num)
|
||||
else:
|
||||
self.games[channel] = self.Game(irc, channel, num, self)
|
||||
irc.noReply()
|
||||
start = wrap(start, ['channel', optional('positiveInt')])
|
||||
|
||||
|
||||
@internationalizeDocstring
|
||||
def stop(self, irc, msg, args, channel):
|
||||
"""[<channel>]
|
||||
|
||||
|
@ -310,13 +311,13 @@ class Trivia(callbacks.Plugin):
|
|||
try:
|
||||
schedule.removeEvent('next_%s' % channel)
|
||||
except KeyError:
|
||||
irc.error('No trivia started')
|
||||
irc.error(_('No trivia started'))
|
||||
if channel in self.games:
|
||||
if self.games[channel].active:
|
||||
self.games[channel].stop()
|
||||
else:
|
||||
del self.games[channel]
|
||||
irc.reply('Trivia stopped')
|
||||
irc.reply(_('Trivia stopped'))
|
||||
else:
|
||||
irc.noReply()
|
||||
stop = wrap(stop, ['channel'])
|
||||
|
|
Loading…
Reference in New Issue