Skip to main content

Simple & Easy Way For Baidu Translation

Project description

catly_translate

Simple & Easy Way For Baidu Translation

Here're some basic usages.

>>> import catly_translate
>>> catly_translate.translate("Hello")
['你好']
>>> catly_translate.translate("こんにちは")
['你好']
>>> catly_translate.translate("Hello\nWorld")
['你好', '世界']
>>> catly_translate.translate("こんにちは\r\n世界")
['你好', '世界']

The default setting is auto language to Chinese Simplified(zh).

def translate(text: str, from_lang="auto", to_lang="zh") -> str:
    ...

from_lang=auto is suitable in most case, try change when translation not as expected.

You can also manualy specify keyword from_lang, to_lang or both.

>>> catly_translate.translate("Hello", "en", "jp")
['こんにちは']
>>> catly_translate.translate("你好", to_lang="en")
['Hello']
>>> catly_translate.translate("你好", to_lang="jp")
['こんにちは']

# Note: Max string length is 5000 per translation due to Baidu API limit.

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

catly_translate-0.1.2.tar.gz (5.3 kB view hashes)

Uploaded Source

Built Distribution

catly_translate-0.1.2-py3-none-any.whl (5.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page