diff --git a/misskaty/helper/tools.py b/misskaty/helper/tools.py index 40dfec1a..ba07a6c0 100644 --- a/misskaty/helper/tools.py +++ b/misskaty/helper/tools.py @@ -6,6 +6,7 @@ import string import time from http.cookies import SimpleCookie from re import match as re_match +from googletrans import Translator from typing import Union from urllib.parse import urlparse @@ -47,6 +48,12 @@ GENRES_EMOJI = { } +async def gtranslate(text, source="auto", target="id"): + async with Translator() as translator: + result = await translator.translate(text, source, target) + return result + + def is_url(url): url = re_match(URL_REGEX, url) return bool(url)