🐛 Fix translate module not found error
This commit is contained in:
parent
338a313807
commit
0d0602042a
@ -1,14 +1,11 @@
|
|||||||
""" PagerMaid features that uses external HTTP APIs other than Telegram. """
|
""" PagerMaid features that uses external HTTP APIs other than Telegram. """
|
||||||
|
|
||||||
import translators as ts
|
|
||||||
from os import remove
|
from os import remove
|
||||||
from magic_google import MagicGoogle
|
from magic_google import MagicGoogle
|
||||||
from gtts import gTTS
|
from gtts import gTTS
|
||||||
from gtts.tts import gTTSError
|
from gtts.tts import gTTSError
|
||||||
from re import compile as regex_compile
|
from re import compile as regex_compile
|
||||||
|
|
||||||
from translators.apis import TranslatorError
|
|
||||||
|
|
||||||
from pagermaid import log, silent
|
from pagermaid import log, silent
|
||||||
from pagermaid.listener import listener, config
|
from pagermaid.listener import listener, config
|
||||||
from pagermaid.utils import clear_emojis, attach_log, fetch_youtube_audio, lang, alias_command
|
from pagermaid.utils import clear_emojis, attach_log, fetch_youtube_audio, lang, alias_command
|
||||||
@ -34,7 +31,13 @@ async def translate(context):
|
|||||||
if not silent:
|
if not silent:
|
||||||
await context.edit(lang('translate_processing'))
|
await context.edit(lang('translate_processing'))
|
||||||
try:
|
try:
|
||||||
result = ts.google(source_text, to_language=ap_lang.replace("zh-cn", "zh-CN"))
|
from translators.apis import TranslatorError
|
||||||
|
from translators import google
|
||||||
|
except ModuleNotFoundError:
|
||||||
|
await context.edit(lang('translate_ImportError'))
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
result = google(source_text, to_language=ap_lang.replace("zh-cn", "zh-CN"))
|
||||||
except TranslatorError:
|
except TranslatorError:
|
||||||
return await context.edit(lang('translate_ValueError'))
|
return await context.edit(lang('translate_ValueError'))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
Loading…
Reference in New Issue
Block a user