Skip to main content

Library for using accurate Google Translate in Python

Project description

google-translate.py

issues forks stars license PyPI Python

Library for using accurate Google Translate in Python

Pythonで正確なGoogle翻訳を使用するためのライブラリ


English

This library uses the translation function of Google Apps Script.

install

Install using pip.

pip install google-translate.py

How to use

Normal:

from google_translate_py import Translator

print(Translator().translate("Hello World!!", "en", "ja"))

>>> こんにちは世界!!

Async version:

import asyncio
from google_translate_py import AsyncTranslator

async def main():
    print(await AsyncTranslator().translate("Hello World!!", "en", "ja"))

loop = asyncio.get_event_loop()
loop.run_until_complete(main())

>>> こんにちは世界!!

Automatic language judgment

If you leave the second argument (source) empty, the language will be determined automatically.

Normal:

from google_translate_py import Translator

print(Translator().translate("Hallo Welt!!", "", "ja"))

>>> こんにちは世界!!

Async version:

import asyncio
from google_translate_py import AsyncTranslator

async def main():
    print(await AsyncTranslator().translate("Hallo Welt!!", "", "ja"))

loop = asyncio.get_event_loop()
loop.run_until_complete(main())

>>> こんにちは世界!!

Thank you for reading!

日本語

このライブラリはGoogle Apps Scriptの翻訳機能を利用しています。

インストール

pipを使用してインストールします。

pip install google-translate.py

使い方

通常:

from google_translate_py import Translator

print(Translator().translate("Hello World!!", "en", "ja"))

>>> こんにちは世界!!

非同期版:

import asyncio
from google_translate_py import AsyncTranslator

async def main():
    print(await AsyncTranslator().translate("Hello World!!", "en", "ja"))

loop = asyncio.get_event_loop()
loop.run_until_complete(main())

>>> こんにちは世界!!

自動言語判定

二つ目の引数(source)を空にしておくと言語を自動で判定してくれます。

通常:

from google_translate_py import Translator

print(Translator().translate("Hallo Welt!!", "", "ja"))

>>> こんにちは世界!!

非同期版:

import asyncio
from google_translate_py import AsyncTranslator

async def main():
    print(await AsyncTranslator().translate("Hallo Welt!!", "", "ja"))

loop = asyncio.get_event_loop()
loop.run_until_complete(main())

>>> こんにちは世界!!

読んでくれてありがとうございます!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

google-translate.py-1.0.0.tar.gz (3.2 kB view hashes)

Uploaded source

Built Distribution

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page