Internationalize Config, Network, Plugin, and User

This commit is contained in:
Valentin Lorentz 2010-10-16 13:51:27 +02:00
parent 92d763a33c
commit 1cc1ec93a5
12 changed files with 958 additions and 88 deletions

View File

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

134
plugins/Config/messages.pot Normal file
View File

@ -0,0 +1,134 @@
# 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 12:34+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:136
#, docstring
msgid ""
"<group>\n"
"\n"
" Returns the configuration variables available under the given\n"
" configuration <group>. If a variable has values under it, it is\n"
" preceded by an '@' sign. If a variable is a 'ChannelValue', that is,\n"
" it can be separately configured for each channel using the 'channel'\n"
" command in this plugin, it is preceded by an '#' sign.\n"
" "
msgstr ""
#: plugin.py:148
msgid "There don't seem to be any values in %s."
msgstr ""
#: plugin.py:154
#, docstring
msgid ""
"<word>\n"
"\n"
" Searches for <word> in the current configuration variables.\n"
" "
msgstr ""
#: plugin.py:167
msgid "There were no matching configuration variables."
msgstr ""
#: plugin.py:174
msgid "Global: %s; %s: %s"
msgstr ""
#: plugin.py:185
msgid "That registry variable has no value. Use the list command in this plugin to see what variables are available in this group."
msgstr ""
#: plugin.py:200
#, docstring
msgid ""
"[<channel>] <name> [<value>]\n"
"\n"
" If <value> is given, sets the channel configuration variable for <name>\n"
" to <value> for <channel>. Otherwise, returns the current channel\n"
" configuration value of <name>. <channel> is only necessary if the\n"
" message isn't sent in the channel itself."
msgstr ""
#: plugin.py:207
msgid "That configuration variable is not a channel-specific configuration variable."
msgstr ""
#: plugin.py:220
#, docstring
msgid ""
"<name> [<value>]\n"
"\n"
" If <value> is given, sets the value of <name> to <value>. Otherwise,\n"
" returns the current value of <name>. You may omit the leading\n"
" \"supybot.\" in the name if you so choose.\n"
" "
msgstr ""
#: plugin.py:234
#, docstring
msgid ""
"<name>\n"
"\n"
" Returns the description of the configuration variable <name>.\n"
" "
msgstr ""
#: plugin.py:242
msgid " (Current value: %s)"
msgstr ""
#: plugin.py:245
msgid "That configuration group exists, but seems to have no help. Try \"config list %s\" to see if it has any children values."
msgstr ""
#: plugin.py:249
msgid "%s has no help."
msgstr ""
#: plugin.py:254
#, docstring
msgid ""
"<name>\n"
"\n"
" Returns the default value of the configuration variable <name>.\n"
" "
msgstr ""
#: plugin.py:264
#, docstring
msgid ""
"takes no arguments\n"
"\n"
" Reloads the various configuration files (user database, channel\n"
" database, registry, etc.).\n"
" "
msgstr ""
#: plugin.py:275
#, docstring
msgid ""
"<filename>\n"
"\n"
" Exports the public variables of your configuration to <filename>.\n"
" If you want to show someone your configuration file, but you don't\n"
" want that person to be able to see things like passwords, etc., this\n"
" command will export a \"sanitized\" configuration file suitable for\n"
" showing publicly.\n"
" "
msgstr ""

View File

