fix translate module, convert to 4 space tabs
parent
4593a1ae9d
commit
2820bc61d6
|
@ -74,20 +74,23 @@ tr.priority = 'low'
|
|||
|
||||
def tr2(phenny, input):
|
||||
"""Translates a phrase, with an optional language hint."""
|
||||
command = input.group(2).encode('utf-8')
|
||||
command = input.group(2)
|
||||
if not command:
|
||||
phenny.reply("Please provide a phrase to translate")
|
||||
return
|
||||
|
||||
def langcode(p):
|
||||
return p.startswith(':') and (2 < len(p) < 10) and p[1:].isalpha()
|
||||
|
||||
args = ['auto', 'en']
|
||||
|
||||
for i in xrange(2):
|
||||
for i in range(2):
|
||||
if not ' ' in command: break
|
||||
prefix, cmd = command.split(' ', 1)
|
||||
if langcode(prefix):
|
||||
args[i] = prefix[1:]
|
||||
command = cmd
|
||||
phrase = command
|
||||
phrase = command.encode('utf-8')
|
||||
|
||||
if (len(phrase) > 350) and (not input.admin):
|
||||
return phenny.reply('Phrase must be under 350 characters.')
|
||||
|
@ -95,8 +98,8 @@ def tr2(phenny, input):
|
|||
src, dest = args
|
||||
if src != dest:
|
||||
msg, src = translate(phrase, src, dest)
|
||||
if isinstance(msg, str):
|
||||
msg = msg.decode('utf-8')
|
||||
#if isinstance(msg, str):
|
||||
# msg = msg.decode('utf-8')
|
||||
if msg:
|
||||
msg = web.decode(msg) # msg.replace(''', "'")
|
||||
msg = '"%s" (%s to %s, translate.google.com)' % (msg, src, dest)
|
||||
|
|
Loading…
Reference in New Issue