google_trans_new but it is async!
Project description
async_google_trans_new
This is a library based on google_trans_new but it is async!
It's very easy to use and solve the problem that the old api which use tk value cannot be used.
This interface is for academic use only, please do not use it for commercial use.
Installation
Run this:
pip install async-google-trans-new
Basic Usage
Translate
import asyncio
import async_google_trans_new
async def coro():
g = async_google_trans_new.AsyncTranslator()
print(await g.translate("こんにちは、世界!","en"))
loop = asyncio.get_event_loop()
loop.run_until_complete(coro())
-> Hello world!
Advanced Usage
Translate
Multi Translate
import asyncio
from async_google_trans_new import AsyncTranslator
async def coro():
g = AsyncTranslator()
texts = ["こんにちは、世界!", "こんばんは、世界!", "おはよう、世界!"]
gathers = []
for text in texts:
gathers.append(g.translate(text, "en"))
print(await asyncio.gather(*gathers))
loop = asyncio.get_event_loop()
loop.run_until_complete(coro())
-> ['Hello World! ', 'Good evening, the world! ', 'Good morning, the world! ']
Prerequisites
- Python 3.8 (Please make GitHub issue if you can use this lib on different python version)
- aiohttp
- urllib3
License
Please see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
File details
Details for the file async_google_trans_new-1.4.6-py3-none-any.whl
.
File metadata
- Download URL: async_google_trans_new-1.4.6-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50492183e9e9fb081376ad8e94a49dcaa3afa1ffa87a47710c0f04251b201e39 |
|
MD5 | 14b5ac9d8ce9597f8cf1638b4cb66b47 |
|
BLAKE2b-256 | 7b01f59d3c01623dd4c2c975d3fda0b117bfd189e5ba694830ab93b44b70c7fe |