mirror of
https://github.com/jlu5/SupyPlugins.git
synced 2025-05-03 08:51:13 -05:00
WTE: be more verbose in output
This commit is contained in:
parent
ea03b40137
commit
b77e6129fe
@ -48,6 +48,9 @@ def configure(advanced):
|
|||||||
|
|
||||||
|
|
||||||
WTE = conf.registerPlugin('WTE')
|
WTE = conf.registerPlugin('WTE')
|
||||||
|
conf.registerChannelValue(WTE, 'verbose',
|
||||||
|
registry.Boolean(False, _("""Determines whether
|
||||||
|
verbose output (list of languages used, etc.) will be used.""")))
|
||||||
conf.registerChannelValue(WTE, 'language',
|
conf.registerChannelValue(WTE, 'language',
|
||||||
registry.String('en', _("""Determines what the output language
|
registry.String('en', _("""Determines what the output language
|
||||||
of 'wte' will be. This should be one of Google Translate's language
|
of 'wte' will be. This should be one of Google Translate's language
|
||||||
|
@ -86,6 +86,7 @@ class WTE(callbacks.Plugin):
|
|||||||
args['q'] = text
|
args['q'] = text
|
||||||
url = "http://translate.google.com/translate_a/t?"+ \
|
url = "http://translate.google.com/translate_a/t?"+ \
|
||||||
urlencode(args)
|
urlencode(args)
|
||||||
|
self.log.debug("WTE: Using URL %s" % url)
|
||||||
try:
|
try:
|
||||||
data = json.loads(utils.web.getUrl(url).decode("utf-8"))
|
data = json.loads(utils.web.getUrl(url).decode("utf-8"))
|
||||||
except utils.web.Error as e:
|
except utils.web.Error as e:
|
||||||
@ -102,10 +103,13 @@ class WTE(callbacks.Plugin):
|
|||||||
multiple rounds of Google Translate to get amazing results!
|
multiple rounds of Google Translate to get amazing results!
|
||||||
"""
|
"""
|
||||||
outlang = self.registryValue('language', msg.args[0])
|
outlang = self.registryValue('language', msg.args[0])
|
||||||
|
inp = text
|
||||||
if outlang not in self.langs:
|
if outlang not in self.langs:
|
||||||
irc.error("Unrecognized output language. Please set "
|
irc.error("Unrecognized output language. Please set "
|
||||||
"'config plugins.wte.language' correctly.", Raise=True)
|
"'config plugins.wte.language' correctly.", Raise=True)
|
||||||
ll = random.sample(self.langs, random.randint(6,12))
|
ll = random.sample(self.langs, random.randint(6,12))
|
||||||
|
self.log.debug(format("WTE: Using %i languages: %L "
|
||||||
|
"(outlang %s)", len(ll), ll, outlang))
|
||||||
for targetlang in ll:
|
for targetlang in ll:
|
||||||
text = self.getTranslation(irc, "auto", targetlang, text)
|
text = self.getTranslation(irc, "auto", targetlang, text)
|
||||||
text = self.getTranslation(irc, "auto", outlang, text)
|
text = self.getTranslation(irc, "auto", outlang, text)
|
||||||
@ -117,6 +121,10 @@ class WTE(callbacks.Plugin):
|
|||||||
"are some lingering issues handling Unicode on "
|
"are some lingering issues handling Unicode on "
|
||||||
"versions of Python 2.")
|
"versions of Python 2.")
|
||||||
irc.error(s, Raise=True)
|
irc.error(s, Raise=True)
|
||||||
|
if self.registryValue("verbose", msg.args[0]):
|
||||||
|
irc.reply(format("Translated through \x02%i\x02 languages: %L "
|
||||||
|
"(outlang %s)",
|
||||||
|
len(ll), ll, outlang))
|
||||||
irc.reply(text)
|
irc.reply(text)
|
||||||
wte = wrap(wte, ['text'])
|
wte = wrap(wte, ['text'])
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user