Internationalize Admin

This commit is contained in:
Valentin Lorentz 2010-10-16 09:50:23 +02:00
parent 70af49feb3
commit 949d13cdc9
3 changed files with 224 additions and 22 deletions

View File

@ -30,6 +30,8 @@
import supybot.conf as conf import supybot.conf as conf
import supybot.registry as registry import supybot.registry as registry
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('Admin')
def configure(advanced): def configure(advanced):
# This will be called by supybot to configure this module. advanced is # This will be called by supybot to configure this module. advanced is

187
plugins/Admin/messages.pot Normal file
View File

@ -0,0 +1,187 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2010-10-16 09:41+CEST\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"
#: plugin.py:53
#, docstring
msgid "Nick/channel temporarily unavailable."
msgstr ""
#: plugin.py:71
msgid "Cannot join %s, it's full."
msgstr ""
#: plugin.py:79
msgid "Cannot join %s, I was not invited."
msgstr ""
#: plugin.py:87
msgid "Cannot join %s, it's banned me."
msgstr ""
#: plugin.py:95
msgid "Cannot join %s, my keyword was wrong."
msgstr ""
#: plugin.py:103
msgid "Cannot join %s, I'm not identified with the NickServ."
msgstr ""
#: plugin.py:133
#, docstring
msgid ""
"<channel> [<key>]\n"
"\n"
" Tell the bot to join the given channel. If <key> is given, it is used\n"
" when attempting to join the channel.\n"
" "
msgstr ""
#: plugin.py:146
msgid "I'm already too close to maximum number of channels for this network."
msgstr ""
#: plugin.py:155
#, docstring
msgid ""
"takes no arguments\n"
"\n"
" Returns the channels the bot is on. Must be given in private, in order\n"
" to protect the secrecy of secret channels.\n"
" "
msgstr ""
#: plugin.py:165
msgid "I'm not currently in any channels."
msgstr ""
#: plugin.py:171
msgid "My connection is restricted, I can't change nicks."
msgstr ""
#: plugin.py:178
msgid "Someone else is already using that nick."
msgstr ""
#: plugin.py:185
msgid "That nick is currently banned."
msgstr ""
#: plugin.py:192
msgid "I can't change nicks, the server said %q."
msgstr ""
#: plugin.py:206
#, docstring
msgid ""
"[<nick>]\n"
"\n"
" Changes the bot's nick to <nick>. If no nick is given, returns the\n"
" bot's current nick.\n"
" "
msgstr ""
#: plugin.py:221
#, docstring
msgid ""
"[<channel>] [<reason>]\n"
"\n"
" Tells the bot to part the list of channels you give it. <channel> is\n"
" only necessary if you want the bot to part a channel other than the\n"
" current channel. If <reason> is specified, use it as the part\n"
" message.\n"
" "
msgstr ""
#: plugin.py:239
msgid "I'm not in %s."
msgstr ""
#: plugin.py:251
#, docstring
msgid ""
"<name|hostmask> <capability>\n"
"\n"
" Gives the user specified by <name> (or the user to whom <hostmask>\n"
" currently maps) the specified capability <capability>\n"
" "
msgstr ""
#: plugin.py:271
msgid "The \"owner\" capability can't be added in thebot. Use the supybot-adduser program (or edit the users.conf file yourself) to add an owner capability."
msgstr ""
#: plugin.py:282
msgid "You can't add capabilities you don't have."
msgstr ""
#: plugin.py:287
#, docstring
msgid ""
"<name|hostmask> <capability>\n"
"\n"
" Takes from the user specified by <name> (or the user to whom\n"
" <hostmask> currently maps) the specified capability <capability>\n"
" "
msgstr ""
#: plugin.py:299
msgid "That user doesn't have that capability."
msgstr ""
#: plugin.py:301
msgid "You can't remove capabilities you don't have."
msgstr ""
#: plugin.py:309
#, docstring
msgid ""
"<hostmask|nick> [<expires>]\n"
"\n"
" This will set a persistent ignore on <hostmask> or the hostmask\n"
" currently associated with <nick>. <expires> is an optional argument\n"
" specifying when (in \"seconds from now\") the ignore will expire; if\n"
" it isn't given, the ignore will never automatically expire.\n"
" "
msgstr ""
#: plugin.py:322
#, docstring
msgid ""
"<hostmask|nick>\n"
"\n"
" This will remove the persistent ignore on <hostmask> or the\n"
" hostmask currently associated with <nick>.\n"
" "
msgstr ""
#: plugin.py:331
msgid "%s wasn't in the ignores database."
msgstr ""
#: plugin.py:336
#, docstring
msgid ""
"takes no arguments\n"
"\n"
" Lists the hostmasks that the bot is ignoring.\n"
" "
msgstr ""
#: plugin.py:344
msgid "I'm not currently globally ignoring anyone."
msgstr ""

