Fix command line tool (#31)
This commit is contained in:
parent
1e6667a9ed
commit
4e52393ceb
@ -2,7 +2,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import argparse
|
import argparse
|
||||||
import sys
|
import sys
|
||||||
from googletrans import translator
|
from googletrans import Translator
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
@ -15,6 +15,7 @@ def main():
|
|||||||
parser.add_argument('-c', '--detect', action='store_true', default=False,
|
parser.add_argument('-c', '--detect', action='store_true', default=False,
|
||||||
help='')
|
help='')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
translator = Translator()
|
||||||
|
|
||||||
if args.detect:
|
if args.detect:
|
||||||
result = translator.detect(args.text)
|
result = translator.detect(args.text)
|
||||||
@ -31,7 +32,7 @@ def main():
|
|||||||
->
|
->
|
||||||
[{dest}] {text}
|
[{dest}] {text}
|
||||||
[pron.] {pronunciation}
|
[pron.] {pronunciation}
|
||||||
""".strip().format(src=result.src, dest=result.dest, original=result.origin,
|
""".strip().format(src=result.src, dest=result.dest, original=result.origin,
|
||||||
text=result.text, pronunciation=result.pronunciation)
|
text=result.text, pronunciation=result.pronunciation)
|
||||||
print(result)
|
print(result)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user