@ -41,6 +41,8 @@ from supybot.utils.iter import all
import supybot.ircutils as ircutils
import supybot.registry as registry
import supybot.callbacks as callbacks
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('Config')
###
# Now, to setup the registry.
@ -129,6 +131,7 @@ class Config(callbacks.Plugin):
utils.sortBy(str.lower, L)
return L
@internationalizeDocstring
def list(self, irc, msg, args, group):
"""<group>
@ -142,9 +145,11 @@ class Config(callbacks.Plugin):
if L:
irc.reply(format('%L', L))
else:
irc.error('There don\'t seem to be any values in %s.' % group._name)
irc.error(_('There don\'t seem to be any values in %s.') %
group._name)
list = wrap(list, ['configVar'])
@internationalizeDocstring
def search(self, irc, msg, args, word):
"""<word>
@ -159,14 +164,14 @@ class Config(callbacks.Plugin):
if L:
irc.reply(format('%L', L))
else:
irc.reply('There were no matching configuration variables.')
irc.reply(_('There were no matching configuration variables.'))
search = wrap(search, ['lowered']) # XXX compose with withoutSpaces?
def _getValue(self, irc, msg, group, addChannel=False):
value = str(group) or ' '
if addChannel and irc.isChannel(msg.args[0]) and not irc.nested:
s = str(group.get(msg.args[0]))
value = 'Global: %s; %s: %s' % (value, msg.args[0], s)
value = _('Global: %s; %s: %s') % (value, msg.args[0], s)
if hasattr(group, 'value'):
if not group._private:
irc.reply(value)
@ -177,9 +182,9 @@ class Config(callbacks.Plugin):
else:
irc.errorNoCapability(capability)
else:
irc.error('That registry variable has no value. Use the list '
irc.error(_('That registry variable has no value. Use the list '
'command in this plugin to see what variables are '
'available in this group.')
'available in this group.'))
def _setValue(self, irc, msg, group, value):
capability = getCapability(group._name)
@ -190,6 +195,7 @@ class Config(callbacks.Plugin):
else:
irc.errorNoCapability(capability)
@internationalizeDocstring
def channel(self, irc, msg, args, channel, group, value):
"""[<channel>] <name> [<value>]
@ -198,8 +204,8 @@ class Config(callbacks.Plugin):
configuration value of <name>. <channel> is only necessary if the
message isn't sent in the channel itself."""
if not group.channelValue:
irc.error('That configuration variable is not a channel-specific '
'configuration variable.')
irc.error(_('That configuration variable is not a channel-specific '
'configuration variable.'))
return
group = group.get(channel)
if value is not None:
@ -209,6 +215,7 @@ class Config(callbacks.Plugin):
channel = wrap(channel, ['channel', 'settableConfigVar',
additional('text')])
@internationalizeDocstring
def config(self, irc, msg, args, group, value):
"""<name> [<value>]
@ -222,6 +229,7 @@ class Config(callbacks.Plugin):
self._getValue(irc, msg, group, addChannel=group.channelValue)
config = wrap(config, ['settableConfigVar', additional('text')])
@internationalizeDocstring
def help(self, irc, msg, args, group):
"""<name>
@ -231,16 +239,17 @@ class Config(callbacks.Plugin):
s = group.help()
if s:
if hasattr(group, 'value') and not group._private:
s += ' (Current value: %s)' % group
s += _(' (Current value: %s)') % group
irc.reply(s)
else:
irc.reply('That configuration group exists, but seems to have '
'no help. Try "config list %s" to see if it has '
'any children values.' % group._name)
irc.reply(_('That configuration group exists, but seems to '
'have no help. Try "config list %s" to see if it '
'has any children values.') % group._name)
else:
irc.error('%s has no help.' % group._name)
irc.error(_('%s has no help.') % group._name)
help = wrap(help, ['configVar'])
@internationalizeDocstring
def default(self, irc, msg, args, group):
"""<name>
@ -250,6 +259,7 @@ class Config(callbacks.Plugin):
irc.reply(str(v))
default = wrap(default, ['settableConfigVar'])
@internationalizeDocstring
def reload(self, irc, msg, args):
"""takes no arguments
@ -260,6 +270,7 @@ class Config(callbacks.Plugin):
irc.replySuccess()
reload = wrap(reload, [('checkCapability', 'owner')])
@internationalizeDocstring
def export(self, irc, msg, args, filename):
"""<filename>

View File

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

View File

@ -0,0 +1,170 @@
# 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 12:52+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:57
#, docstring
msgid ""
"[--ssl] <network> [<host[:port]>] [<password>]\n"
"\n"
" Connects to another network (which will be represented by the name\n"
" provided in <network>) at <host:port>. If port is not provided, it\n"
" defaults to 6667, the default port for IRC. If password is\n"
" provided, it will be sent to the server in a PASS command. If --ssl is\n"
" provided, an SSL connection will be attempted.\n"
" "
msgstr ""
#: plugin.py:67
msgid "I'm already connected to %s."
msgstr ""
#: plugin.py:87
msgid "A server must be provided if the network is not already registered."
msgstr ""
#: plugin.py:95
msgid "Connection to %s initiated."
msgstr ""
#: plugin.py:102
#, docstring
msgid ""
"[<network>] [<quit message>]\n"
"\n"
" Disconnects from the network represented by the network <network>.\n"
" If <quit message> is given, quits the network with the given quit\n"
" message. <network> is only necessary if the network is different\n"
" from the network the command is sent on.\n"
" "
msgstr ""
#: plugin.py:114
msgid "Disconnection to %s initiated."
msgstr ""
#: plugin.py:120
#, docstring
msgid ""
"[<network>] [<quit message>]\n"
"\n"
" Disconnects and then reconnects to <network>. If no network is given,\n"
" disconnects and then reconnects to the network the command was given\n"
" on. If no quit message is given, uses the configured one\n"
" (supybot.plugins.Owner.quitMsg) or the nick of the person giving the\n"
" command.\n"
" "
msgstr ""
#: plugin.py:137
#, docstring
msgid ""
"<network> <command> [<arg> ...]\n"
"\n"
" Gives the bot <command> (with its associated <arg>s) on <network>.\n"
" "
msgstr ""
#: plugin.py:210
msgid "is an op on %L"
msgstr ""
#: plugin.py:212
msgid "is a halfop on %L"
msgstr ""
#: plugin.py:214
msgid "is voiced on %L"
msgstr ""
#: plugin.py:217
msgid "is also on %L"
msgstr ""
#: plugin.py:219
msgid "is on %L"
msgstr ""
#: plugin.py:221
msgid "isn't on any non-secret channels"
msgstr ""
#: plugin.py:228 plugin.py:229 plugin.py:233
msgid "<unknown>"
msgstr ""
#: plugin.py:240
msgid " identified"
msgstr ""
#: plugin.py:245
msgid "%s (%s) has been%s on server %s since %s (idle for %s) and %s.%s"
msgstr ""
#: plugin.py:258
msgid "There is no %s on %s."
msgstr ""
#: plugin.py:264
#, docstring
msgid ""
"[<network>] <nick>\n"
"\n"
" Returns the WHOIS response <network> gives for <nick>. <network> is\n"
" only necessary if the network is different than the network the command\n"
" is sent on.\n"
" "
msgstr ""
#: plugin.py:280
#, docstring
msgid ""
"takes no arguments\n"
"\n"
" Returns the networks to which the bot is currently connected.\n"
" "
msgstr ""
#: plugin.py:293
msgid "%.2f seconds."
msgstr ""
#: plugin.py:297
#, docstring
msgid ""
"[<network>]\n"
"\n"
" Returns the current latency to <network>. <network> is only necessary\n"
" if the message isn't sent on the network to which this command is to\n"
" apply.\n"
" "
msgstr ""
#: plugin.py:303
msgid "Latency check (from %s)."
msgstr ""
#: plugin.py:311
#, docstring
msgid ""
"[<network>]\n"
"\n"
" Returns the current network driver for <network>. <network> is only\n"
" necessary if the message isn't sent on the network to which this\n"
" command is to apply.\n"
" "
msgstr ""

View File

@ -38,6 +38,8 @@ import supybot.ircmsgs as ircmsgs
import supybot.ircutils as ircutils
import supybot.registry as registry
import supybot.callbacks as callbacks
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('Network')
class Network(callbacks.Plugin):
_whois = {}
@ -50,6 +52,7 @@ class Network(callbacks.Plugin):
raise callbacks.Error, \
'I\'m not currently connected to %s.' % network
@internationalizeDocstring
def connect(self, irc, msg, args, opts, network, server, password):
"""[--ssl] <network> [<host[:port]>] [<password>]
@ -61,7 +64,7 @@ class Network(callbacks.Plugin):
"""
try:
otherIrc = self._getIrc(network)
irc.error('I\'m already connected to %s.' % network)
irc.error(_('I\'m already connected to %s.') % network)
return # We've gotta return here. This is ugly code, but I'm not
# quite sure what to do about it.
except callbacks.Error:
@ -81,19 +84,20 @@ class Network(callbacks.Plugin):
try:
serverPort = conf.supybot.networks.get(network).servers()[0]
except (registry.NonExistentRegistryEntry, IndexError):
irc.error('A server must be provided if the network is not '
'already registered.')
irc.error(_('A server must be provided if the network is not '
'already registered.'))
return
Owner = irc.getCallback('Owner')
newIrc = Owner._connect(network, serverPort=serverPort,
password=password, ssl=ssl)
conf.supybot.networks().add(network)
assert newIrc.callbacks is irc.callbacks, 'callbacks list is different'
irc.replySuccess('Connection to %s initiated.' % network)
irc.replySuccess(_('Connection to %s initiated.') % network)
connect = wrap(connect, ['owner', getopts({'ssl': ''}), 'something',
additional('something'),
additional('something', '')])
@internationalizeDocstring
def disconnect(self, irc, msg, args, otherIrc, quitMsg):
"""[<network>] [<quit message>]
@ -107,10 +111,11 @@ class Network(callbacks.Plugin):
otherIrc.die()
conf.supybot.networks().discard(otherIrc.network)
if otherIrc != irc:
irc.replySuccess('Disconnection to %s initiated.' %
irc.replySuccess(_('Disconnection to %s initiated.') %
otherIrc.network)
disconnect = wrap(disconnect, ['owner', 'networkIrc', additional('text')])
@internationalizeDocstring
def reconnect(self, irc, msg, args, otherIrc, quitMsg):
"""[<network>] [<quit message>]
@ -127,6 +132,7 @@ class Network(callbacks.Plugin):
irc.replySuccess()
reconnect = wrap(reconnect, ['owner', 'networkIrc', additional('text')])
@internationalizeDocstring
def command(self, irc, msg, args, otherIrc, commandAndArgs):
"""<network> <command> [<arg> ...]
@ -201,43 +207,43 @@ class Network(callbacks.Plugin):
voices.append(channel[1:])
L = []
if ops:
L.append(format('is an op on %L', ops))
L.append(format(_('is an op on %L'), ops))
if halfops:
L.append(format('is a halfop on %L', halfops))
L.append(format(_('is a halfop on %L'), halfops))
if voices:
L.append(format('is voiced on %L', voices))
L.append(format(_('is voiced on %L'), voices))
if normal:
if L:
L.append(format('is also on %L', normal))
L.append(format(_('is also on %L'), normal))
else:
L.append(format('is on %L', normal))
L.append(format(_('is on %L'), normal))
else:
L = ['isn\'t on any non-secret channels']
L = [_('isn\'t on any non-secret channels')]
channels = format('%L', L)
if '317' in d:
idle = utils.timeElapsed(d['317'].args[2])
signon = time.strftime(conf.supybot.reply.format.time(),
time.localtime(float(d['317'].args[3])))
else:
idle = '<unknown>'
signon = '<unknown>'
idle = _('<unknown>')
signon = _('<unknown>')
if '312' in d:
server = d['312'].args[2]
else:
server = '<unknown>'
server = _('<unknown>')
if '301' in d:
away = ' %s is away: %s.' % (nick, d['301'].args[2])
else:
away = ''
if '320' in d:
if d['320'].args[2]:
identify = ' identified'
identify = _(' identified')
else:
identify = ''
else:
identify = ''
s = '%s (%s) has been%s on server %s since %s (idle for %s) and ' \
'%s.%s' % (user, hostmask, identify, server, signon, idle,
s = _('%s (%s) has been%s on server %s since %s (idle for %s) and '
'%s.%s') % (user, hostmask, identify, server, signon, idle,
channels, away)
replyIrc.reply(s)
del self._whois[(irc, loweredNick)]
@ -249,10 +255,11 @@ class Network(callbacks.Plugin):
return
(replyIrc, replyMsg, d) = self._whois[(irc, loweredNick)]
del self._whois[(irc, loweredNick)]
s = 'There is no %s on %s.' % (nick, irc.network)
s = _('There is no %s on %s.') % (nick, irc.network)
replyIrc.reply(s)
do401 = do402
@internationalizeDocstring
def whois(self, irc, msg, args, otherIrc, nick):
"""[<network>] <nick>
@ -268,6 +275,7 @@ class Network(callbacks.Plugin):
self._whois[(otherIrc, nick)] = (irc, msg, {})
whois = wrap(whois, ['networkIrc', 'nick'])
@internationalizeDocstring
def networks(self, irc, msg, args):
"""takes no arguments
@ -282,8 +290,9 @@ class Network(callbacks.Plugin):
now = time.time()
if irc in self._latency:
(replyIrc, when) = self._latency.pop(irc)
replyIrc.reply('%.2f seconds.' % (now-when))
replyIrc.reply(_('%.2f seconds.') % (now-when))
@internationalizeDocstring
def latency(self, irc, msg, args, otherIrc):
"""[<network>]
@ -291,11 +300,13 @@ class Network(callbacks.Plugin):
if the message isn't sent on the network to which this command is to
apply.
"""
otherIrc.queueMsg(ircmsgs.ping('Latency check (from %s).' % msg.nick))
otherIrc.queueMsg(ircmsgs.ping(_('Latency check (from %s).') %
msg.nick))
self._latency[otherIrc] = (irc, time.time())
irc.noReply()
latency = wrap(latency, ['networkIrc'])
@internationalizeDocstring
def driver(self, irc, msg, args, otherIrc):
"""[<network>]

View File

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

217
plugins/Plugin/messages.pot Normal file
View File

@ -0,0 +1,217 @@
# 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 13:50+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:43
#, docstring
msgid ""
"This plugin exists to help users manage their plugins. Use 'plugin\n"
" list' to list the loaded plugins; use 'plugin help' to get the description\n"
" of a plugin; use the 'plugin' command itself to determine what plugin a\n"
" command exists in."
msgstr ""
#: plugin.py:49
#, docstring
msgid ""
"<plugin>\n"
"\n"
" Returns a useful description of how to use <plugin>, if the plugin has\n"
" one.\n"
" "
msgstr ""
#: plugin.py:58
msgid "That plugin is loaded, but has no plugin help."
msgstr ""
#: plugin.py:63
#, docstring
msgid ""
"takes no arguments\n"
"\n"
" Returns a list of the currently loaded plugins.\n"
" "
msgstr ""
#: plugin.py:74
#, docstring
msgid ""
"<command>\n"
"\n"
" Returns the plugin(s) that <command> is in.\n"
" "
msgstr ""
#: plugin.py:89
msgid "plugins"
msgstr ""
#: plugin.py:91
msgid "plugin"
msgstr ""
#: plugin.py:92
msgid "The %q command is available in the %L %s."
msgstr ""
#: plugin.py:95
msgid "There is no command %q."
msgstr ""
#: plugin.py:100
#, docstring
msgid ""
"<plugin>\n"
"\n"
" Returns the author of <plugin>. This is the person you should talk to\n"
" if you have ideas, suggestions, or other comments about a given plugin.\n"
" "
msgstr ""
#: plugin.py:106
msgid "That plugin does not seem to be loaded."
msgstr ""
#: plugin.py:112
msgid "That plugin doesn't have an author that claims it."
msgstr ""
#: plugin.py:117
#, docstring
msgid ""
"<plugin> [<nick>]\n"
"\n"
" Replies with a list of people who made contributions to a given plugin.\n"
" If <nick> is specified, that person's specific contributions will\n"
" be listed. Note: The <nick> is the part inside of the parentheses\n"
" in the people listing.\n"
" "
msgstr ""
#: plugin.py:125
#, docstring
msgid ""
"\n"
" Take an Authors object, and return only the name and nick values\n"
" in the format 'First Last (nick)'.\n"
" "
msgstr ""
#: plugin.py:131
#, docstring
msgid ""
"\n"
" Take a list of long names and turn it into :\n"
" shortname[, shortname and shortname].\n"
" "
msgstr ""
#: plugin.py:138
#, docstring
msgid ""
"\n"
" Sort the list of 'long names' based on the number of contributions\n"
" associated with each.\n"
" "
msgstr ""
#: plugin.py:148
#, docstring
msgid ""
"\n"
" Build the list of author + contributors (if any) for the requested\n"
" plugin.\n"
" "
msgstr ""
#: plugin.py:152
msgid "The %s plugin"
msgstr ""
#: plugin.py:153
msgid "has not been claimed by an author"
msgstr ""
#: plugin.py:154
msgid "and"
msgstr ""
#: plugin.py:155
msgid "has no contributors listed."
msgstr ""
#: plugin.py:160
msgid "was written by %s"
msgstr ""
#: plugin.py:171
msgid "%s %h contributed to it."
msgstr ""
#: plugin.py:176
msgid "has no additional contributors listed."
msgstr ""
#: plugin.py:178
msgid "but"
msgstr ""
#: plugin.py:181
#, docstring
msgid ""
"\n"
" Build the list of contributions (if any) for the requested person\n"
" for the requested plugin\n"
" "
msgstr ""
#: plugin.py:195
msgid "The nick specified (%s) is not a registered contributor."
msgstr ""
#: plugin.py:201
msgid "The %s plugin does not have '%s' listed as a contributor."
msgstr ""
#: plugin.py:209
msgid "command"
msgstr ""
#: plugin.py:212
msgid "the %L %s"
msgstr ""
#: plugin.py:214
msgid "the %L"
msgstr ""
#: plugin.py:217
msgid "%s wrote the %s plugin and also contributed %L."
msgstr ""
#: plugin.py:220
msgid "%s contributed %L to the %s plugin."
msgstr ""
#: plugin.py:223
msgid "%s wrote the %s plugin"
msgstr ""
#: plugin.py:226
msgid "%s has no listed contributions for the %s plugin."
msgstr ""

View File

@ -34,13 +34,17 @@ from supybot.commands import *
import supybot.plugins as plugins
import supybot.ircutils as ircutils
import supybot.callbacks as callbacks
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('Plugin')
@internationalizeDocstring
class Plugin(callbacks.Plugin):
"""This plugin exists to help users manage their plugins. Use 'plugin
list' to list the loaded plugins; use 'plugin help' to get the description
of a plugin; use the 'plugin' command itself to determine what plugin a
command exists in."""
@internationalizeDocstring
def help(self, irc, msg, args, cb):
"""<plugin>
@ -51,9 +55,10 @@ class Plugin(callbacks.Plugin):
if doc:
irc.reply(utils.str.normalizeWhitespace(doc))
else:
irc.reply('That plugin is loaded, but has no plugin help.')
irc.reply(_('That plugin is loaded, but has no plugin help.'))
help = wrap(help, ['plugin'])
@internationalizeDocstring
def list(self, irc, msg, args):
"""takes no arguments
@ -64,6 +69,7 @@ class Plugin(callbacks.Plugin):
irc.reply(format('%L', L))
list = wrap(list)
@internationalizeDocstring
def plugin(self, irc, msg, args, command):
"""<command>
@ -80,15 +86,16 @@ class Plugin(callbacks.Plugin):
irc.reply(format('%L', L))
else:
if len(L) > 1:
plugin = 'plugins'
plugin = _('plugins')
else:
plugin = 'plugin'
irc.reply(format('The %q command is available in the %L %s.',
command, L, plugin))
plugin = _('plugin')
irc.reply(format(_('The %q command is available in the %L '
'%s.'), command, L, plugin))
else:
irc.error(format('There is no command %q.', command))
irc.error(format(_('There is no command %q.'), command))
plugin = wrap(plugin, [many('something')])
@internationalizeDocstring
def author(self, irc, msg, args, cb):
"""<plugin>
@ -96,15 +103,16 @@ class Plugin(callbacks.Plugin):
if you have ideas, suggestions, or other comments about a given plugin.
"""
if cb is None:
irc.error('That plugin does not seem to be loaded.')
irc.error(_('That plugin does not seem to be loaded.'))
return
module = cb.classModule
if hasattr(module, '__author__') and module.__author__:
irc.reply(str(module.__author__))
else:
irc.reply('That plugin doesn\'t have an author that claims it.')
irc.reply(_('That plugin doesn\'t have an author that claims it.'))
author = wrap(author, [('plugin')])
@internationalizeDocstring
def contributors(self, irc, msg, args, cb, nick):
"""<plugin> [<nick>]
@ -141,15 +149,15 @@ class Plugin(callbacks.Plugin):
Build the list of author + contributors (if any) for the requested
plugin.
"""
head = 'The %s plugin' % cb.name()
author = 'has not been claimed by an author'
conjunction = 'and'
contrib = 'has no contributors listed.'
head = _('The %s plugin') % cb.name()
author = _('has not been claimed by an author')
conjunction = _('and')
contrib = _('has no contributors listed.')
hasAuthor = False
hasContribs = False
if hasattr(module, '__author__'):
if module.__author__ != supybot.authors.unknown:
author = 'was written by %s' % \
author = _('was written by %s') % \
utils.web.mungeEmail(str(module.__author__))
hasAuthor = True
if hasattr(module, '__contributors__'):
@ -160,14 +168,14 @@ class Plugin(callbacks.Plugin):
except ValueError:
pass
if contribs:
contrib = format('%s %h contributed to it.',
contrib = format(_('%s %h contributed to it.'),
buildContributorsString(contribs),
len(contribs))
hasContribs = True
elif hasAuthor:
contrib = 'has no additional contributors listed.'
contrib = _('has no additional contributors listed.')
if hasContribs and not hasAuthor:
conjunction = 'but'
conjunction = _('but')
return ' '.join([head, author, conjunction, contrib])
def buildPersonString(module):
"""
@ -184,39 +192,39 @@ class Plugin(callbacks.Plugin):
break
authorInfo = authorInfo or getattr(supybot.authors, nick, None)
if not authorInfo:
return 'The nick specified (%s) is not a registered ' \
'contributor.' % nick
return _('The nick specified (%s) is not a registered '
'contributor.') % nick
fullName = utils.web.mungeEmail(str(authorInfo))
contributions = []
if hasattr(module, '__contributors__'):
if authorInfo not in module.__contributors__:
return 'The %s plugin does not have \'%s\' listed as a ' \
'contributor.' % (cb.name(), nick)
return _('The %s plugin does not have \'%s\' listed as a '
'contributor.') % (cb.name(), nick)
contributions = module.__contributors__[authorInfo]
isAuthor = getattr(module, '__author__', False) == authorInfo
(nonCommands, commands) = utils.iter.partition(lambda s: ' ' in s,
contributions)
results = []
if commands:
s = 'command'
s = _('command')
if len(commands) > 1:
s = utils.str.pluralize(s)
results.append(format('the %L %s', commands, s))
results.append(format(_('the %L %s'), commands, s))
if nonCommands:
results.append(format('the %L', nonCommands))
results.append(format(_('the %L'), nonCommands))
if results and isAuthor:
return format(
'%s wrote the %s plugin and also contributed %L.',
_('%s wrote the %s plugin and also contributed %L.'),
(fullName, cb.name(), results))
elif results and not isAuthor:
return format('%s contributed %L to the %s plugin.',
return format(_('%s contributed %L to the %s plugin.'),
fullName, results, cb.name())
elif isAuthor and not results:
return '%s wrote the %s plugin' % (fullName, cb.name())
return _('%s wrote the %s plugin') % (fullName, cb.name())
# XXX Does this ever actually get reached?
else:
return '%s has no listed contributions for the %s plugin.' % \
(fullName, cb.name())
return _('%s has no listed contributions for the %s '
'plugin.') % (fullName, cb.name())
# First we need to check and see if the requested plugin is loaded
module = cb.classModule
if not nick:

View File

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

288
plugins/User/messages.pot Normal file
View File

@ -0,0 +1,288 @@
# 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 13:50+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:49
#, docstring
msgid ""
"[--capability=<capability>] [<glob>]\n"
"\n"
" Returns the valid registered usernames matching <glob>. If <glob> is\n"
" not given, returns all registered usernames.\n"
" "
msgstr ""
#: plugin.py:80
msgid "There are no matching registered users."
msgstr ""
#: plugin.py:82
msgid "There are no registered users."
msgstr ""
#: plugin.py:88
#, docstring
msgid ""
"<name> <password>\n"
"\n"
" Registers <name> with the given password <password> and the current\n"
" hostmask of the person registering. You shouldn't register twice; if\n"
" you're not recognized as a user but you've already registered, use the\n"
" hostmask add command to add another hostmask to your already-registered\n"
" user, or use the identify command to identify just for a session.\n"
" This command (and all other commands that include a password) must be\n"
" sent to the bot privately, not in a channel.\n"
" "
msgstr ""
#: plugin.py:101
msgid "That name is already assigned to someone."
msgstr ""
#: plugin.py:106
msgid "username"
msgstr ""
#: plugin.py:107
msgid "Hostmasks are not valid usernames."
msgstr ""
#: plugin.py:114
msgid "Your hostmask is already registered to %s"
msgstr ""
#: plugin.py:130
#, docstring
msgid ""
"<name> [<password>]\n"
"\n"
" Unregisters <name> from the user database. If the user giving this\n"
" command is an owner user, the password is not necessary.\n"
" "
msgstr ""
#: plugin.py:145
msgid "This command has been disabled. You'll have to ask the owner of this bot to unregister your user."
msgstr ""
#: plugin.py:158
#, docstring
msgid ""
"<name> <new name> [<password>]\n"
"\n"
" Changes your current user database name to the new name given.\n"
" <password> is only necessary if the user isn't recognized by hostmask.\n"
" This message must be sent to the bot privately (not on a channel) since\n"
" it may contain a password.\n"
" "
msgstr ""
#: plugin.py:167
msgid "%q is already registered."
msgstr ""
#: plugin.py:181
#, docstring
msgid ""
"[<name>] <old password> <new password>\n"
"\n"
" Sets the new password for the user specified by <name> to <new\n"
" password>. Obviously this message must be sent to the bot\n"
" privately (not in a channel). If the requesting user is an owner\n"
" user (and the user whose password is being changed isn't that same\n"
" owner user), then <old password> needn't be correct.\n"
" "
msgstr ""
#: plugin.py:209
#, docstring
msgid ""
"<password> [<True|False>]\n"
"\n"
" Sets the secure flag on the user of the person sending the message.\n"
" Requires that the person's hostmask be in the list of hostmasks for\n"
" that user in addition to the password being correct. When the\n"
" secure flag is set, the user *must* identify before he can be\n"
" recognized. If a specific True/False value is not given, it\n"
" inverts the current value.\n"
" "
msgstr ""
#: plugin.py:224
msgid "Secure flag set to %s"
msgstr ""
#: plugin.py:232
#, docstring
msgid ""
"<hostmask|nick>\n"
"\n"
" Returns the username of the user specified by <hostmask> or <nick> if\n"
" the user is registered.\n"
" "
msgstr ""
#: plugin.py:241
msgid "I haven't seen %s."
msgstr ""
#: plugin.py:246
msgid "I don't know who that is."
msgstr ""
#: plugin.py:252
#, docstring
msgid ""
"[<nick>]\n"
"\n"
" Returns the hostmask of <nick>. If <nick> isn't given, return the\n"
" hostmask of the person giving the command.\n"
" "
msgstr ""
#: plugin.py:264
#, docstring
msgid ""
"[<name>]\n"
"\n"
" Returns the hostmasks of the user specified by <name>; if <name>\n"
" isn't specified, returns the hostmasks of the user calling the\n"
" command.\n"
" "
msgstr ""
#: plugin.py:276
msgid "%s has no registered hostmasks."
msgstr ""
#: plugin.py:283
msgid "You may only retrieve your own (hostmasks."
msgstr ""
#: plugin.py:299
#, docstring
msgid ""
"[<name>] [<hostmask>] [<password>]\n"
"\n"
" Adds the hostmask <hostmask> to the user specified by <name>. The\n"
" <password> may only be required if the user is not recognized by\n"
" hostmask. <password> is also not required if an owner user is\n"
" giving the command on behalf of some other user. If <hostmask> is\n"
" not given, it defaults to your current hostmask. If <name> is not\n"
" given, it defaults to your currently identified name. This message\n"
" must be sent to the bot privately (not on a channel) since it may\n"
" contain a password.\n"
" "
msgstr ""
#: plugin.py:313
msgid "hostmask"
msgstr ""
#: plugin.py:314
msgid "Make sure your hostmask includes a nick, then an exclamation point (!), then a user, then an at symbol (@), then a host. Feel free to use wildcards (* and ?, which work just like they do on the command line) in any of these parts."
msgstr ""
#: plugin.py:324 plugin.py:347
msgid "That hostmask is already registered."
msgstr ""
#: plugin.py:355
#, docstring
msgid ""
"<name> <hostmask> [<password>]\n"
"\n"
" Removes the hostmask <hostmask> from the record of the user\n"
" specified by <name>. If the hostmask given is 'all' then all\n"
" hostmasks will be removed. The <password> may only be required if\n"
" the user is not recognized by his hostmask. This message must be\n"
" sent to the bot privately (not on a channel) since it may contain a\n"
" password.\n"
" "
msgstr ""
#: plugin.py:374
msgid "All hostmasks removed."
msgstr ""
#: plugin.py:378
msgid "There was no such hostmask."
msgstr ""
#: plugin.py:387
#, docstring
msgid ""
"[<name>]\n"
"\n"
" Returns the capabilities of the user specified by <name>; if <name>\n"
" isn't specified, returns the capabilities of the user calling the\n"
" command.\n"
" "
msgstr ""
#: plugin.py:407
#, docstring
msgid ""
"<name> <password>\n"
"\n"
" Identifies the user as <name>. This command (and all other\n"
" commands that include a password) must be sent to the bot privately,\n"
" not in a channel.\n"
" "
msgstr ""
#: plugin.py:419
msgid "Your secure flag is true and your hostmask doesn't match any of your known hostmasks."
msgstr ""
#: plugin.py:429
#, docstring
msgid ""
"takes no arguments\n"
"\n"
" Un-identifies you. Note that this may not result in the desired\n"
" effect of causing the bot not to recognize you anymore, since you may\n"
" have added hostmasks to your user that can cause the bot to continue to\n"
" recognize you.\n"
" "
msgstr ""
#: plugin.py:447
#, docstring
msgid ""
"takes no arguments\n"
"\n"
" Returns the name of the user calling the command.\n"
" "
msgstr ""
#: plugin.py:455
msgid "I don't recognize you."
msgstr ""
#: plugin.py:460
#, docstring
msgid ""
"takes no arguments\n"
"\n"
" Returns some statistics on the user database.\n"
" "
msgstr ""
#: plugin.py:478
msgid "I have %s registered users with %s registered hostmasks; %n and %n."
msgstr ""

View File

@ -36,12 +36,15 @@ import supybot.ircdb as ircdb
from supybot.commands import *
import supybot.ircutils as ircutils
import supybot.callbacks as callbacks
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('User')
class User(callbacks.Plugin):
def _checkNotChannel(self, irc, msg, password=' '):
if password and irc.isChannel(msg.args[0]):
raise callbacks.Error, conf.supybot.replies.requiresPrivacy()
@internationalizeDocstring
def list(self, irc, msg, args, optlist, glob):
"""[--capability=<capability>] [<glob>]
@ -74,12 +77,13 @@ class User(callbacks.Plugin):
irc.reply(format('%L', users))
else:
if predicates:
irc.reply('There are no matching registered users.')
irc.reply(_('There are no matching registered users.'))
else:
irc.reply('There are no registered users.')
irc.reply(_('There are no registered users.'))
list = wrap(list, [getopts({'capability':'capability'}),
additional('glob')])
@internationalizeDocstring
def register(self, irc, msg, args, name, password):
"""<name> <password>
@ -94,18 +98,21 @@ class User(callbacks.Plugin):
addHostmask = True
try:
ircdb.users.getUserId(name)
irc.error('That name is already assigned to someone.', Raise=True)
irc.error(_('That name is already assigned to someone.'),
Raise=True)
except KeyError:
pass
if ircutils.isUserHostmask(name):
irc.errorInvalid('username', name,
'Hostmasks are not valid usernames.', Raise=True)
irc.errorInvalid(_('username'), name,
_('Hostmasks are not valid usernames.'),
Raise=True)
try:
u = ircdb.users.getUser(msg.prefix)
if u._checkCapability('owner'):
addHostmask = False
else:
irc.error('Your hostmask is already registered to %s' % u.name)
irc.error(_('Your hostmask is already registered to %s') %
u.name)
return
except KeyError:
pass
@ -118,6 +125,7 @@ class User(callbacks.Plugin):
irc.replySuccess()
register = wrap(register, ['private', 'something', 'something'])
@internationalizeDocstring
def unregister(self, irc, msg, args, user, password):
"""<name> [<password>]
@ -134,9 +142,9 @@ class User(callbacks.Plugin):
if not caller or not isOwner:
self.log.warning('%s tried to unregister user %s.',
msg.prefix, user.name)
irc.error('This command has been disabled. You\'ll have to '
'ask the owner of this bot to unregister your user.',
Raise=True)
irc.error(_('This command has been disabled. You\'ll have to '
'ask the owner of this bot to unregister your '
'user.'), Raise=True)
if isOwner or user.checkPassword(password):
ircdb.users.delUser(user.id)
irc.replySuccess()
@ -145,6 +153,7 @@ class User(callbacks.Plugin):
unregister = wrap(unregister, ['private', 'otherUser',
additional('anything')])
@internationalizeDocstring
def changename(self, irc, msg, args, user, newname, password):
"""<name> <new name> [<password>]
@ -155,7 +164,7 @@ class User(callbacks.Plugin):
"""
try:
id = ircdb.users.getUserId(newname)
irc.error(format('%q is already registered.', newname))
irc.error(format(_('%q is already registered.'), newname))
return
except KeyError:
pass
@ -167,6 +176,7 @@ class User(callbacks.Plugin):
additional('something', '')])
class set(callbacks.Commands):
@internationalizeDocstring
def password(self, irc, msg, args, user, password, newpassword):
"""[<name>] <old password> <new password>
@ -194,6 +204,7 @@ class User(callbacks.Plugin):
password = wrap(password, ['private', optional('otherUser'),
'something', 'something'])
@internationalizeDocstring
def secure(self, irc, msg, args, user, password, value):
"""<password> [<True|False>]
@ -210,12 +221,13 @@ class User(callbacks.Plugin):
user.checkHostmask(msg.prefix, useAuth=False):
user.secure = value
ircdb.users.setUser(user)
irc.reply('Secure flag set to %s' % value)
irc.reply(_('Secure flag set to %s') % value)
else:
irc.error(conf.supybot.replies.incorrectAuthentication())
secure = wrap(secure, ['private', 'user', 'something',
additional('boolean')])
@internationalizeDocstring
def username(self, irc, msg, args, hostmask):
"""<hostmask|nick>
@ -226,15 +238,16 @@ class User(callbacks.Plugin):
try:
hostmask = irc.state.nickToHostmask(hostmask)
except KeyError:
irc.error('I haven\'t seen %s.' % hostmask, Raise=True)
irc.error(_('I haven\'t seen %s.') % hostmask, Raise=True)
try:
user = ircdb.users.getUser(hostmask)
irc.reply(user.name)
except KeyError:
irc.error('I don\'t know who that is.')
irc.error(_('I don\'t know who that is.'))
username = wrap(username, [first('nick', 'hostmask')])
class hostmask(callbacks.Commands):
@internationalizeDocstring
def hostmask(self, irc, msg, args, nick):
"""[<nick>]
@ -246,6 +259,7 @@ class User(callbacks.Plugin):
irc.reply(irc.state.nickToHostmask(nick))
hostmask = wrap(hostmask, [additional('seenNick')])
@internationalizeDocstring
def list(self, irc, msg, args, name):
"""[<name>]
@ -259,14 +273,15 @@ class User(callbacks.Plugin):
hostmasks.sort()
return format('%L', hostmasks)
else:
return format('%s has no registered hostmasks.', user.name)
return format(_('%s has no registered hostmasks.'),
user.name)
try:
user = ircdb.users.getUser(msg.prefix)
if name:
if name != user.name and \
not ircdb.checkCapability(msg.prefix, 'owner'):
irc.error('You may only retrieve your own hostmasks.',
Raise=True)
irc.error(_('You may only retrieve your own '
'(hostmasks.'), Raise=True)
else:
try:
user = ircdb.users.getUser(name)
@ -279,6 +294,7 @@ class User(callbacks.Plugin):
irc.errorNotRegistered()
list = wrap(list, ['private', additional('something')])
@internationalizeDocstring
def add(self, irc, msg, args, user, hostmask, password):
"""[<name>] [<hostmask>] [<password>]
@ -294,18 +310,18 @@ class User(callbacks.Plugin):
if not hostmask:
hostmask = msg.prefix
if not ircutils.isUserHostmask(hostmask):
irc.errorInvalid('hostmask', hostmask,
'Make sure your hostmask includes a nick, '
irc.errorInvalid(_('hostmask'), hostmask,
_('Make sure your hostmask includes a nick, '
'then an exclamation point (!), then a user, '
'then an at symbol (@), then a host. Feel '
'free to use wildcards (* and ?, which work '
'just like they do on the command line) in '
'any of these parts.',
'any of these parts.'),
Raise=True)
try:
otherId = ircdb.users.getUserId(hostmask)
if otherId != user.id:
irc.error('That hostmask is already registered.',
irc.error(_('That hostmask is already registered.'),
Raise=True)
except KeyError:
pass
@ -328,11 +344,13 @@ class User(callbacks.Plugin):
except ValueError, e:
irc.error(str(e), Raise=True)
except ircdb.DuplicateHostmask:
irc.error('That hostmask is already registered.', Raise=True)
irc.error(_('That hostmask is already registered.'),
Raise=True)
irc.replySuccess()
add = wrap(add, ['private', first('otherUser', 'user'),
optional('something'), additional('something', '')])
@internationalizeDocstring
def remove(self, irc, msg, args, user, hostmask, password):
"""<name> <hostmask> [<password>]
@ -353,17 +371,18 @@ class User(callbacks.Plugin):
s = ''
if hostmask == 'all':
user.hostmasks.clear()
s = 'All hostmasks removed.'
s = _('All hostmasks removed.')
else:
user.removeHostmask(hostmask)
except KeyError:
irc.error('There was no such hostmask.')
irc.error(_('There was no such hostmask.'))
return
ircdb.users.setUser(user)
irc.replySuccess(s)
remove = wrap(remove, ['private', 'otherUser', 'something',
additional('something', '')])
@internationalizeDocstring
def capabilities(self, irc, msg, args, user):
"""[<name>]
@ -383,6 +402,7 @@ class User(callbacks.Plugin):
Raise=True)
capabilities = wrap(capabilities, [first('otherUser', 'user')])
@internationalizeDocstring
def identify(self, irc, msg, args, user, password):
"""<name> <password>
@ -396,14 +416,15 @@ class User(callbacks.Plugin):
ircdb.users.setUser(user, flush=False)
irc.replySuccess()
except ValueError:
irc.error('Your secure flag is true and your hostmask '
'doesn\'t match any of your known hostmasks.')
irc.error(_('Your secure flag is true and your hostmask '
'doesn\'t match any of your known hostmasks.'))
else:
self.log.warning('Failed identification attempt by %s (password '
'did not match for %s).', msg.prefix, user.name)
irc.error(conf.supybot.replies.incorrectAuthentication())
identify = wrap(identify, ['private', 'otherUser', 'something'])
@internationalizeDocstring
def unidentify(self, irc, msg, args, user):
"""takes no arguments
@ -421,6 +442,7 @@ class User(callbacks.Plugin):
'recognized.')
unidentify = wrap(unidentify, ['user'])
@internationalizeDocstring
def whoami(self, irc, msg, args):
"""takes no arguments
@ -430,9 +452,10 @@ class User(callbacks.Plugin):
user = ircdb.users.getUser(msg.prefix)
irc.reply(user.name)
except KeyError:
irc.reply('I don\'t recognize you.')
irc.reply(_('I don\'t recognize you.'))
whoami = wrap(whoami)
@internationalizeDocstring
def stats(self, irc, msg, args):
"""takes no arguments
@ -452,9 +475,9 @@ class User(callbacks.Plugin):
admins += 1
except KeyError:
pass
irc.reply(format('I have %s registered users '
irc.reply(format(_('I have %s registered users '
'with %s registered hostmasks; '
'%n and %n.',
'%n and %n.'),
users, hostmasks,
(owners, 'owner'), (admins, 'admin')))
stats = wrap(stats)