View File

@ -1,5 +1,6 @@
### ###
# Copyright (c) 2002-2005, Jeremiah Fincher # Copyright (c) 2002-2005, Jeremiah Fincher
# Copyright (c) 2010, Valentin Lorentz
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -38,6 +39,8 @@ import supybot.ircmsgs as ircmsgs
import supybot.ircutils as ircutils import supybot.ircutils as ircutils
import supybot.schedule as schedule import supybot.schedule as schedule
import supybot.callbacks as callbacks import supybot.callbacks as callbacks
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('Admin')
class Admin(callbacks.Plugin): class Admin(callbacks.Plugin):
def __init__(self, irc): def __init__(self, irc):
@ -46,6 +49,7 @@ class Admin(callbacks.Plugin):
self.joins = {} self.joins = {}
self.pendingNickChanges = {} self.pendingNickChanges = {}
@internationalizeDocstring
def do437(self, irc, msg): def do437(self, irc, msg):
"""Nick/channel temporarily unavailable.""" """Nick/channel temporarily unavailable."""
target = msg.args[0] target = msg.args[0]
@ -65,7 +69,7 @@ class Admin(callbacks.Plugin):
try: try:
channel = msg.args[1] channel = msg.args[1]
(irc, msg) = self.joins.pop(channel) (irc, msg) = self.joins.pop(channel)
irc.error('Cannot join %s, it\'s full.' % channel) irc.error(_('Cannot join %s, it\'s full.') % channel)
except KeyError: except KeyError:
self.log.debug('Got 471 without Admin.join being called.') self.log.debug('Got 471 without Admin.join being called.')
@ -73,7 +77,7 @@ class Admin(callbacks.Plugin):
try: try:
channel = msg.args[1] channel = msg.args[1]
(irc, msg) = self.joins.pop(channel) (irc, msg) = self.joins.pop(channel)
irc.error('Cannot join %s, I was not invited.' % channel) irc.error(_('Cannot join %s, I was not invited.') % channel)
except KeyError: except KeyError:
self.log.debug('Got 473 without Admin.join being called.') self.log.debug('Got 473 without Admin.join being called.')
@ -81,7 +85,7 @@ class Admin(callbacks.Plugin):
try: try:
channel = msg.args[1] channel = msg.args[1]
(irc, msg) = self.joins.pop(channel) (irc, msg) = self.joins.pop(channel)
irc.error('Cannot join %s, it\'s banned me.' % channel) irc.error(_('Cannot join %s, it\'s banned me.') % channel)
except KeyError: except KeyError:
self.log.debug('Got 474 without Admin.join being called.') self.log.debug('Got 474 without Admin.join being called.')
@ -89,7 +93,7 @@ class Admin(callbacks.Plugin):
try: try:
channel = msg.args[1] channel = msg.args[1]
(irc, msg) = self.joins.pop(channel) (irc, msg) = self.joins.pop(channel)
irc.error('Cannot join %s, my keyword was wrong.' % channel) irc.error(_('Cannot join %s, my keyword was wrong.') % channel)
except KeyError: except KeyError:
self.log.debug('Got 475 without Admin.join being called.') self.log.debug('Got 475 without Admin.join being called.')
@ -97,8 +101,8 @@ class Admin(callbacks.Plugin):
try: try:
channel = msg.args[1] channel = msg.args[1]
(irc, msg) = self.joins.pop(channel) (irc, msg) = self.joins.pop(channel)
irc.error('Cannot join %s, I\'m not identified with the NickServ.' irc.error(_('Cannot join %s, I\'m not identified with the '
% channel) 'NickServ.') % channel)
except KeyError: except KeyError:
self.log.debug('Got 515 without Admin.join being called.') self.log.debug('Got 515 without Admin.join being called.')
@ -125,6 +129,7 @@ class Admin(callbacks.Plugin):
'the user lacked the "admin" capability.', 'the user lacked the "admin" capability.',
channel, msg.prefix) channel, msg.prefix)
@internationalizeDocstring
def join(self, irc, msg, args, channel, key): def join(self, irc, msg, args, channel, key):
"""<channel> [<key>] """<channel> [<key>]
@ -139,13 +144,14 @@ class Admin(callbacks.Plugin):
networkGroup.channels.key.get(channel).setValue(key) networkGroup.channels.key.get(channel).setValue(key)
maxchannels = irc.state.supported.get('maxchannels', sys.maxint) maxchannels = irc.state.supported.get('maxchannels', sys.maxint)
if len(irc.state.channels) + 1 > maxchannels: if len(irc.state.channels) + 1 > maxchannels:
irc.error('I\'m already too close to maximum number of ' irc.error(_('I\'m already too close to maximum number of '
'channels for this network.', Raise=True) 'channels for this network.'), Raise=True)
irc.queueMsg(networkGroup.channels.join(channel)) irc.queueMsg(networkGroup.channels.join(channel))
irc.noReply() irc.noReply()
self.joins[channel] = (irc, msg) self.joins[channel] = (irc, msg)
join = wrap(join, ['validChannel', additional('something')]) join = wrap(join, ['validChannel', additional('something')])
@internationalizeDocstring
def channels(self, irc, msg, args): def channels(self, irc, msg, args):
"""takes no arguments """takes no arguments
@ -157,34 +163,34 @@ class Admin(callbacks.Plugin):
utils.sortBy(ircutils.toLower, L) utils.sortBy(ircutils.toLower, L)
irc.reply(format('%L', L)) irc.reply(format('%L', L))
else: else:
irc.reply('I\'m not currently in any channels.') irc.reply(_('I\'m not currently in any channels.'))
channels = wrap(channels, ['private']) channels = wrap(channels, ['private'])
def do484(self, irc, msg): def do484(self, irc, msg):
irc = self.pendingNickChanges.get(irc, None) irc = self.pendingNickChanges.get(irc, None)
if irc is not None: if irc is not None:
irc.error('My connection is restricted, I can\'t change nicks.') irc.error(_('My connection is restricted, I can\'t change nicks.'))
else: else:
self.log.debug('Got 484 without Admin.nick being called.') self.log.debug('Got 484 without Admin.nick being called.')
def do433(self, irc, msg): def do433(self, irc, msg):
irc = self.pendingNickChanges.get(irc, None) irc = self.pendingNickChanges.get(irc, None)
if irc is not None: if irc is not None:
irc.error('Someone else is already using that nick.') irc.error(_('Someone else is already using that nick.'))
else: else:
self.log.debug('Got 433 without Admin.nick being called.') self.log.debug('Got 433 without Admin.nick being called.')
def do435(self, irc, msg): def do435(self, irc, msg):
irc = self.pendingNickChanges.get(irc, None) irc = self.pendingNickChanges.get(irc, None)
if irc is not None: if irc is not None:
irc.error('That nick is currently banned.') irc.error(_('That nick is currently banned.'))
else: else:
self.log.debug('Got 435 without Admin.nick being called.') self.log.debug('Got 435 without Admin.nick being called.')
def do438(self, irc, msg): def do438(self, irc, msg):
irc = self.pendingNickChanges.get(irc, None) irc = self.pendingNickChanges.get(irc, None)
if irc is not None: if irc is not None:
irc.error(format('I can\'t change nicks, the server said %q.', irc.error(format(_('I can\'t change nicks, the server said %q.'),
msg.args[2]), private=True) msg.args[2]), private=True)
else: else:
self.log.debug('Got 438 without Admin.nick being called.') self.log.debug('Got 438 without Admin.nick being called.')
@ -196,6 +202,7 @@ class Admin(callbacks.Plugin):
except KeyError: except KeyError:
self.log.debug('Got NICK without Admin.nick being called.') self.log.debug('Got NICK without Admin.nick being called.')
@internationalizeDocstring
def nick(self, irc, msg, args, nick): def nick(self, irc, msg, args, nick):
"""[<nick>] """[<nick>]
@ -210,6 +217,7 @@ class Admin(callbacks.Plugin):
irc.reply(irc.nick) irc.reply(irc.nick)
nick = wrap(nick, [additional('nick')]) nick = wrap(nick, [additional('nick')])
@internationalizeDocstring
def part(self, irc, msg, args, channel, reason): def part(self, irc, msg, args, channel, reason):
"""[<channel>] [<reason>] """[<channel>] [<reason>]
@ -229,7 +237,7 @@ class Admin(callbacks.Plugin):
except KeyError: except KeyError:
pass pass
if channel not in irc.state.channels: if channel not in irc.state.channels:
irc.error('I\'m not in %s.' % channel, Raise=True) irc.error(_('I\'m not in %s.') % channel, Raise=True)
irc.queueMsg(ircmsgs.part(channel, reason or msg.nick)) irc.queueMsg(ircmsgs.part(channel, reason or msg.nick))
if msg.nick in irc.state.channels[channel].users: if msg.nick in irc.state.channels[channel].users:
irc.noReply() irc.noReply()
@ -239,6 +247,7 @@ class Admin(callbacks.Plugin):
class capability(callbacks.Commands): class capability(callbacks.Commands):
@internationalizeDocstring
def add(self, irc, msg, args, user, capability): def add(self, irc, msg, args, user, capability):
"""<name|hostmask> <capability> """<name|hostmask> <capability>
@ -260,10 +269,10 @@ class Admin(callbacks.Plugin):
# will depend on supybot.capabilities and its child default) but # will depend on supybot.capabilities and its child default) but
# generally means they can't mess with channel capabilities. # generally means they can't mess with channel capabilities.
if ircutils.strEqual(capability, 'owner'): if ircutils.strEqual(capability, 'owner'):
irc.error('The "owner" capability can\'t be added in the bot.' irc.error(_('The "owner" capability can\'t be added in the'
' Use the supybot-adduser program (or edit the ' 'bot. Use the supybot-adduser program (or edit the '
'users.conf file yourself) to add an owner ' 'users.conf file yourself) to add an owner '
'capability.') 'capability.'))
return return
if ircdb.isAntiCapability(capability) or \ if ircdb.isAntiCapability(capability) or \
ircdb.checkCapability(msg.prefix, capability): ircdb.checkCapability(msg.prefix, capability):
@ -271,9 +280,10 @@ class Admin(callbacks.Plugin):
ircdb.users.setUser(user) ircdb.users.setUser(user)
irc.replySuccess() irc.replySuccess()
else: else:
irc.error('You can\'t add capabilities you don\'t have.') irc.error(_('You can\'t add capabilities you don\'t have.'))
add = wrap(add, ['otherUser', 'lowered']) add = wrap(add, ['otherUser', 'lowered'])
@internationalizeDocstring
def remove(self, irc, msg, args, user, capability): def remove(self, irc, msg, args, user, capability):
"""<name|hostmask> <capability> """<name|hostmask> <capability>
@ -287,14 +297,15 @@ class Admin(callbacks.Plugin):
ircdb.users.setUser(user) ircdb.users.setUser(user)
irc.replySuccess() irc.replySuccess()
except KeyError: except KeyError:
irc.error('That user doesn\'t have that capability.') irc.error(_('That user doesn\'t have that capability.'))
else: else:
s = 'You can\'t remove capabilities you don\'t have.' s = _('You can\'t remove capabilities you don\'t have.')
irc.error(s) irc.error(s)
remove = wrap(remove, ['otherUser','lowered']) remove = wrap(remove, ['otherUser','lowered'])
class ignore(callbacks.Commands): class ignore(callbacks.Commands):
@internationalizeDocstring
def add(self, irc, msg, args, hostmask, expires): def add(self, irc, msg, args, hostmask, expires):
"""<hostmask|nick> [<expires>] """<hostmask|nick> [<expires>]
@ -307,6 +318,7 @@ class Admin(callbacks.Plugin):
irc.replySuccess() irc.replySuccess()
add = wrap(add, ['hostmask', additional('expiry', 0)]) add = wrap(add, ['hostmask', additional('expiry', 0)])
@internationalizeDocstring
def remove(self, irc, msg, args, hostmask): def remove(self, irc, msg, args, hostmask):
"""<hostmask|nick> """<hostmask|nick>
@ -317,9 +329,10 @@ class Admin(callbacks.Plugin):
ircdb.ignores.remove(hostmask) ircdb.ignores.remove(hostmask)
irc.replySuccess() irc.replySuccess()
except KeyError: except KeyError:
irc.error('%s wasn\'t in the ignores database.' % hostmask) irc.error(_('%s wasn\'t in the ignores database.') % hostmask)
remove = wrap(remove, ['hostmask']) remove = wrap(remove, ['hostmask'])
@internationalizeDocstring
def list(self, irc, msg, args): def list(self, irc, msg, args):
"""takes no arguments """takes no arguments
@ -329,7 +342,7 @@ class Admin(callbacks.Plugin):
if ircdb.ignores.hostmasks: if ircdb.ignores.hostmasks:
irc.reply(format('%L', (map(repr,ircdb.ignores.hostmasks)))) irc.reply(format('%L', (map(repr,ircdb.ignores.hostmasks))))
else: else:
irc.reply('I\'m not currently globally ignoring anyone.') irc.reply(_('I\'m not currently globally ignoring anyone.'))
list = wrap(list) list = wrap(list)