Skip to main content

No project description provided

Project description

tra-yan

awesome free asynchronous translator for python

Installation

pip install -U tra-yan

Usage

async def use():
    from trayan import (
        TraYan, AsyncTraYan,
        detect, translate,
        async_detect, async_translate,
        get_supported_langs
    )
    from trayan.models.translator import Language

    ru = 'красивый мужчина в отличных трусах'
    en = 'a handsome man in great underpants'
    proxy = None  # 'scheme://login:password@ip:port'

    with TraYan() as t:
        print(f'{ru} — {t.detect(ru, Language.RU)}')
        print(f'ru-en — {t.translate(ru, Language.RU, Language.EN)}')

    print(f'{en} — {detect(en)}')
    print(f'en-ru — {translate(en)}')

    async with AsyncTraYan(proxy=proxy) as t:
        print(f'{en} — {await t.detect(en, (Language.RU,))}')
        print(f'en-ru — {await t.translate(en, Language.EN, Language.RU)}')

    print(f'{ru} — {await async_detect(ru, proxy=proxy)}')
    print(f'ru-en — {await async_translate(ru, proxy=proxy)}')

    print(f'поддерживаемые языки: {TraYan.supported_langs}')

    print(f'supported langs: {get_supported_langs()}')


if __name__ == '__main__':
    import asyncio

    asyncio.run(use())

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

tra-yan-0.1.0.tar.gz (7.6 kB view hashes)

Uploaded Source

Built Distribution

tra_yan-0.1.0-py3-none-any.whl (12.0 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